akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int MAX_TWO_POWER = 60;

vector<vector<int>> to;

// solution by doubling
int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    to.resize(MAX_TWO_POWER + 1, vector<int>(N, 0));
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        t--;
        to[1][i] = t;
    }

    for (int i = 2; i <= MAX_TWO_POWER; i++) {
        for (int j = 0; j < N; j++) {
            to[i][j] = to[i - 1][to[i - 1][j]];
        }
    }

    int cur = 0;
    for (int i = 0; i < MAX_TWO_POWER; i++) {
        int bit = (K >> i) & 1;
        if (bit) {
            cur = to[i + 1][cur];
        }
    }

    cout << cur + 1 << endl;

    return 0;
}


Measured memory_bytes: 51836
N = int(input())
shou = []
for f in range(N):
    x = int(input())
    for i in range(x):
        a, b = map(int, input().split())
        shou.append([f, a - 1, b])
max_count = 0
for i in range(1, 2 ** N):
    flag = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for z, x, y in shou:
            if (i >> x) & 1 != y and z == j:
                flag = False
                break
        if not flag:
            break
    if flag == 1:
        max_count = max(bin(i)[2:].count('1'), max_count)
print(max_count)


Measured memory_bytes: 3064
# a + 2b = X
# 2a + b = Y
# 3b = 2X-Y
# b = (2X-Y)/3 ①
# 6a + (2X-Y) = 3Y
# 6a = 4Y-2X
# a = (2Y-X)/3 ②

# X=3,Y=3 の時
# b = 1, a = 1


def nCr(n, r, mod):
    if n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    x = y = 1
    for i in range(r):
        x = (x * (n - i)) % mod
        y = (y * (i + 1)) % mod

    return (x * pow(y, mod - 2, mod)) % mod


X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)
    exit(0)

a = (2 * X - Y) // 3
b = (2 * Y - X) // 3
if a < 0 or b < 0:
    print(0)
else:
    print(nCr(a + b, a, 10**9 + 7))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    string s;

    cin >> n >> s;

    if (n%2) cout << "No";
    else {

        string a = s.substr(0, n/2);
        string b = s.substr(n/2, n);

        if (a == b) cout << "Yes";
        else cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

ll x;

void input() {
  cin >> x;
}

void solve() {
  ll cur = 100;
  int ans = 0;

  while (cur < x) {
    cur += cur / 100;

    ++ans;
  }
  
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3620
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 2050;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, cost, a[N], mn[N][N];

void solve() { 
  cin >> n >> cost;
  for (int i = 1;i <= n;i++) {
    cin >> a[i];
  }
  for (int i = 1;i <= n;i++) {
    int now = inf;
    for (int j = i;j <= n;j++) {
      now = min(now, a[j]);
      mn[i][j] = now;
    }
  }
  ll ans = 1e18;
  for (int l = 0;l <= n;l++) {
    ll cur = 1ll * l * cost;
    for (int i = 1;i <= n;i++) {
      int j = i - l;
      if (j < 1) {
        cur += min(mn[1][i], mn[n + j][n]);
      } else {
        cur += mn[j][i];
      }
    }
    ans = min(ans, cur);
  }   
  cout << ans << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
  // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> A(N),DP(N);
  for(int i=0;i<N;i++)cin>>A[i];
  DP[0]=0;
  DP[1]=abs(A[0]-A[1]);
  for(int i=2;i<N;i++) {
    DP[i]=min(abs(A[i-1]-A[i])+DP[i-1],abs(A[i-2]-A[i])+DP[i-2]);
  }
  cout<<DP[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	char[] c;
	int id;

	String cip() {
		String res = str();
		while (id < c.length && c[id] != ']') {
			res += str();
		}
		return res;
	}

	String str() {
		String res = "";
		if (c[id] == '[') {
			id++;
			StringBuilder tmp = new StringBuilder(cip());
			res += tmp.reverse();
			id++;
		} else {
			res += let();
		}
		return res;
	}

	char let() {
		if (c[id] == '+') {
			id++;
			char res = let();
			if (res == '?') return res;
			res += 1;
			if ('Z' < res)
				res = 'A';
			return res;
		}
		if (c[id] == '-') {
			id++;
			char res = let();
			if (res == '?') return res;
			res -= 1;
			if (res < 'A')
				res = 'Z';
			return res;
		}
		if (c[id] == '?') {
			id++;
			return '?';
		}
		return c[id++];
	}

	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			c = sc.next().toCharArray();
			if (c[0] == '.') {
				break;
			}
			id = 0;
			char[] ans = cip().toCharArray();
			int n = ans.length;
			for (int i = 0; i < n; i++) {
				if (ans[i] == '?') {
					System.out.print("A");
				} else {
					System.out.print(ans[i]);
				}
			}
			System.out.println();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
int n;
int ans = 0;

const string sgs = "357";

bool check(string s) {
  if(s == "") return false;
  bool f3 = false;
  bool f5 = false;
  bool f7 = false;
  REP(i,s.length()) {
    if(f3 && f5 && f7) break;
    if(s[i] == '3') f3 = true;
    if(s[i] == '5') f5 = true;
    if(s[i] == '7') f7 = true;
  }
  return f3 && f5 && f7;
}

int dfs(string s) {
  if(s.length() > 9) return 0;
  if(!s.empty() && stoi(s) > n) return 0;
  int ans = 0;
  if(check(s)) ++ans;
  ans += dfs(s+'3');
  ans += dfs(s+'5');
  ans += dfs(s+'7');
  return ans;
}
/***** MAIN *****/
signed main() {
  cin >> n;
  cout << dfs("");
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int main() {
	ll N;
	cin >> N;
	ll A[MAX];
	repn(i, N) cin >> A[i];
	sort(A + 1, A + N + 1);

	cout << A[N] - A[1];
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b,c,d,e,f,g;
long long ans;
int main()
{
	scanf("%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g);
	ans=a/2*4ll+b*2ll+d/2*4ll+e/2*4ll;
	if(a%2&&d%2&&e%2)
		ans+=6;
	else if(a%2+d%2+e%2==2)
	{
		if(a&&d&&e)
			ans+=2;
	}
	printf("%lld",ans/2);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

int field[10][10];
int H, W, C;


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

int count_field() {
  int c = field[1][1];
  bool visit[10][10];
  fill(&visit[0][0], &visit[9][10], false);
  visit[1][1] = true;
  int cnt = 1;
  queue<P> Q;
  Q.push(P(1, 1));
  while (!Q.empty()) {
    P cur = Q.front();
    int x = cur.first;
    int y = cur.second;
    Q.pop();
    
    for (int i = 0; i < 4; i++) {
      int tx = x + dx[i];
      int ty = y + dy[i];
      // printf("%d, %d = %d\n",tx, ty,  field[ty][tx]);
      if (field[ty][tx] > 0 && !visit[ty][tx] && field[ty][tx] == C) {
        visit[ty][tx] = true;
        cnt++;
        Q.push(P(tx, ty));
      }
    }
  }
  return cnt;
}

int fill_color(int color, vector<P>& filled) {
  queue<P> Q;
  Q.push(P(1, 1));
  bool visit[10][10];
  fill(&visit[0][0], &visit[9][10], false);
  visit[1][1] = true;
  int bc = field[1][1];
  field[1][1] = color;
  filled.push_back(P(1,1));
  while (!Q.empty()) {
    P cur = Q.front();
    int x = cur.first;
    int y = cur.second;
    Q.pop();

    for (int i = 0; i < 4; i++) {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if (field[ty][tx] > 0 && !visit[ty][tx] && field[ty][tx] == bc) {
        visit[ty][tx] = true;
        field[ty][tx] = color;
        Q.push(P(tx, ty));
        filled.push_back(P(tx, ty));
      }
    }
  }
}

void reverse_color(int c, vector<P> & filled) {
  for (int i = 0; i < filled.size(); i++) {
    int x = filled[i].first;
    int y = filled[i].second;
    field[y][x] = c;
  }
}

void print_field() {
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      printf("%d ", field[i][j]);
    }
    printf("\n");
  }
  printf("\n");
}

int _solve(int depth) {
  // print_field();
  /*
  if (depth == 4) {
    int c = field[1][1];
    filled.clear();
    fill_color(C);
    int res = count_field();
    reverse_color(c);
    return res;
  }
  */
  if (depth == 5) {
    return count_field();
  }
  int c = field[1][1];
  int mx = 0;
  for (int i = 1; i <= 6; i++) {
    if (c != i) {
      vector<P> prev;
      fill_color(i, prev);
      mx = max(_solve(depth + 1), mx);
      reverse_color(c, prev);
    }
  }
  return mx;
}

void solve() {
  printf("%d\n", _solve(0));
}

void init() {
  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      field[i][j] = 0;
    }
  }
}

int main() {
  while (true) {
    scanf("%d %d %d ", &H, &W, &C);
    init();
    if (H == 0 && W == 0 && C == 0) {
      return 0;
    }
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        scanf("%d ", &field[i][j]);
      }
    }
    solve();
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a, x[50];
LL dp[51][10000];

int main() {
	cin >> n >> a;
	inc(i, n) { cin >> x[i]; }
	
	dp[0][0] = 1;
	inc(i, n) {
	dec(j, n) {
	dec(k, 10000) {
		if(dp[j][k]) { dp[j + 1][k + x[i]] += dp[j][k]; }
	}
	}
	}
	
	LL ans = 0;
	incII(i, 1, n) { ans += dp[i][a * i]; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 3116
N,M,C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
A = readlines.map {|a| a.split.map(&:to_i) }

puts A.count {|a|
  M.times.inject(0) {|r,i| r + a[i]*B[i] } + C > 0
}


Measured memory_bytes: 3836
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    n=int(input())
    println(n%2<1 ? n : 2n)
end
main()

Measured memory_bytes: 113604
#include<iostream>
using namespace std;
int main()
{
	string a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	bool d = 0;
	char e = 'a';
	char w;
	int i = 0;
	while(d == 0){
		switch (e){
			case 'a':
			if(a.empty() == true){
				d = 1;
				w = 'A';
			} else {
				e = a[0];
				a.erase(a.begin()+i);
			}
			break;
			
			case 'b':
			if(b.empty() == true){
				d = 1;
				w = 'B';
			} else {
				e = b[0];
				b.erase(b.begin()+i);
			}
			break;
			
			case 'c':
			if(c.empty() == true){
				d = 1;
				w = 'C';
			} else {
				e = c[0];
				c.erase(c.begin()+i);
			}
			break;
		}
	}
	cout << w;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(input())

count = x.count('1')
one_count = count - 1
zero_count = count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_count:
        one_mod = (one_mod * 2 + int(b)) % one_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_count

f = [0] * 2000001
pop_count = [0] * 200001
for i in range(1, 200001):
    pop_count[i] = pop_count[i//2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

for i in range(n):
    if x[i] == '1':
        if one_count:
            nxt = one_mod
            nxt -= pow(2, n-i-1, one_count)
            nxt %= one_count
            print(f[nxt] + 1)
        else:
            print(0)
    if x[i] == '0':
        nxt = zero_mod
        nxt += pow(2, n-i-1, zero_count)
        nxt %= zero_count
        print(f[nxt] + 1)


Measured memory_bytes: 28092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vvi dp(3001, vi(3001, 0));

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll ns = SZ(s);
    ll nt = SZ(t);
    rep(i, ns){
        rep(j, nt){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    //rep(i, ns+1)dump(dp[i]);
    string ans = "";
    ll i = ns;
    ll j = nt;
    while(i >= 0 && j >= 0){
        if(s[i] == t[j]){
            ans += string({s[i]});
            //dump(i, j);
            i--; j--;
        }else{
            if(i == 0){j--; continue;}
            if(j == 0){i--; continue;}
            if(dp[i][j+1] > dp[i+1][j]){
                i--;
            }else{
                j--;
            }
        }
    }
    reverse(ALL(ans));
    ans.erase(ans.end()-1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int n;
string s;

bool is(int l, int t) {
	for (int i = 0; i < t; ++i)
		for (int j = i + 1; j < t; ++j)
			if (s[l + i] == s[l + j])
				return true;
	return false;
}
	

void read() {
	cin >> s;
	n = s.length();
}

void kill() {
	for (int i = 0; i < n; ++i)
		for (int len = 2; len <= 3 && i + len <= n; ++len)
			if (is(i, len)) {
				cout << i + 1 << " " << i + len << endl;
				return;
			}
	cout << "-1 -1\n";
}

int main() {
	read();
	kill();	
	return 0;
}


Measured memory_bytes: 512
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int r;
  cin >> r;
  printf("%d\n",r*r );
  return 0;
}


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

using namespace std;
 
int main(){
    
    string s1, s2;
    cin >> s1 >> s2;
    int a, b;
    cin >> a >> b;
    string s3;
    cin >> s3;
    if(s1 == s3){
        a--;
    }else if(s2 == s3){
        b--;
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

int n;
vi p;
vi idx;
multiset<int> s;

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	p.resize(n);
	rep(i,0,n) {
		cin >> p[i];
	}
	idx.resize(n+1);
	rep(i,0,n) {
		idx[p[i]] = i;
	}

	ll total = 0;
	s.insert(n);
	s.insert(n);
	s.insert(-1);
	s.insert(-1);
	s.insert(idx[n]);
	per(i,1,n) {
		s.insert(idx[i]);
		auto it = s.find(idx[i]);
		int left = *(--it);
		int lleft = *(--it);
		++it;
		++it;
		int right = *(++it);
		int rright = *(++it);
		//cout << i << " : " << lleft << ' ' << left << ' ' << idx[i] << ' ' << right << ' ' << rright << endl;
		total += (long long)(left - lleft) * (right - idx[i]) * i;
		total += (long long)(idx[i] - left) * (rright - right) * i;
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 5760
use std::io;

fn main() {
    let n = read_one::<String>();

    if n == "1" {
        println!("Hello World");
    } else {
        let a = read_one::<usize>();
        let b = read_one::<usize>();
        println!("{}", a + b);
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 4352
N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 10**9 + 7

sum = 0
A.each do |a|
    sum = (sum + a) % MOD
end

result = 0
A.each do |a|
    sum -= a
    if sum < 0
        sum = sum + MOD
    end
    result += a * sum
    result = result % MOD
end

puts result

Measured memory_bytes: 28204
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  set<pair<int, int>> s;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    s.insert({b[i], i});
  }

  long long result = 0;
  for (;;) {
    if (s.empty()) break;

    int i = prev(s.end())->second;
    s.erase(prev(s.end()));

    int i1 = (i + 1) % n;
    int i2 = (i + n - 1) % n;

    int sum = b[i1] + b[i2];

    if (b[i] < a[i]) {
      cout << -1 << endl;
      return 0;
    }

    if (b[i] == a[i]) {
      continue;
    }
    if (b[i] <= sum) {
      cout << -1 << endl;
      return 0;
    }
    int t = (b[i] - a[i]) / sum;
    if (t == 0) {
      cout << -1 << endl;
      return 0;
    }
    result += t;
    b[i] -= t * sum;
    s.insert({b[i], i});
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    for (int i = 1; i <= 9; i++) {
        if (N%i == 0 && 1 <= N/i && N/i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<bool> seen(N); //既に行ったところを覚えておく
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i]--; //添え字が0から始まるのでそれに合わせる
    }
    int beforeLoop = 0; //ループが始まるまでの長さ
    int now = 0; //最初
    while(!seen[now])
    {
        seen[now] = true;
        now = A[now];
        beforeLoop++;
    } 
    int loopStart = now; //ループが始まる場所
    int loopLength = 0; //ループの長さ(周期)
    do
    {
        seen[now] = true;
        now = A[now];
        loopLength++;
    } while (now != loopStart);
    if(K<beforeLoop) //ループが始まるまでに操作が終わるとき
    {
        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            ans = A[ans];
        }
        cout<<ans+1;
        return 0;
    }
    K -= beforeLoop;
    K %= loopLength;
    int pos = loopStart;
    for (int i = 0; i < K; i++)
    {
        pos = A[pos];
    }
    cout << pos + 1;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B,C;
	cin>>A>>B>>C;
	if (A+B+1>=C){
		cout<<C+B<<endl;
	}else{
		cout<<B+C-(C-A-B-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll h, a; cin >> h >> a;
    ll ans = 0;
    while (h > 0)
    {
        h = h - a;
        ans = ans + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
//const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll N, M;
ll H[100010];
ll A, B;
bool ans[100010];
ll res;

void solve() {
	cin >> N >> M;
	for (ll i = 1; i <= N; i++) cin >> H[i];
	rep(i, M) {
		cin >> A >> B;
		if (H[A] <= H[B]) ans[A] = true;
		if (H[B] <= H[A]) ans[B] = true;
	}
	for (ll i = 1; i <= N; i++) {
		if (!ans[i]) res++;
	}
	cout << res << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  int cnt[26] = {0};
  string s; 
  while(getline(cin, s))
  {
    if(s=="") break;
    rep(i,s.size())
    {
      if(isalpha(s[i])&&isupper(s[i])) cnt[s[i]-'A']++;
      if(isalpha(s[i])&&islower(s[i])) cnt[s[i]-'a']++;
    }
  }
  rep(i,26)
  {
    cout << (unsigned char)(i+'a') << " : " << cnt[i] << "\n";
  }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const int inf = 0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans;
}
ll mul(ll a,ll b){//大数取模乘法防止溢出
    ll ans=0;
    a%=mod,b%=mod;
    while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }
    return ans;
}
//(b/a)%p=b*a^(p-2)%p
int pr(ll num){//判断素数
     if(num == 1) return 0;
     if(num ==2|| num==3 ) return 1 ;
     if(num %6!= 1&&num %6!= 5) return 0 ;
     int tmp =sqrt( num);
     for(int i= 5;i <=tmp; i+=6 )
          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
     return 1 ;
}
int Day(int y,int m, int d){
    if(m==1||m==2) { m+=12; y--; }
    int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
    return w+1;
}
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}

//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec

//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址

const int maxn=1e5+5;
int main(){
    int k;
    int a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;++i){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int mod = 1e9 + 7;
const long double PI = 3.141592653589793;

void solve(){
  int n;
  cin >> n;
  set<int> hon({2, 4, 5, 7, 9});
  set<int> pon({0, 1, 6, 8});
  if(hon.count(n%10)){
    cout << "hon" <<endl;
  }
  else if(pon.count(n%10)){
    cout << "pon" <<endl;
  }
  else{
    cout << "bon" <<endl;
  }
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3608
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
nm = [int(s) for s in stdin.readline().rstrip().split()]
n = nm[0]
m = nm[1]
ab = []
for el in range(m):
    tmp = [int(s) for s in stdin.readline().rstrip().split()]
    ab.append(tmp)

data = []
for el in range(n):
    if el == 0:
        data.append({'index': el + 1, 'diff': 0, 'connection': [], 'num': 0})
    else:
        data.append({'index': el + 1, 'diff': 0, 'connection': []})
for el in ab:
    data[el[0]-1]['connection'].append(el[1])
    data[el[1]-1]['connection'].append(el[0])
poss = [1]
count = 1

for elt in range(n):
    tmp = []
    for el in poss:
        for el2 in data[el - 1]['connection']:
            if not 'num' in data[el2-1]:
                tmp.append(el2)
                data[el2-1]['num'] = el
    else:
        poss = tmp
        count += 1

check = True
for el in data:
    if not 'num' in el:
        check = False
if check:
    print('Yes')
    tmp = 0
    for el in data:
        if tmp != 0:
            print(el['num'])
        tmp += 1
if not check:
    print('No')


Measured memory_bytes: 163892
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/12 7:58 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if(n == 1){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll n, m; cin >> n >> m;
  if(abs(n - m) > 1){
    cout << 0 << endl;
    return 0;
  }
  if(n - m == 0){
    ll ans = 1;
    for (ll i = 1; i <= n; i++){
      ans *= i;
      ans %= MOD;
    }
    for (ll i = 1; i <= n; i++){
      ans *= i;
      ans %= MOD;
    }
    ans *= 2;
    ans %= MOD;
    cout << ans << endl;
  }else{
    ll ans = 1;
    for (ll i = 1; i <= n; i++){
      ans *= i;
      ans %= MOD;
    }
    for (ll i = 1; i <= m; i++){
      ans *= i;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}

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

bool flag_p[300000 + 100];


int main(){

    vector<int> pf;

    for(int i=0; i<300000/7 + 100; i++){
        pf.push_back(7*i + 1);
        pf.push_back(7*i + 6);
    }

    for(int i=0; i<300000 + 100; i++){
        flag_p[i] = true;
    }

    for(int i=1; i<pf.size(); i++){
        int kt = pf[i];
        if(flag_p[kt]){
            for(int j=2; j*kt<300000 + 100; j++){
                flag_p[j*kt] = false;
            }
        }
    }

    while(true){
        int n;

        cin >> n;

        if(n==1){
            break;
        }

        cout << n << ":";

        for(int i=1; i<pf.size(); i++){
            if(n%pf[i] == 0 && flag_p[pf[i]]){
                cout << " " << pf[i];
            }
        }
        cout << endl;

    }

}


Measured memory_bytes: 3468
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, card[2][10000];
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", card[0] + i, card[1] + i);
		int A, B;
		A = B = 0;
		for (int i = 0; i < n; ++i)
		{
			if (card[0][i] > card[1][i])
				A += card[0][i] + card[1][i];
			else if (card[0][i] < card[1][i])
				B += card[0][i] + card[1][i];
			else
			{
				A += card[0][i];
				B += card[1][i];
			}
		}
		printf("%d %d\n", A, B);
	}

	return 0;
}

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

int main() {
string S; cin>>S;
  int K=0;
  if(S.at(0)=='A')
    K++;
  int G=0;// Cのかず
  for(int i=2; i<S.size()-1; i++){
    if(S.at(i)=='C')
      G++;
  }
  if(G==1&&S.at(0)!='C'&&S.at(1)!='C'&&S.at(S.size()-1)!='C') K++;
  int QA=0;
  for(int i=0; i<S.size();i++){
if(isupper(S.at(i))&&S.at(i)!='A'&&S.at(i)!='C'){
  QA++;
}
    else continue;
}
  
  if(QA==0)
    K++;
  if(K==3)
    cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}



Measured memory_bytes: 2092
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
  char s[101];
  scanf("%s",s);
  int l = strlen(s);
  bool flag = false;
  for(int i=0;i<l;i++){
    if(!flag&&s[i]=='C') flag = true;
    else if(flag&&s[i]=='F'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int sum = 0;
    if (A > B)
    {
        sum += 2 * A - 1;
    }
    else if (A == B)
    {
        sum += 2 * A;
    }
    else
    {
        sum += 2 * B - 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	x := 0
	ans := make([]string, n)
	for _, ai := range a {
		x ^= ai
	}
	for i, ai := range a {
		ans[i] = fmt.Sprint(ai ^ x)
	}
	fmt.Fprintln(stdout, strings.Join(ans, " "))
}


Measured memory_bytes: 19644
#include<stdio.h>
int main(void){
	int n,a,b;
	int i,j,cnt;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		cnt=0;
		scanf("%d %d",&a,&b);
		while(a>0){
			for(j=1;j<=b;j++){
				a--;
				if(a==0){
					break;
				}
			}
		}
		printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;cin>>s;int n=s.size();
    string s1="dream";string s2="dreamer";string s3="erase";string s4="eraser";
    string h;
    queue<string> S;
    S.push(h);
    bool ans=false;
    while(S.empty()==false){
        string a=S.front();S.pop();int x=a.size();
        if(a==s)ans=true;
    
        if(x+5<n+1&&a+s1==s.substr(0,x+5))S.push(a+s1);
        if(x+7<n+1&&a+s2==s.substr(0,x+7))S.push(a+s2);
        if(x+5<n+1&&a+s3==s.substr(0,x+5))S.push(a+s3);
        if(x+6<n+1&&a+s4==s.substr(0,x+6))S.push(a+s4);
    }
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 1320
import java.util.*

fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val str = Array(n){countMinAndSum(readLine()!!.trim())}
    val plus = PriorityQueue<Pair<Int, Int>>(compareBy(Pair<Int, *>::first).reversed())
    val minus = PriorityQueue<Pair<Int, Int>>(compareBy{ (min, count) -> min - count })
    var last = 0
    for ((min, count) in str){
        if (min >= 0){
            last += count
        }else if (count > 0) {
            plus.add(Pair(min, count))
        }else {
            minus.add(Pair(min, count))
        }
    }
    while(plus.isNotEmpty() && plus.peek().first >= -last){
        last += plus.poll().second
    }
    while(minus.isNotEmpty() && minus.peek().first >= -last && minus.peek().second >= -last){
        last += minus.poll().second
    }
    println(if (plus.isEmpty() && minus.isEmpty() && last == 0) "Yes" else "No")
}
fun countMinAndSum(str: String): Pair<Int, Int> {
    var count = 0
    var min = 0
    for (c in str){
        when(c){
            '(' -> ++count
            ')' -> {
                --count
                if (min > count) min = count
            }
        }
    }
    return Pair(min, count)
}



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    map<int,int>mp;
    long long ttl=0ll;
    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        mp[dif]++;
        if(dif==0)
            ttl++;
    }

    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        mp[dif]--;
        ttl+=(long long)mp[i+v[i]-v[0]];
    }
    cout << ttl << endl;
    return 0;
}
/***
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5

6
2 3 3 1 3 1
*/


Measured memory_bytes: 20960
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	try (Scanner in = new Scanner(System.in)) {
    		int[] line = new int[3];
    		
    		for (int i = 0; i < 3; i++) {
    			line[i] = Integer.parseInt(in.next());
    			if (i > 0 && line[i] != line[i-1]) {
    				System.out.println("No");
    				return;
    			}
    		}
    		System.out.println("Yes");
    		
    		
    		
    	} catch (Exception e) {
			// TODO: handle exception
		}
    }
}


Measured memory_bytes: 23124