akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n;
	cin >> n;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		sum += cntmod(a, 2);
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

string s;

void input() {
    cin >> s;
}


void solve() {
    if (s.size() == 2)
        cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}


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



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ARangeFlipFindRoute {
public:
    map<pair<int, int>, int> memo;
    int H, W;
    vector<vector<char>> s;

    int dfs(int x, int y) {
        if (memo.count({x, y})) return memo[{x, y}];
        if (x == H - 1 && y == W - 1) {
            return s[x][y] == '#' ? 1 : 0;
        }

        int res = INF;
        if (x + 1 < H) {
            int tmp = dfs(x+1, y);
            if (s[x][y] == '#' && s[x + 1][y] == '.') tmp++;
            res = min(res, tmp);
        }
        if (y + 1 < W) {
            int tmp = dfs(x, y + 1);
            if (s[x][y] == '#' && s[x][y + 1] == '.') tmp++;
            res = min(res, tmp);
        }
        return memo[{x, y}] = res;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> H >> W;
        s = vector<vector<char>>(H, vector<char>(W, '.'));
        REP(i, H) {
            REP(j, W) {
                cin >> s[i][j];
            }
        }
        int res = dfs(0, 0);
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ARangeFlipFindRoute solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	string line;
	while ( cin >> line )
	{
		replace( line.begin(), line.end(), ',', ' ' );
		istringstream is( line );
		int no;
		double w, h;
		is >> no >> w >> h;

		if ( ( w / ( h*h ) ) >= 25.0 )
			cout << no << endl;

	}
	return 0;
}

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

int main()
{
	std::string S, T;
	std::cin >> S >> T;
	std::vector<int> sSum(S.size() + 1), tSum(T.size() + 1);
	for (int i{}; i < (int)S.size(); i++)
	{
		sSum[i + 1] = sSum[i];
		if (S[i] == 'A') sSum[i + 1] += 2;
		else sSum[i + 1] += 1;
	}
	for (int i{}; i < (int)T.size(); i++)
	{
		tSum[i + 1] = tSum[i];
		if (T[i] == 'A') tSum[i + 1] += 2;
		else tSum[i + 1] += 1;
	}

	int q;
	scanf("%d", &q);
	for (int i{}; i < q; i++)
	{
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; c--;
		if ((sSum[b] - sSum[a]) % 3 == (tSum[d] - tSum[c]) % 3)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))

#define dbg(x) cerr << #x << " = " << x << endl;
#define dbgall(x) cerr << #x << " = "; for(auto i_ : x) cerr << i_ << " "; cerr << endl;
#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	double r; cin >> r;
	cout << 2.0 * 3.14159265359 * r << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll a, b, c, d, e, k;

    cin >> a >> b >> c >> d >> e >> k;

    cout << (abs(a - e) > k ? ":(" : "Yay!") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long A, B, N;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		A = Long.parseLong(tokens[0]);
		B = Long.parseLong(tokens[1]);
		N = Long.parseLong(tokens[2]);
	}

	void calc() {
		result = Math.min(N, B - 1) * A / B;
		System.out.println(result);
	}

	void showResult() {
	}

}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n], b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  vector<ll> sa(n + 1);
  rep(i, n) sa[i + 1] = sa[i] + a[i];
  vector<ll> sb(m + 1);
  rep(i, m) sb[i + 1] = sb[i] + b[i];

  int ans = 0;
  rep(i, n + 1) {
    int now = i;
    ll res = k - sa[i];
    if (res < 0) continue;
    int idx = upper_bound(sb.begin(), sb.end(), res) - sb.begin();
    now += idx - 1;
    ans = max(ans, now);
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;++i) {
    cin >> s[i];
  }

  int cnt = 0;
  int cb = 0, ca = 0, rab = 0;
  for(int i=0;i<n;++i) {
    int sz = s[i].size();
    bool a = false;
    if(s[i][0] == 'B' && s[i][sz-1] == 'A') {
      rab++;
    } else if(s[i][0] == 'B') {
      cb++;
    } else if(s[i][sz-1] == 'A') {
      ca++;
    }
    for(int j=0;j<sz;++j) {
      if(s[i][j] == 'A') {
        a = true;
      } else {
        if(s[i][j] == 'B' && a) cnt++;
        a = false;
      }
    }
  }

  if(rab != 0 && ca + cb == 0) {
    cout << cnt + rab - 1 << endl;
  } else {
    cout << cnt + rab + min(ca, cb) << endl;
  }
}


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

int main(){
  string S;
  cin >> S;
  string front = S.substr(0,2);
  string end = S.substr(2, 2);
  bool yy=false, mm=false;

  if(stoi(front)<=12 && stoi(front)>0){
    mm = true;
  }
  if(stoi(end)<=12 && stoi(end)>0){
    yy = true;
  }
  if(yy && mm){
    cout << "AMBIGUOUS" << endl;
  }
  else if(yy || mm) {
    if(yy)cout << "YYMM"<< endl;
    if(mm)cout << "MMYY" << endl;
  }
  else{
    cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
    int n, m;
    cin >> n;
    m = n;

    int f = 0;
    while(m > 0){
        f += m % 10;
        m /= 10;
    }

    if(n % f == 0) cout << "Yes" << endl;
    if(n % f != 0) cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
Input = []
while True:
    try:
        a,b = list(map(int, input().split()))
        Input += a,b
    except EOFError:
        break
    if a!=0:
        for j in range(a):
            for i in range(b):
                if j%2==0 and i%2==0:
                    print('#',end='')
                elif j%2!=0 and i%2!=0:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
        print()


Measured memory_bytes: 7016
#include <stdio.h>

int main(void)
{
    int N, H[100001], i;
    int max=0;//最大の移動回数
    int idou=0;//現在の移動回数

    scanf("%d",&N);

    for(i=0; i<N; i++){
        scanf("%d",&H[i]);
    }

    for(i=0; i<N-1; i++){
        if(H[i] >= H[i+1]){
            idou++;
        } else {
            idou = 0;
        }
        if(max < idou){
            max = idou;
        }
    }


    printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 512
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,d = iim()

print(math.ceil(n/(2*d+1)))

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(){

   long long x;
   int c = 0;
   long long y = 100;


   cin >> x;

   while(y < x){
       y = 1.01*y;
       c = c + 1;
   }

   cout << c << endl;

   return 0;

}

Measured memory_bytes: 3640
H, W = map(int, input().split())

ans = []
# 横白の除去
for h in range(H):
    line = input()
    if "#" in line:
        ans.append(line)


lines = zip(*ans)
ans = []
# 縦白の除去
for line in lines:
    if "#" in line:
        ans.append(line)

an = zip(*ans)

for line in an:
    print(''.join(line))

Measured memory_bytes: 3064
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,b*d);
    ll ans2=b*c;
    ans2=max(ans2,a*d);
     cout<<max(ans,ans2)<<endl;

    return 0;
}


Measured memory_bytes: 3648
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()

ans = 0
for n in range(1, N+1):
    m = N // n
    ans += n * m * (m + 1) // 2

print(ans)

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
        cin >> A[i] >> B[i] >> C[i];
    
    vector<int> dpA(N, MOD), dpB(N, MOD), dpC(N, MOD);
    dpA[0] = A[0], dpB[0] = B[0], dpC[0] = C[0];
    for (int i = 1; i < N; i++)
    {
        dpA[i] = max(dpB[i - 1] + A[i], dpC[i - 1] + A[i]);
        dpB[i] = max(dpA[i - 1] + B[i], dpC[i - 1] + B[i]);
        dpC[i] = max(dpA[i - 1] + C[i], dpB[i - 1] + C[i]);
    }
    cout << max(dpA[N - 1], max(dpB[N - 1], dpC[N - 1]));
}

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

using namespace std;

int main()
{
    #ifdef lOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // lOCAL_EXEC
    double d,s,t;
    cin>>d>>t>>s;
    if(d/s>t)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3732
n=int(input())
f=[]
P=[]
for i in range(n):
    a=list(map(int,input().split()))
    f.append(a)
for i in range(n):
    a=list(map(int, input().split()))
    P.append(a)
from itertools import product
ans=-(10**10)
for p in product([0, 1], repeat = 10):
    if sum(p)!=0:
        ret = 0
        for i in range(n):
            cnt = 0
            for j in range(10):
                if p[j] == f[i][j] and p[j] == 1:
                    cnt += 1
            ret += P[i][cnt]
        ans = max(ans, ret)
print(ans)



Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);
	h = S / 3600;
	m = S / 60 - h * 60;
	s = S - h * 3600 - m * 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=3e3+10;
ll n,a[N],oo=1e13,sum;
ll mem[N][N][3];
ll dp(int i,int j,int p){
if(i>j){return 0;}
if(i==j){return (p?a[i]:0);}
ll &ret=mem[i][j][p];
if(ret!=-1){return ret;}
ret=-oo;
if(p){
ret=max(a[i]+dp(i+1,j,!p),a[j]+dp(i,j-1,!p));
}
else{
ret=min(dp(i+1,j,!p),dp(i,j-1,!p));
}
return ret;
}
int main(){
me(mem,-1);
scll(n);
read_arr_ll(a,1,n);
loop(i,1,n){sum+=a[i];}
ll ans=2*dp(1,n,1)-sum;
printf("%lld\n",ans);
}
/**
**/


Measured memory_bytes: 212736
#これはmaspyさんの提出コードの写経です
from sys import setrecursionlimit
setrecursionlimit(10**6) 

from sys import stdin
from functools import lru_cache
n = int(stdin.readline().rstrip())
k = int(stdin.readline().rstrip())
#n以下の数字で0でないものがちょうどk個
@lru_cache(maxsize=None)
def kosuu(n,k):
    #残り10以下の場合
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    q = n//10#商
    r = n%10#余り
    ret = 0
    if k >= 1:
        # 1の位が nonzero
        ret += kosuu(q, k-1) * r
        ret += kosuu(q-1, k-1) * (9-r)
    ret += kosuu(q,k)
    return ret
print(kosuu(n,k))

Measured memory_bytes: 3940
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
ll n, k, a[200009], u[200009], cyclestart = -1;
vector<ll> path;
void go(ll v) {
    u[v] = 1;
    path.push_back(v);
    ll nex = a[v];
    if(u[nex]) {
        cyclestart = nex;
        return;
    }
    go(nex);
}
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    go(1);
    for(int i=0;i<path.size();i++) {
        ll cur = path[i];
        if(cur != cyclestart) {
            if(k == 0) {
                cout<<cur;
                return 0;
            }
            k--;
            continue;
        }
        int sz = int(path.size()) - i;
//        cout<<i<<" "<<cur<<" "<<sz<<" "<<k<<" ";
        k %= sz;
//        cout<<k<<endl;
        cout<<path[i + k];
        break;
    }
}
/*
 2
 1 1
 1 0
 1 1
 1 1
 */


Measured memory_bytes: 14112
#include <stdint.h>
#include <stdio.h>
#include <stack>
#include <vector>

unsigned readUnsigned() {
    int c;
    do { c = ::getchar_unlocked(); } while (c < '0');
    unsigned result = c - '0';
    while ((c = ::getchar_unlocked()) >= '0') {
        result *= 10;
        result += c - '0';
    }
    return result;
}

void writeUnsignedLn(unsigned x) {
    static const unsigned MAX_DIGITS = 10;
    static const unsigned BUF_SIZE = MAX_DIGITS + 1;
    static char buffer[BUF_SIZE] = {0};
    buffer[BUF_SIZE - 1] = '\n';
    unsigned i = BUF_SIZE - 1;
    do {
        buffer[--i] = x % 10 + '0';
        x /= 10;
    } while (x);
    ::fwrite_unlocked(buffer + i, 1, BUF_SIZE - i, stdout);
}

struct Node {
    unsigned color = 0;
    unsigned colordist = 0;
    std::vector<unsigned> edges;
};

struct Paint {
    unsigned v = 0;
    unsigned color = 0;
    unsigned dist = 0;

    Paint(unsigned v = 0, unsigned color = 0, unsigned dist = 0)
        : v(v), color(color), dist(dist)
    {
    }
};

Node NODE[100 * 1000];

int main() {
    unsigned N = readUnsigned();
    unsigned M = readUnsigned();

    for (unsigned i = 0; i < M; ++i) {
        unsigned x = readUnsigned();
        unsigned y = readUnsigned();
        --x, --y;
        NODE[x].edges.push_back(y);
        NODE[y].edges.push_back(x);
    }
    
    unsigned numPaint = readUnsigned();
    std::stack<Paint> jobs;
    for (unsigned i = 0; i < numPaint; ++i) {
        unsigned v = readUnsigned();
        unsigned dist = readUnsigned();
        unsigned color = readUnsigned();
        jobs.push(Paint(v - 1, color, dist + 1));
    }

    while (!jobs.empty()) {
        Paint P = jobs.top();
        jobs.pop();
        if (NODE[P.v].colordist >= P.dist) {
            continue;
        }
        if (NODE[P.v].color == 0) {
            NODE[P.v].color = P.color;
        }
        NODE[P.v].colordist = P.dist;
        if (P.dist == 1) {
            continue;
        }
        for (unsigned u : NODE[P.v].edges) {
            if (NODE[u].colordist < P.dist - 1) {
                jobs.push(Paint(u, P.color, P.dist - 1));
            }
        }
    }

    for (unsigned i = 0; i < N; ++i) {
        writeUnsignedLn(NODE[i].color);
    }
}


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

extern inline unsigned int xor128(void){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123; 
  unsigned int t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}

template <typename T>
class Treap{
public:
  Treap* l;
  Treap* r;
  int cnt;
  int pri;
  T value;
  Treap(){
  }
  Treap(T v){
    value=v;
    cnt=1;
    pri=xor128();
    l=r=NULL;
  }
};

template <typename T >
class Vectree{
private:

  int count(Treap<T>* t){ return !t ? 0:t->cnt; }

  Treap<T>* update(Treap<T>* t){
    t->cnt = count(t->l) + count(t->r) + 1;
    return t;
  }

  
  Treap<T>* merge(Treap<T>* l,Treap<T>* r){
    if( !l || !r ) return !l ? r : l;
    if( l->pri > r ->pri ){
      l->r = merge(l->r,r);
      return update(l);
    } else {
      r->l = merge(l,r->l);
      return update(r);
    }
  }

  typedef pair< Treap<T>* , Treap<T>* > pnn;
  pnn split(Treap<T>* t,int k){
    if( !t ) return pnn(NULL,NULL);
    if( k <= count(t->l) ){
      pnn s = split(t->l,k);
      t->l = s.second;
      return make_pair(s.first,update(t));
    } else {
      pnn s = split(t->r,k - count(t->l) - 1);
      t->r = s.first;
      return make_pair(update(t),s.second);
    }
  }
  
  int size_num;
  Treap<T> *root;
  
  int poolc;
  Treap<T> pool[10000];
  
public:
  Vectree(){
    size_num=0;
    poolc=0;
    root=NULL;
  }
  
  int size();
  void push_back(T);
  void pop_back();
  void insert(int,T);
  void erase(int);
  T& operator [] (int x);
};


template <typename T>
int Vectree <T> :: size(){
  return size_num;
}

template <typename T>
void Vectree <T> :: erase(int index){
  auto p=split( root, index + 1 );
  auto q=split( p.first, index);
  root = merge(q.first,p.second);
  size_num--;
}

template <typename T>
void Vectree <T> :: insert(int index,T v){
  auto p=split( root, index );
  pool[ poolc ] = Treap<T>(v);
  p.first = merge( p.first, &pool[poolc] );
  poolc++;
  root = merge( p.first, p.second );
  size_num++;
}

template <typename T>
void Vectree <T> :: push_back(T v){
  insert( size_num, v );
}

template <typename T>
void Vectree <T> :: pop_back(){
  erase( size_num );
}

template <typename T>

T& Vectree<T> :: operator [] (int x){
  auto p=split(root,x);
  auto q=split(p.second,1);
  root=merge(p.first, merge(q.first,q.second) );
  return q.first->value;
}

int main(){
  Vectree<int> t;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    t.push_back(a);
  }
  

  for(int i=n-1;i>=0;i--){
    cout<<t[i];
    if(i==0)cout<<endl;
    else cout<<' ';
  }

  return 0;
}

Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>

using namespace std;

int n, a[100];
long long dp[3100][3100];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> dp[i][1];
  }

  for (int len = 2; len <= n; len++) {
    for (int i = 0; i+len <= n; i++) {
      dp[i][len] = max(dp[i][1]-dp[i+1][len-1], dp[i+len-1][1]-dp[i][len-1]);
    }
  }

  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 74112
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        S: String,
    }

    if &S == "RRR" {
        println!("3");
        return;
    }

    if &S == "RRS" || &S == "SRR" {
        println!("2");
        return;
    }

    if &S == "SSS" {
        println!("0");
        return;
    }

    println!("1");

}


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

class UnionFind {
    vector<int> data;
    ll num;
public:
    UnionFind(int size) : data(size, -1), num(size) { }
    bool unite(int x, int y) {//xとyの集合を統合する
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        num -= (x != y);
        return x != y;
    }
    bool findSet(int x, int y) {//xとyが同じ集合か返す
        return root(x) == root(y);
    }
    int root(int x) {//xのルートを返す
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(int x) {//xの集合のサイズを返す
        return -data[root(x)];
    }
    ll numSet() {//集合の数を返す
        return num;
    }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> to[n];
  vector<int> block[n];
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
    uf.unite(a,b);
  }
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--;d--;
    block[c].push_back(d);
    block[d].push_back(c);
  }
  rep(i,n){
    int ans=uf.size(i);
    ans=ans-1-to[i].size();
    for(auto x : block[i]){
      if(uf.findSet(x,i)) ans--;
    }
    cout<<max(ans,0)<<" "; 
  }
  cout<<endl;
}

Measured memory_bytes: 14664
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  std::vector<int> P(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> S[i] >> P[i];
  }

  // Main
  std::vector<int> res(N);
  for (int i = 0; i < N; ++i) {
    res[i] = i;
  }

  std::stable_sort(res.begin(), res.end(),
                   [&](int k, int l) { return P[k] > P[l]; });
  std::stable_sort(res.begin(), res.end(),
                   [&](int k, int l) { return S[k] < S[l]; });

  // std::cout << res << std::endl;

  // Output
  for (int i = 0; i < N; ++i) {
    std::cout << res[i] + 1 << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = [0]*N
S = [0]*N

for i in range(N):
    c, *s = map(int, input().split())
    C[i] = c
    S[i] = list(s)

ans = 10**7
for i in range(2**N):
    num = i
    data = [0]*M
    cost = 0
    for j in range(N):
        if num&1 == 1:
            for k in range(M):
                data[k] += S[j][k]
            cost += C[j]
        num >>= 1
    if min(data) >= X:
        ans = min(ans, cost)

if ans == 10**7:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

const int maxn = 2500 + 5;
const int maxm = 5005;

int n , m , p;
ll d[maxn];

int a[maxm] , b[maxm] , c[maxm];

void negative(){
	ll now = 0;
	fill_n(d,maxn,(ll)-1e18);
	d[1] = 0;
	for(int i = 1 ; i <= n  ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			if(d[a[j]] != -1e18 && d[b[j]] < d[a[j]] + c[j]){
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}
	now = d[n];
	for(int i = 1 ; i <= n  ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			if(d[a[j]] != -1e18 && d[b[j]] < d[a[j]] + c[j]){
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}
	//cout << d[n] << endl;
	if(now != d[n]){
		cout << -1;
		exit(0);
	}
	cout << max(0ll,d[n]);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> p;	
	for(int i = 1 ; i <= m ; ++i){
		cin >> a[i] >> b[i] >> c[i];
		c[i] -= p;
		//adj[a[i]].pb(mp(b[i] , c[i]));
	}
	negative();
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll i,a[n],b[n];
  for(i=0;i<n;i++) {cin>>a[i];b[i]=a[i];}
  sort(a,a+n);
  ll c=0;
  for(i=0;i<n;i++)
  {
    if(a[i]!=b[i]) c++;
  }
  if(c>2) cout<<"NO";
  else cout<<"YES";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	
	long A,B,C;

	cin>>A>>B>>C;


	long sum = A*B*C;
	
	long c_men = A*B;
	long a_men = B*C;
	long b_men = A*C;
	
long answer;
	if( (A%2 == 0) || (B%2 == 0) || (C%2 == 0) ){
		cout<<'0'<<endl;	
		return 0;
	}




	long min_men = min(a_men,min(b_men,c_men));


	cout<<min_men<<endl;


	return 0;
}


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

#define int long long
const int INF = 1LL << 60;


int cost(int i, int s, const vector<int> &A){
    if(s == 0 || s == 4) return A[i];
    else if(s == 1 || s == 3){
        if(A[i] % 2 == 0) return (A[i] == 0 ? 2 : 0);
        else return 1;
    }else{
        if(A[i] % 2 == 0) return 1;
        else return 0;
    }
}

signed main() {

    int L; cin >> L;
    vector<int> A(L);
    for(int i = 0; i < L; i++) cin >> A[i];

    vector<vector<int> > dp(L + 1, vector<int> (5, INF));
    dp[0][0] = 0;
    for(int i = 0; i < L; i++){
        for(int j = 0; j < 5; j++){
            for(int k = j; k < 5; k++){
                dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + cost(i, k, A));
            }
        }
    }

    int ans = INF;
    for(int j = 0; j < 5; j++) ans = min(ans, dp[L][j]);
    cout << ans << endl;
    return 0;
}


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

Measured memory_bytes: 2752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(ALL(v));
    int ans=0;
    ans+=(v[2]-v[1]);
    v[0]+=(v[2]-v[1]);
    if((v[2]-v[0])%2==1){
        v[0]-=(v[2]-v[1]);
        ans=1;
        v[0]++; v[2]++;
        ans+=(v[2]-v[1]);
        v[0]+=(v[2]-v[1]);
        ans+=(v[2]-v[0])/2;
        cout << ans << endl;
        return 0;
    }
    ans+=(v[2]-v[0])/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;
bool cmp(pair<int,int>p1,pair<int,int>p2)
{
    return p1.second<p2.second;
}
int main()
{
    long long n,i,k,c,l,s=0,j;
    cin>>n>>c;
    set<int>st;
    map<int,int>mp;
    vector<pair<int,int>>v;
    for(i=0;i<n;i++)
    {
        cin>>k;
        st.insert(k);
        mp[k]++;
    }
    j=st.size();
    //cout<<st.size()<<endl;
    if(st.size()<=c)
    {
        cout<<"0"<<endl;
        return 0;
    }
    else
    {
        for(auto i:mp)
        {
            v.push_back(make_pair(i.first,i.second));
        }
        sort(v.begin(),v.end(),cmp);
        l=j-c;
        for(i=0;i<l;i++)
        {
            s=s+v[i].second;
        }
        cout<<s<<endl;
        /*for(auto i:v)
        {
            cout<<i.first<< " "<<i.second<<endl;
        }*/

    }
    return 0;
}


Measured memory_bytes: 23880
k = int(input()) #ここで標準入力

# 数値→アルファベット
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

#１０進数を２６進数に変えれば良い。
# t = 0
# # print(len(a))
# for i in range(k):
#     k = k /26
#     t += 1
#     if k < 26:
#         amari = int(k % 26)
#         break
# print(k)
# print(t)
# print(amari)

print(num2alpha(k).lower())

Measured memory_bytes: 9084
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,k;

  cin >> n >> k;

  int ans=0;
  rep(i,n)
  {
    int a;
    cin >> a;

    if(a>=k)
      ans++;
  }

  cout << ans;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if(A + B < C + D){
    cout << "Right" << endl;
  }
}
  
  
  

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W ==0){
                break;
            }else{
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 33400
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<long> x(n), y(n);
    int pr = 0;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (i == 0) {
            pr = (x[i] + y[i]) & 1;
        } else {
            if (pr != ((x[i] + y[i]) & 1)) {
                cout << -1;
                return 0;
            }
        }
    }

    vector<long> d;
    for (int i = 0; i < 31; i++) {
        d.push_back(1ll << i);
    }
    if (pr == 0) {
        d.push_back(1);
    }
    std::sort(d.rbegin(), d.rend());

    cout << d.size() << "\n";
    for (long x : d) {
        cout << x << " ";
    }
    cout << "\n";

    for (int t = 0; t < n; t++) {
        long xx = 0;
        long yy = 0;
        int dx[] = {-1, +1, 0, 0};
        int dy[] = {0, 0, -1, +1};
        string nm = "LRDU";
        for (long len : d) {
            int q = 0;
            long best = MAX_LONG;
            for (int j = 0; j < 4; j++) {
                long xxx = xx + len * dx[j];
                long yyy = yy + len * dy[j];
                long dd = std::abs(xxx - x[t]) + std::abs(yyy - y[t]);
                if (dd < best) {
                    best = dd;
                    q = j;
                }
            }
            cout << nm[q];
            xx = xx + len * dx[q];
            yy = yy + len * dy[q];
        }
        cout << "\n";
    }

    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;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;

int main(){
    int n,m;
    cin >> n >> m;
    vector<bool> correct(n,false);
    vector<int> wrong(n,0);
    int ans_ac=0;
    int ans_wa=0;
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (s=="AC"){
            if(!correct[p]) ans_ac+=1;
            correct[p]=true;
        }
        else{
            if(!correct[p]) wrong[p]+=1;
        }

    }
    rep(i,n){
        if (correct[i]) ans_wa+=wrong[i];
    }
    cout << ans_ac << " " << ans_wa << endl;

}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
class Main{
    public static void main(String[] a){
		 Scanner scanner = new Scanner(System.in);

		 int Hill[] = new int[10];
		 int i;
		 for (i = 0; i < 10; i++ ) {
			 Hill[i] = scanner.nextInt();
		 }

		 Arrays.sort(Hill);
		 System.out.println(Hill[9]);
		 System.out.println(Hill[8]);
		 System.out.println(Hill[7]);
		 scanner.close();

    }
}


Measured memory_bytes: 26292
#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>;
using Graph = vector<vector<int>>;

const long long MOD = 1000000007;
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);
  string S, T;
  cin >> S >> T;
  string Tsub = T.substr(0, S.size());
  if (S == Tsub)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <functional>
#include <array>
#include <algorithm>

using namespace std;

int main() {

	int a;

	cin >> a;

	cout << a + a * a + a * a * a;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (d.at(i) != d.at(i - 1)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

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;
}

vector<int> rs;
vector<int> gs;
vector<int> bs;

ll calc(const vector<int> &rs, const vector<int> &gs, const vector<int> &bs) {
    ll ans = 0;
    for (auto &r : rs) {
        auto p_g = upper_bound(gs.begin(), gs.end(), r);
        while (p_g != gs.end()) {
            const int g = *p_g;
            auto p_b = upper_bound(bs.begin(), bs.end(), g);
            ans += bs.end() - p_b;
            // if (p_b != bs.end()) {
            //     printf("first: %d, second: %d, += %ld\n", r, g, bs.end() - p_b);
            // }

            p_b = lower_bound(bs.begin(), bs.end(), g + (g - r));
            if (p_b != bs.end() && *p_b - g == g - r) {
                // printf("but ignore it\n");
                ans--;
            }
            p_g++;
        }
    }
    return ans;
}

ll solve(const int N) {
    ll ans = 0;

    ans += calc(rs, gs, bs);
    ans += calc(rs, bs, gs);
    ans += calc(gs, rs, bs);
    ans += calc(gs, bs, rs);
    ans += calc(bs, rs, gs);
    ans += calc(bs, gs, rs);

    return ans;
}

int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    for (int i = 0; i < N; i++) {
        char c = S[i];
        if (c == 'R') {
            rs.push_back(i);
        } else if (c == 'G') {
            gs.push_back(i);
        } else {
            bs.push_back(i);
        }
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, m;
vector<ll> a;

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

signed main(){
    cin >> n >> m;
    a.resize(n);
    REP(i, n) cin >> a[i];
    
    REP(i, n){
        a[i] /= 2;
    }

    ll k = a[0];
    REP(i, n-1){
        k = lcm(k, a[i+1]);
        if(k > m){
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i, n){
        if((k / a[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ((m / k) + 1) / 2 << endl;

    return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n, m;
	scanf("%d %d", &n, &m);

	int M[m];
	for (int i = 0; i < m; ++i) {
		scanf("%d", &M[i]);
	}
	int V[n + 1];
	V[0] = 0;
	for (int i = 1; i <= n; ++i) {
		V[i] = 50000;
	}
	for (int i = 0; i < m; ++i) {
		for (int j = M[i]; j <= n; ++j) {
			V[j] = min(V[j], V[j - M[i]] + 1);
		}
	}
	cout << V[n] << endl;

	return 0;
}

Measured memory_bytes: 3396
H,W,A,B = map(int,input().split())
for i in range(B):
    S = []
    for j in range(A):
        S.append('0')
    for j in range(A,W):
        S.append('1')
    print(''.join(S))
for i in range(B,H):
    S = []
    for j in range(A):
        S.append('1')
    for j in range(A,W):
        S.append('0')
    print(''.join(S))

Measured memory_bytes: 3956
#include <iostream>                                                                                     #include <vector>
#include <algorithm>
#include <map>
#include <string.h>    

using namespace std;

int main() {
    std::string s;
    cin >> s;
    int pos = 0;
    int pos_pre = 0;
    int count=0;
    int zero= 0;                                                                                            int one= 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '0') {
            pos = 0;
        } else {
            pos = 1;
        }
        if (i != 0 ) {
            if (pos_pre == pos) {
                count++;
                if (pos == 0) {
                    pos = 1;
                } else {
                    pos = 0;
                }
            }
        }
        pos_pre = pos;
    }
    cout << count;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,a[100000],cun=0;
  cin>>n;
  for(ll i=0;i<n;i++){
	cin>>a[i];
  }
  ll ma = a[0];
  for(ll i=0;i<n;i++){
	if(ma<=a[i]){
      cun++;
      ma = a[i];
    }
  }
  cout<<cun<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
	char op;
	int a,b;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		printf("%d\n",a+b);
	}
	else if(op=='-'){
		printf("%d\n",a-b);
	}
	else if(op=='*'){
		printf("%d\n",a*b);
	}
	else if(op=='/'){
		printf("%d\n",a/b);
	}

	else{
		break;
	}
	}
	

	return 0;
}

Measured memory_bytes: 600