akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;
int dpl[3010][3010];
int dpr[3010][3010];

int main(){
    int n,t;
    cin>>n>>t;
    vector<int> a(n+1),b(n+1);
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=t;j++){
            dpl[i][j]=dpl[i-1][j];
            int from=j-a[i];
            if(from>=0) dpl[i][j]=max(dpl[i][j],dpl[i-1][from]+b[i]);
        }
    }
    for(int i=n;i>0;i--){
        for(int j=0;j<=t;j++){
            dpr[i][j]=dpr[i+1][j];
            int from=j-a[i];
            if(from>=0) dpr[i][j]=max(dpr[i][j],dpr[i+1][from]+b[i]);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<t;j++){
            ans=max(ans,b[i]+dpl[i-1][j]+dpr[i+1][t-j-1]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 74176
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
char str[MAXN];
map<pair<string,string>,int> mp;
int main()
{
    scanf("%d",&n);
    scanf("%s",str);
    for(int mask=0;mask<(1<<n);mask++)
    {
        string str1="",str2="";
        for(int i=0;i<n;i++)
        {
            if(mask&(1<<i)) str1+=str[i]; else str2+=str[i];
        }
        mp[make_pair(str1,str2)]++;
    }
    ll ans=0;
    for(int mask=0;mask<(1<<n);mask++)
    {
        string str1="",str2="";
        for(int i=0;i<n;i++)
        {
            if(mask&(1<<i)) str1+=str[2*n-1-i]; else str2+=str[2*n-1-i];
        }
        ans+=mp[make_pair(str1,str2)];
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 91904
Tree = {}
Parents = {}
Siblings = {}

n = gets.to_i
n.times do
  i, l, r = gets.split(' ').map(&:to_i)
  Parents[l] = Parents[r] = i
  Siblings[l] = r
  Siblings[r] = l
  Tree[i] = [l, r]
end

Parents[-1] = nil

Tree.sort.each do |i, n|
  p = Parents[i]
  s = Siblings[i]
  if Parents[i].nil?
    t = 'root'
    p = -1
    s = -1
  elsif n == [-1, -1]
    t = 'leaf'
  else
    t = 'internal node'
  end

  depth = -> (d, j) do
    return d if Parents[j].nil?
    return depth.(d + 1, Parents[j])
  end

  height = -> (h, n) do
    return h if n == -1
    return [height.(h + 1, Tree[n][0]), height.(h + 1, Tree[n][1])].max
  end

  d = depth.(0, i)
  h = [height.(0, n[0]), height.(0, n[1])].max
  g = n.select{|c| c != -1}.size

  puts "node #{i}: parent = #{p}, sibling = #{s}, degree = #{g}, depth = #{d}, height = #{h}, #{t}"
end


Measured memory_bytes: 6880
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define dbg(...)                debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

vector<string> vec_splitter(string s){
    s += ','; vector<string> res;
    while(!s.empty()) res.push_back(s.substr(0,s.find(','))), s = s.substr(s.find(',') + 1);
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused))int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T){
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...);
}






main(){
//read;


int k,a,b;
cin>>k>>a>>b;

for(int i = a; i<=b; i++){
    if(i%k==0){
        cout<<"OK";
        return 0;
    }
}

cout<<"NG";



return 0;
}


Measured memory_bytes: 3608
using System;
using System.IO;

namespace AtCoder.R167.A
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, string answer)
        {
            tw.WriteLine(answer);
        }

        private static string Parse(TextReader tr)
        {
            var s = tr.ReadLine();
            var t = tr.ReadLine();
            return Calc(s, t);
        }

        public static string Calc(string s, string t)
        {
            return s.Length == t.Length - 1 && s == t.Substring(0, s.Length) ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 25680
#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    ll n, m;
    cin >> n >> m;
    if (n > m) {
        swap(n, m);
    }
    ll even = 0;
    if (n == 1) {
        cout << n * m - (m > 2 ? 2: 0);
        return;
    }
    even = 4 + (n - 2) * 2  + (m - 2) * 2;


    cout << n * m - even;

}


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)

using namespace std;

int main(void) {
	int N, X;
	int L[105];

    scanf("%d %d", &N, &X);
    REP(i, 1, N + 1) scanf("%d", &L[i]);
    L[N + 1] = 10005;

    int ans = 0;
    int i = 1;
    for (int D = 0; D <= X; D += L[i++]) ans++;
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

struct Tree {
  int key;
  Tree *left, *right, *parent;
};

void insert(Tree* trees, Tree* new_tree) {
  Tree *cur_tree = trees;
  Tree *pre_tree;
  bool is_left_selected;
  while (cur_tree != nullptr) {
    pre_tree = cur_tree;
      if (new_tree->key < cur_tree->key) {
        cur_tree = pre_tree->left;
        is_left_selected = true;
      } else {
        cur_tree = pre_tree->right;
        is_left_selected = false;
      }
  }
  new_tree->parent = pre_tree;
  if (is_left_selected) {
    pre_tree->left = new_tree;
  } else {
    pre_tree->right = new_tree;
  }
}

void inorder(Tree *tree) {
  if (tree->left != nullptr) {
    inorder(tree->left);
  }
  cout << " " << tree->key;
  if (tree->right != nullptr) {
    inorder(tree->right);
  }
}

void preorder(Tree *tree) {
  cout << " " << tree->key;
  if (tree->left != nullptr) {
    preorder(tree->left);
  }
  if (tree->right != nullptr) {
    preorder(tree->right);
  }
}

void print(Tree* trees) {
  inorder(trees);
  cout << endl;
  preorder(trees);
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  Tree* trees = nullptr;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s.find("insert") != string::npos) {
      int key;
      Tree* new_tree = new Tree;
      cin >> new_tree->key;
      new_tree->parent = nullptr;
      new_tree->left = nullptr;
      new_tree->right = nullptr;
      if (trees == nullptr) {
        trees = new_tree;
      } else {
        insert(trees, new_tree);
      }
    } else {
      print(trees);
    }
  }
  return 0;
}



Measured memory_bytes: 26560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,res=0,x;
	cin>>n;
	
	vector<int> a(n,-1);
	
	for(int i=0;i<n-1;i++){
		cin>>x;
		if(i==0) a[0]=a[1]=x;
		else{
			if( a[i]>x )a[i]=x;
			a[i+1]=x;
		}
	}

	for(int i=0;i<n;i++) res+=a[i];
	cout<<res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;


long long cnt[1000002];



int main()
{
    long long n , k , q;

    cin >> n >> k >> q;



    for(int i=0; i<q; i++)
    {
        long long a;

        cin >> a;
        cnt[a]++;
    }


    for(int i=1; i<=n; i++)
    {
        long long ans = k-(q-cnt[i]);


        if(ans<=0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes"<< endl;
        }

    }

    return 0;
}


Measured memory_bytes: 1408
from collections import deque

h, w = map(int, input().split())
S = [['#']*(w+2)]

for _ in range(h):
    s = str(input())
    new_s = ['#']
    for x in s:
        new_s.append(x)
    new_s.append('#')
    S.append(new_s)
S.append(['#']*(w+2))

Possible_list = []
for i in range(h+2):
    for j in range(w+2):
        if S[i][j] == '.':
            Possible_list.append((i,j))

max_length = 0

for zahyou in Possible_list:
    dq = deque()
    Visited = [-1 for _ in range(len(Possible_list))]
    Visited[Possible_list.index(zahyou)] = 0
    dq.append(zahyou)
    
    while dq:
        now = dq.popleft()
        
        Adj_possible = []
        if (now[0]-1, now[1]) in Possible_list:
            Adj_possible.append((now[0]-1, now[1]))
        if (now[0]+1, now[1]) in Possible_list:
            Adj_possible.append((now[0]+1, now[1]))
        if (now[0], now[1]-1) in Possible_list:
            Adj_possible.append((now[0], now[1]-1))
        if (now[0], now[1]+1) in Possible_list:
            Adj_possible.append((now[0], now[1]+1))
        
        for next_zahyou in Adj_possible:
            if Visited[Possible_list.index(next_zahyou)] != -1:
                continue
            Visited[Possible_list.index(next_zahyou)] = Visited[Possible_list.index(now)] + 1
            dq.append(next_zahyou)
    
    max_length = max(max_length, max(Visited))

print(max_length)

Measured memory_bytes: 47708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		int ans = 0;
		double money = 100;
		double risi = 0;

		while (money < X) {
			risi = money*0.01;
			risi = Math.floor(risi);
			money = money + risi;
			ans++;
			risi = 0;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 35732
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN = 110;
int n, W, w[MAXN], v[MAXN];
int dp[MAXN][310], b, ans, w1;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = x*10 + ch-'0';
	return x * f;
}

int main() {
	int i, j, k;
	n = read(), W = read();
	w1 = read(), v[1] = read();
	for(i = 2; i <= n; i++) {
		w[i] = read()-w1;
		v[i] = read();
	}
	b = max(W-300, 0);
	for(i = 1; i <= n; i++) {
		for(j = i; j >= 1; j--) {
			if((ll)j*w1 > W) continue;
			for(k = 0; k <= 300; k++) {
				if((ll)j*w1+k > W) break;
				if(k < w[i]) continue;
				dp[j][k] = max(dp[j][k], dp[j-1][k-w[i]]+v[i]);
				//printf("%d ", dp[j][k]);
			}
			//printf("\n");
		}
		//printf("\n");
	}
	for(j = 1; j <= n; j++) 
		for(k = 0; k <= 300; k++) ans = max(ans, dp[j][k]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
from collections import deque

n = int(input())
edge = [list(map(int, input().split())) for _ in range(n-1)]

adj = [[] for _ in range(n+1)]

for i in range(n-1):
    u, v, w = edge[i]
    adj[u].append([v, w])
    adj[v].append([u, w])

q = deque([1])

dist = [0] * (n+1)
visited = [False] * (n+1)

while len(q) > 0:
    v = q.popleft()
    for w, d in adj[v]:
        if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist)

for i in range(1, n+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 120160
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(ll arg_size,ll arg_value){
		size = arg_size;
		value = arg_value;
	}
	ll size,value;
	bool operator<(const struct Info &arg) const{
		return size < arg.size;
	}
};

vector<Info> info;
ll ruisekiwa[500001],minus_value[500001];

int main(){

	int N;
	scanf("%d",&N);

	info.push_back(Info(0,0));

	ll size,value;

	for(int i = 1; i <= N; i++){
		scanf("%lld %lld",&size,&value);
		info.push_back(Info(size,value));
	}

	sort(info.begin(),info.end());

	ruisekiwa[0] = 0;
	minus_value[0] = 0;

	for(int i = 1; i <= N; i++){
		ruisekiwa[i] = info[i].value;
		ruisekiwa[i] += ruisekiwa[i-1];
		minus_value[i] = ruisekiwa[i-1]-info[i].size;
	}

	for(int i = 2; i <= N; i++){
		minus_value[i] = min(minus_value[i],minus_value[i-1]);
	}

	ll ans = -99999999999999999;

	for(int i = N; i >= 1; i--){
		ans = max(ans,ruisekiwa[i]-info[i].size-minus_value[i]);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 18508
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int A,B,sum = 0;

        A = Integer.parseInt(scan.next());
        B = Integer.parseInt(scan.next());
        
        for(int i = 0;i < 2;i++){
            if(A > B){
                sum += A;
                A--;
            }else{
                sum += B;
                B--;
            }
        }
        System.out.println(sum);
            
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string s;
  cin >> s;
  s += s[0];
  s += s[1];
  for (int c = 0; c < 4; c++)
  {
    string ans;
    if (c == 0)
    {
      ans += 'S';
      ans += 'S';
    }
    else if (c == 1)
    {
      ans += 'S';
      ans += 'W';
    }
    else if (c == 2)
    {
      ans += 'W';
      ans += 'S';
    }
    else
    {
      ans += 'W';
      ans += 'W';
    }
    for (int i = 2; i <= N + 1; i++)
    {
      if (ans[i - 1] == 'S')
      {
        if (s[i - 1] == 'o')
        {
          ans += ans[i - 2];
        }
        else
        {
          ans += (ans[i - 2] == 'S') ? 'W' : 'S';
        }
      }
      else
      {
        if (s[i - 1] == 'o')
        {
          ans += (ans[i - 2] == 'S') ? 'W' : 'S';
        }
        else
        {
          ans += ans[i - 2];
        }
      }
      if (i == N + 1)
      {
        if (ans[0] == ans[N] && ans[1] == ans[N + 1])
        {
          for (int i = 0; i < N; i++)
            cout << ans[i];
          cout << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 712
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i,ty-sy) cout << 'U';
    rep(i,tx-sx) cout << 'R';
    rep(i,ty-sy) cout << 'D';
    rep(i,tx-sx) cout << 'L';
    cout << 'L';
    rep(i,ty-sy+1) cout << 'U';
    rep(i,tx-sx+1) cout <<'R';
    cout << 'D';
    cout << 'R';
    rep(i,ty-sy+1) cout << 'D';
    rep(i,tx-sx+1) cout << 'L';
    cout << 'U' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    char c;

    cin >> c;

    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
 
        cout << "vowel" << endl;

    }

    else{

        cout << "consonant" << endl;


    }

}

Measured memory_bytes: 256
#! /usr/bin/env python3

s = input()
k = int(input())

alphabets = 'abcdefghijklmnopqrstuvwxyz'

dic = []

for char in alphabets:
    
    index = 0
    ss = []
    while index != -1:
        index = s.find(char, index)

        if index != -1:
            tmp = s[index:index + 5]
            isSubstring = False
            for sss in ss:
                if sss.find(tmp) == 0:
                    isSubstring = True
                    break
            if isSubstring == False:
                ss.append(tmp)

            index += 1

    if  len(ss) > 0:
        ss.sort()
        for x in ss:
            for i in range(len(x)):
                if x[0:i+1] not in dic:
                    dic.append(x[0:i+1])
                    if len(dic) >= k:
                        break
        if len(dic) >= k:
            break

print(dic[k-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, L;
int a[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int pos = -1;
  for (int i = 0; i + 1 < N; i++) {
    if (a[i] + a[i + 1] >= L) pos = i;
  }
  if (pos < 0) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  // cout << pos << endl;
  vector<int> vs;
  vs.emplace_back(pos + 1);
  for (int i = pos - 1; i >= 0; i--) {
    vs.emplace_back(i + 1);
  }
  for (int i = pos + 1; i < N - 1; i++) {
    vs.emplace_back(i + 1);
  }
  reverse(vs.begin(), vs.end());
  for (int v : vs) {
    cout << v << endl;
  }

  return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+1,inf=INT_MAX;
int a[N],d[N];
int n;
int ans;
int main(){
	scanf("%d",&n);
	for(int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i = 1;i<=n;i++){
		d[a[i]]=d[a[i]-1]+1;
		ans=max(ans,d[a[i]]);
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
    int i = 1;

    int a,b,c;
    cin >> a >> b >> c;
        int result = max(a,b);
    while(true){
        if(a % result == 0 && b % result == 0){
            if(i == c){
                cout << result << endl;
                break;
            }else{
                i++;
            }
        }
        result--;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s1 = scanner.next(), s2 = scanner.next();
		StringBuffer sb = new StringBuffer(s2);
        String s3 = sb.reverse().toString();
		if(s1.equals(s3)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 20948
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
	int x;
	
	cin >> x;
	
		int	h = x / 3600;
		int m = (x - (h * 3600)) / 60;
		int s = (x - (h * 3600) - (m * 60));
	
	cout << h << ":" << m << ":" << s<< endl; 
	
	
	
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    A += 'z'; B += 'z'; C += 'z';
    int turn = 0;
    int a = 0, b = 0, c = 0;
    while(1){
        if(turn == 0){
            if(A[a] == 'z'){
                printf("A\n");
                return 0;
            }else if(A[a] == 'a'){
                turn = 0;
            }else if(A[a] == 'b'){
                turn = 1;
            }else if(A[a] == 'c'){
                turn = 2;
            }
            a++;
        }else if(turn == 1){
            if(B[b] == 'z'){
                printf("B\n");
                return 0;
            }else if(B[b] == 'a'){
                turn = 0;
            }else if(B[b] == 'b'){
                turn = 1;
            }else if(B[b] == 'c'){
                turn = 2;
            }
            b++;
        }else if(turn == 2){
            if(C[c] == 'z'){
                printf("C\n");
                return 0;
            }else if(C[c] == 'a'){
                turn = 0;
            }else if(C[c] == 'b'){
                turn = 1;
            }else if(C[c] == 'c'){
                turn = 2;
            }
            c++;
        }
    }
}

Measured memory_bytes: 256
import math
while True:
	n = int(input())
	if n == 0:
		break
	Student=list(map(float,input().split()))
	#print(n)
	#print(Student)
	#m=average
	average=sum(Student)/n
	#print(m)
	#a^2=dispersion
	s=0.0
	for i in Student:
		s+=(i-average)**2
	dispersion=s/n
	print("%.6f"%(math.sqrt(dispersion)))

Measured memory_bytes: 7684
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    ll N, X, M;
    cin >> N >> X >> M;
    if(N == 1){
        cout << X << endl;
        return 0;
    }
    vector<ll> f;
    set<ll> al;
    f.push_back(X); al.insert(X);
    bool is_zero = false;
    ll last = 0;
    while(true){
        ll nxt = (f[f.size()-1] * f[f.size()-1]) % M;
        if(nxt == 0)is_zero = true;
        if(al.count(nxt) == 1){last = nxt; break;}
        f.push_back(nxt); al.insert(nxt);
    }
    if(is_zero){
        ll ans = 0;
        for(ll i = 0; i < min(N, (ll)f.size()); ++i)ans += f[i];
        cout << ans << endl;
        return 0;
    }
    ll ans = 0;
    bool out_head = false;
    ll loop_len = 0;
    ll loop_sum = 0;
    ll rest = N;
    vector<ll> loop;
    for(int i = 0; i < min(N, (ll)f.size()); ++i){
        if(f[i] == last)out_head = true;
        if(!out_head){
            ans += f[i];
            --rest;
        }else{
            ++loop_len;
            loop_sum += f[i];            
            loop.push_back(f[i]);
        }
    }
    ans += rest / loop_len * loop_sum;
    rest %= loop_len;
    rep(i,rest)ans += loop[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<bool> VB;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int a, b, t;
  std::cin >> a >> b >> t;
  
  int n = 0;
  while (2 * n * a <= 2 * t + 1) {
    n++;
  }
  cout((n-1) * b);
}

Measured memory_bytes: 384
#include<stdio.h>

int gcd(int m, int n){
  if(m == n){
    return m;
  }else if(m > n){
    return gcd(m-n,n);
  }else{
    return gcd(m,n-m);
  }
}

int main(){
  int x,y;
  scanf("%d %d", &x, &y);

  printf("%d\n",gcd(x,y));

}



Measured memory_bytes: 2100
def main():
    N, H = list(map(int, input().split(' ')))
    swords = [list(map(int, input().split(' '))) for _ in range(N)]
    swords.sort(key=lambda s: s[0], reverse=True)
    max_a = swords[0][0]
    throwable_swords = list(filter(lambda s: s[1] > max_a, swords))
    # if len(swords) = 0, then use only the sword with max_a.
    sum_b = sum(list(map(lambda s: s[1], throwable_swords)))
    if H <= sum_b:
        # throw all swords
        throwable_swords.sort(key=lambda s: s[1], reverse=True)
        ans = 0
        for s in throwable_swords:
            ans += 1
            H -= s[1]
            if H <= 0:
                break
        print(ans)
    else:
        # attack with the max_a sword and throw swords
        ans = len(throwable_swords)
        H -= sum_b
        ans += (H + max_a - 1) // max_a
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int cnt = b / a;
        System.out.println(cnt >= c ? c : cnt);
    }
}


Measured memory_bytes: 23124
//Flipping Signs

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    sort(range(a));
    int fu = 0;
    rep(i,0,n)if(a[i]<0)fu++;
    vector<int>t(n);
    rep(i,0,n)t[i]=abs(a[i]);
    sort(range(t));
    int ans = 0;
    rep(i,(fu%2),n)ans+=t[i];
    if(fu%2)ans-=t[0];
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 4840
// glory be to the sky
#include<cstdio>
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 

vector<int> adj[26];

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	string ipt;
	cin >> ipt;

	set<char> sit;
	for (int i = 0; i < ipt.length(); i++) {
		if (i + 2 > ipt.length()) break;
		if (ipt[i] == ipt[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		if (i + 3 > ipt.length()) break;
		sit.clear();
		sit.insert(ipt[i]); sit.insert(ipt[i + 1]); sit.insert(ipt[i + 2]);
		if (sit.size() <= 2) {
			// cout << "SIZE "  << sit.size() << endl;
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << "-1 -1\n";
	return 0;	
}

Measured memory_bytes: 512
#include<stdio.h>
void swap(int *a , int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}
int main() {
	int a , b , c;
	int tmp;
	scanf("%d %d %d" , &a , &b , &c);
	if (a > b) {
		swap(&a , &b);
	}
	if (a > c) {
		swap(&a , &c);
	}
	if (b > c) {
		swap(&b , &c);
	}
	printf("%d %d %d\n" , a , b , c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int c[33]; string s;
int main() {
	cin >> s;
	for(int i = 0; i < s.size(); i++) c[s[i] - 97]++;
	for(int i = 0; i < 26; i++) {
		if(c[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    int n = 100;
    int h = 0;
    while(h != k){
        if (a % n == 0 && b % n == 0) {
            h ++;


        }
        n --;
    }
    cout << n + 1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(s[i]==t[j])dp[i][j]=dp[i+1][j+1]+1;
            dp[i][j]=max(dp[i][j],dp[i+1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j+1]);
        }
    }
    string ans="";
    ll index=dp[0][0];
    for(int i=0;i<index;i++){
        ans+="0";
    }
    int i=0,j=0;
    while(i<n&&j<m){
        if(s[i]==t[j]){
            ans[index-1]=s[i];
            i++;j++;index--;
        }else if(dp[i+1][j]>dp[i][j+1]){
            i++;
        }else j++;
    }
    reverse(be(ans));
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){


  int n;
  cin>>n;
  
  vi a(n+1);
  
  for (int i=1;i<=n;i++){
    int tmp;
    cin>>tmp;
    a.at(tmp)=i;
  }
  
  for (int i=1;i<=n;i++){
    cout<<a.at(i)<<" ";
  }
  
  cout<<endl;
  
   
  
  


  
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[10];
    cin>>s;
    int a,b,c,d;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    for(int i=43;i<=45;i+=2){
        for(int j=43;j<=45;j+=2){
            for(int k=43;k<=45;k+=2){
                int ans=a;
                if(i==43){
                    ans+=b;
                }
                else{
                    ans-=b;
                }
                if(j==43){
                    ans+=c;
                }
                else{
                    ans-=c;
                }
                if(k==43){
                    ans+=d;
                }
                else{
                    ans-=d;
                }
                if(ans==7){
                    cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;//只要输出一种
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
//template
import java.util.*;
import java.util.stream.Stream;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) throws IOException{
		
		int[] vec=readInts();
		if(vec[0]<9&&vec[1]<9)
			out.append("Yay!");
		else
			out.append(":(");
		
		out.flush();
		in.close();
		out.close();
	}
	
	public static boolean palindrome(String s) {
		boolean palindrome=true;
		int i=0,j=s.length()-1;
		while(i<j&&palindrome) {
			if(s.charAt(i++)!=s.charAt(j--))
				palindrome=false;
		}
		return palindrome;
	}
	public static long reverse(String s) {
		String aux="";
		for(int i=s.length()-1;i>=0;i--) {
			aux+=s.charAt(i);
		}
		return Long.parseLong(aux);
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}
class Pair{
	int first;
	int second;
	public Pair(int first,int second) {
		this.first=first;
		this.second=second;
	}
	public Pair() {
		
	}
}

Measured memory_bytes: 34476
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int a=nxt(),b=nxt();
    string u;
    cin>>u;
    if(u==s)
        a--;
    else
        b--;
    cout<<a<<" "<<b<<endl;
  

    return 0;   
}


 
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

int main(){
    
    size_t h, w;
    std::cin >> h >> w;

    std::vector<std::string> a(h);

    for(auto&& e : a){
        std::string in;
        std::cin >> in;
        in = '#' + in + '#';
        e = in;
    }

    a.emplace(a.begin(), std::string(a.at(0).size(), '#'));
    a.emplace_back(std::string(a.at(0).size(), '#'));

    for(const auto& e : a){
        std::cout << e << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private const int MaxLength = 19;
    private int L;

    private bool Q(long n)
    {
        return Q(n.ToString());
    }

    private bool Q(string s)
    {
        Console.WriteLine("? {0}", s);
        return Console.ReadLine() == "Y";
    }

    public void Solve()
    {
        long p = 1;
        bool flag = true;
        for (int i = 1; i <= MaxLength; i++)
        {
            if (Q(p))
            {
                L = i;
            }
            else
            {
                flag = false;
                break;
            }
            p *= 10;
        }

        if (flag) //N = 10^k
        {
            long q = 2;
            for (int i = 1; i <= MaxLength; i++)
            {
                if (Q(q))
                {
                    Console.WriteLine("! {0}", q / 2);
                    return;
                }
                q *= 10;
            }
        }
        else
        {
            long max = p - 1;
            long min = p / 10;
            while (max - min > 1)
            {
                long mid = (max + min) / 2;
                if (Q(mid * 10))
                {
                    max = mid;
                }
                else
                {
                    min = mid;
                }
            }
            Console.WriteLine("! {0}", max);
            return;
        }
    }
}


Measured memory_bytes: 13476
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
x = a1 + a2 + a3

n=int(input())
ans='No'

for i in range(n):
  ent=int(input())
  x=['x' if i==ent else i for i in x]

if x[0]==x[3]==x[6]=='x':ans='Yes'
elif x[1]==x[4]==x[7]=='x':ans='Yes'
elif x[2]==x[5]==x[8]=='x':ans='Yes'
elif x[0]==x[1]==x[2]=='x':ans='Yes'
elif x[3]==x[4]==x[5]=='x':ans='Yes'
elif x[6]==x[7]==x[8]=='x':ans='Yes'
elif x[0]==x[4]==x[8]=='x':ans='Yes'
elif x[2]==x[4]==x[6]=='x':ans='Yes'

print(ans)

Measured memory_bytes: 9272
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

int main(void) {
    cin >> n;
    unordered_map<string, ll> mp;
    ll max = 0;
    rep (i, 0, n) {
        string ss;
        cin >> ss;
        mp[ss] += 1;
        if (mp[ss] > max) {
            max = mp[ss];
        }
    }

    vector<string> s;
    
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second == max) s.emplace_back(itr->first);
    }

    sort(s.begin(), s.end());
    printa(s, s.size());


    return 0;
}



Measured memory_bytes: 26692
import bisect
n = int(input())
S = tuple(map(int, input().split()))
q = int(input())
T = tuple(map(int, input().split()))
cnt = 0
for n in T:
    m = bisect.bisect_right(S, n)
    if m > 0 and S[m-1] == n:
        cnt += 1
print(cnt)

Measured memory_bytes: 18868
// https://atcoder.jp/contests/abc168/tasks/abc168_b
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

const int K_MAX = 100;

int K;
string S;

void solve() {
  string ans = K >= S.size() ? S : S.erase(K) + "...";
  cout << ans << endl;
}

void input() {
  scanf("%d", &K);
  cin >> S;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)){
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^63.
// NOTE: This function does not handle error cases.
fun fastReadLongs(n: Int): LongArray {
  val xs = LongArray(n)
  val s = readLine()!!
  var currentValue = 0L
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
  return xs
}

fun main(args: Array<String>) {
  val (nLong, circleLength) = fastReadLongs(2)
  val n = nLong.toInt()
  val xs = LongArray(n)
  val values = LongArray(n)
  repeat(n) {
    val (x, value) = fastReadLongs(2)
    xs[it] = x
    values[it] = value
  }

  val gains1 = LongArray(n)
  val maxes1 = LongArray(n)
  gains1[0] = values[0] - xs[0]
  maxes1[0] = Math.max(0, gains1[0])
  for (i in 1 until n) {
    gains1[i] = gains1[i - 1] + values[i] - (xs[i] - xs[i - 1])
    maxes1[i] = Math.max(maxes1[i - 1], gains1[i])
  }

  val gains2 = LongArray(n)
  val maxes2 = LongArray(n)
  gains2[n - 1] = values[n - 1] - (circleLength - xs[n - 1])
  maxes2[n - 1] = Math.max(0, gains2[n - 1])
  for (i in n - 2 downTo 0) {
    gains2[i] = gains2[i + 1] + values[i] - (xs[i + 1] - xs[i])
    maxes2[i] = Math.max(maxes2[i + 1], gains2[i])
  }

  var ans = Math.max(maxes1.max()!!, maxes2.max()!!)
  for (i in 0 until n - 1) {
    val candidate = gains1[i] - xs[i] + maxes2[i + 1]
    ans = Math.max(ans, candidate)
  }
  for (i in n - 1 downTo 1) {
    val candidate = gains2[i] - (circleLength - xs[i]) + maxes1[i - 1]
    ans = Math.max(ans, candidate)
  }
  println(ans)
}


Measured memory_bytes: 44188
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long x, k, d;
	cin >> x >> k >> d;

	long massugu = x / d;
	if (massugu < 0) {	massugu = -massugu;	}
	if (massugu >= k) {
		long ans;
		if (x < 0) {
			ans = x + k * d;
		}
		else {
			ans = x - k * d;
		}
		if (ans < 0) { ans = -ans; }
		cout << ans << endl;
		return 0;
	}
	
	long massugu2, massugu3;
	if (x < 0) {
		massugu2 = x + massugu * d;
		massugu3 = massugu2 + d;
		massugu2 = -massugu2;
	}
	else {
		massugu2 = x - massugu * d;
		massugu3 = massugu2 - d;
		massugu3 = -massugu3;
	}
	long nokori = k - massugu;
	if (nokori % 2 == 0) {
		cout << massugu2 << endl;
	}
	else {
		cout << massugu3 << endl;
	}
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader
import java.util.*
import kotlin.math.max
import kotlin.math.min

fun main() = abc119d()

@OptIn(ExperimentalStdlibApi::class)
fun abc119d() = SimpleFastIOWithToken_abc119d().exec {
    val infinity = Long.MAX_VALUE / 100
    fun List<Long>.addPosNegInfinity() = buildList {
        add(-infinity); addAll(this@addPosNegInfinity); add(infinity)
    }.toLongArray()

    val (a, b, q) = List(3) { readInt() }
    val shrines = List(a) { readLong() }.addPosNegInfinity()
    val temples = List(b) { readLong() }.addPosNegInfinity()

    fun LongArray.lowerBound(key: Long): Int {
        var ng = -1
        var ok = size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (this[mid] >= key) ok = mid else ng = mid
        }
        return ok
    }

    fun minOf(a: Long, b: Long, c: Long, d: Long) = min(min(a, b), min(c, d))

    repeat(q) {
        val x = readLong()
        val rightShrineIndex = shrines.lowerBound(x)
        val rightTempleIndex = temples.lowerBound(x)

        val leftShrine = shrines[rightShrineIndex - 1]
        val rightShrine = shrines[rightShrineIndex]
        val leftTemple = temples[rightTempleIndex - 1]
        val rightTemple = temples[rightTempleIndex]

        val answer = minOf(
            // left shrine, left temple
            x - min(leftShrine, leftTemple),
            // left shrine, right temple
            rightTemple - leftShrine + min(rightTemple - x, x - leftShrine),
            // right shrine, left temple
            rightShrine - leftTemple + min(rightShrine - x, x - leftTemple),
            // right shrine, right temple
            max(rightShrine, rightTemple) - x
        )

        println(answer)
    }
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc119d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc119d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 66760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

class Amida{
public:
	int h,p,q;
	bool operator<(const Amida &amida)const{return h>amida.h;}
};

vector<Amida> amida;

int main() {
	int n,m,a;
	while(cin>>n>>m>>a,n+m+a>0){
		amida.clear();
		int i;
		Amida ami;
		for(i=0;i<m;i++){
			cin>>ami.h>>ami.p>>ami.q;
			amida.push_back(ami);
		}
		sort(amida.begin(),amida.end());
		for(i=0;i<m;i++){
			if(amida[i].p==a)a=amida[i].q;
			else if(amida[i].q==a)a=amida[i].p;
//cout<<a<<" "<<amida[i].p<<" "<<amida[i].q<<endl;
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 0