akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    ll sum[N + 1];
    sum[0] = 0;
    for(int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];

    ll ans = 1LL << 50;
    for(int i = 1; i < N; i++){
        ll l = sum[i];
        ll r = sum[N] - sum[i];
        ans = min(ans, abs(r - l));
    }

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

Measured memory_bytes: 3456
N, M = map(int, input().split())
ngs = [False] * (N+1)
for _ in range(M):
    ngs[int(input())] = True

bs = [1] * (N+1)
for i in range(1, N+1):
    if ngs[i]:
        bs[i] = 0
    elif i == 1:
        bs[i] = 1
    else:
        bs[i] = (bs[i-1] + bs[i-2]) % 1000000007

print(bs[N])


Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    
    ll x;   cin >> x;
    cout << x/500*1000+(x%500)/5*5 << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int x,y;
    cin >> x>>y;
    int res=0;
    if(x==1)res+=300000;
    if(x==2)res+=200000;
    if(x==3)res+=100000;
    if(y==1)res+=300000;
    if(y==2)res+=200000;
    if(y==3)res+=100000;
    if(x==y&&y==1){
        res+=400000;
    }
    cout << res <<endl;
    return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
c10000 = 0
for i in range(N+1):
    c1000 = i
    for j in range(N+1-i):
        c5000 = j
        c10000  = N-i-j
        if c1000*1000+ c5000*5000+c10000*10000 == Y:
            print(c10000,c5000,c1000)
            exit()
print(-1,-1,-1)



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

int main() {
    long long N;
    cin >> N;
    string res = "";
    while (N) {
        --N;
        res = (char)('a' + (N % 26)) + res;
        N /= 26;
    }
    //reverse(res.begin(), res.end());
    cout << res << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string s;
  cin >> s;

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
    string s;
    int i,n,a,b,c,d;
    bool r1=0,b1=0,b2=0,b3=0;
    cin>>n>>a>>b>>c>>d;
    cin>>s;

    if(c<d){
        r1=0;
        for(i=b-1;i<d-1;i++){
            if(s[i]=='#'){
                if(r1){
                    cout<<"No"<<endl;
                    return 0;
                }
                r1=1;
            }
            else{
                r1=0;
            }
        }
        r1=0;
        for(i=a-1;i<c-1;i++){
            if(s[i]=='#'){
                if(r1){
                    cout<<"No"<<endl;
                    return 0;
                }
                r1=1;
            }
            else{
                r1=0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        for(i=b-2;i<d+1;i++){
            if(s[i]=='#'){
                b1=b2=0;
            }
            else{
                if(b1){
                    if(b2){
                        b3=1;
                        break;
                    }
                    else{
                        b2=1;
                    }
                }
                b1=1;
            }
        }

        r1=0;
        for(i=a-1;i<c-1;i++){
            if(s[i]=='#'){
                if(r1){
                    cout<<"No"<<endl;
                    return 0;
                }
                r1=1;
            }
            else{
                r1=0;
            }
        }

        if(b3){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.BigDecimal;

public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    double odds = 0;
    
    if(num%2 == 0){
      odds = (double) 0.5;
    } else {
      int numHalf = (num/2) + 1;
    odds = (double) numHalf/num;
    }
    System.out.println(odds);
  }
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] mArr = new int[n];

        int count = 0;
        for (int i = 0; i < n; i++) {
            mArr[i] = sc.nextInt();
            x -= mArr[i];
            count++;
        }

        Arrays.sort(mArr);
        int min = mArr[0];
        count += x/min;

        System.out.println(count);
    }
}


Measured memory_bytes: 22868
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    int S;
    cin >> S;
    for (int i = 0; i < S; i++) {
        vector<int> N(9);
        for (int j = 0; j < 9; j++) {
            string str;
            cin >> str;
            N[j] = (int)stoll(str, nullptr, 16);
        }

        uint32_t K = pow(2, 32) - 1;
        for (int d = 0; d < 32; d++) {
            ll sum = 0;
            for (int j = 0; j < 8; j++) {
                sum += K ^ N[j];
                sum %= (ll)pow(2, 32);
            }

            if ((sum & (1 << d)) != ((N[8] ^ K) & (1 << d))) {
                K ^= (1 << d);
            }
        }

        printf("%x\n", K);
    }
}


Measured memory_bytes: 3208
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M, Q;
int map[2000][2000];
int num[2000][2000];
int row[2000][2000];
int col[2000][2000];

int GetEdge(int x, int y)
{
	int c = x == 0 ? 0 : row[x - 1][y];
	int r = y == 0 ? 0 : col[x][y - 1];
	return c + r;
}

signed main()
{
	cin >> N >> M >> Q;
	REP(y, N)
	{
		string s;
		cin >> s;
		REP(x, M)
		{
			map[x][y] = (s.at(x) == '0') ? 0 : 1;
		}
	}

	REP(y, N)
	{
		REP(x, M)
		{
			if (x > 0)
			{
				num[x][y] += num[x - 1][y];
			}
			if (map[x][y] == 1)
			{
				num[x][y]++;
			}
		}
	}
	for (int y = 1; y < N; y++)
	{
		REP(x, M)
		{
			num[x][y] += num[x][y - 1];
		}
	}

	REP(y, N)
	{
		REP(x, M - 1)
		{
			if (x > 0)
			{
				row[x][y] += row[x - 1][y];
			}
			if (map[x][y] == 1 && map[x + 1][y] == 1)
			{
				row[x][y]++;
			}
		}
	}
	for (int y = 1; y < N; y++)
	{
		REP(x, M)
		{
			row[x][y] += row[x][y - 1];
		}
	}

	REP(y, N - 1)
	{
		REP(x, M)
		{
			if (y > 0)
			{
				col[x][y] += col[x][y - 1];
			}
			if (map[x][y] == 1 && map[x][y + 1] == 1)
			{
				col[x][y]++;
			}
		}
	}
	for (int x = 1; x < M; x++)
	{
		REP(y, N)
		{
			col[x][y] += col[x - 1][y];
		}
	}

	REP(q, Q)
	{
		int x1, y1, x2, y2;
		cin >> y1 >> x1 >> y2 >> x2;
		x1--; y1--; y2--; x2--;

		int n1 = 0;
		int n2 = 0;
		int n3 = 0;
		int n4 = 0;
		n1 = num[x2][y2];
		if (y1 > 0) n2 = num[x2][y1 - 1];
		if (x1 > 0) n3 = num[x1 - 1][y2];
		if (x1 > 0 && y1 > 0) n4 = num[x1 - 1][y1 - 1];
		int n = n1 - n2 - n3 + n4;

		int e1 = 0;
		int e2 = 0;
		int e3 = 0;
		int e4 = 0;
		e1 = ((x2 > 0) ? row[x2 - 1][y2] : 0) + ((y2 > 0) ? col[x2][y2 - 1] : 0);
		if (y1 > 0) e2 = col[x2][y1 - 1] + row[x2 - 1][y1 - 1];
		if (x1 > 0) e3 = col[x1 - 1][y2 - 1] + row[x1 - 1][y2];
		if (x1 > 0 && y1 > 0) e4 = row[x1 - 1][y1 - 1] + col[x1 - 1][y1 - 1];
		int e = e1 - e2 - e3 + e4;

		int ans = n - e;
		cout << ans << endl;
	}
}

Measured memory_bytes: 126848
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,min=101,max=-101;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (max<a[i]){
            max=a[i];
        }
        if (min>a[i]){
            min=a[i];
        }
    }
    long long ans;
    for (int i=min; i<=max; i++){
        int tmp=0;
        for (int j=0; j<n; j++){
            int tmp1,tmp2;
            tmp1=a[j]-i;
            tmp2=tmp1*tmp1;
            tmp+=tmp2;
        }
        if (i==min || ans>tmp){
            ans=tmp;
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

char *
int2str(int n)
{
    static char str[4];
    str[0] = n/100+'0';
    str[1] = n/10%10+'0';
    str[2] = n%10+'0';
    str[3] = '\0';
    return str;
}

void
solver(int n, char *s)
{
    int r=0;
    int i, j, p;
    char *t;

    for (i=0; i<1000; i++) {
        t = int2str(i);
        p=0;
        for (j=0; j<n; j++) {
            if (t[p]==s[j]) {
                if (p==2) {
                    r++;
                    break;
                }
                else {
                    p++;
                }
            }
        }
    }
    printf("%d\n", r);
}

int
main(int argc, char *argv[])
{
    int n;
    char s[30001];

    scanf("%d", &n);
    scanf("%s", s);

    solver(n, s);
    return 0;
}

Measured memory_bytes: 128
from sys import exit
N = int(input())

Od = True
Ev = True
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    if (x+y) % 2:
        Ev = False
    else:
        Od = False
    XY.append((x, y))

if not Od and not Ev:
    print(-1)
    exit()

ans = [2**i for i in range(31)]
Sig = sum(ans)

if Ev:
    ans = [1] + ans
print(len(ans))
print(*ans)
for x, y in XY:
    if Ev:
        x -= 1
    pl = abs((Sig - (x + y))//2)
    mi = abs((Sig - (x - y))//2)
    RU = [1 if pl & 2**i else 0 for i in range(31)]
    RD = [1 if mi & 2**i else 0 for i in range(31)]
    ans = [None]*31
    for j in range(31):
        if RU[j] and RD[j]:
            ans[j] = 'R'
        elif RD[j] and not RU[j]:
            ans[j] = 'D'
        elif not RD[j] and RU[j]:
            ans[j] = 'U'
        else:
            ans[j] = 'L'
    ans = ''.join(ans)
    xi, yi = 0, 0
    for i, s in enumerate(ans):
        if s == 'U':
            yi += 2**i
        if s == 'D':
            yi -= 2**i
        if s == 'R':
            xi += 2**i
        if s == 'L':
            xi -= 2**i
    if y != yi:
        ans = ans.translate(str.maketrans('UD', 'DU'))
    if x != xi:
        ans = ans.translate(str.maketrans('LR', 'RL'))
    if Ev:
        ans = 'R' + ans
    print(ans)
        

Measured memory_bytes: 46888
#include <stdio.h>

unsigned long a[100100];

int main()
{
	int k, flag = 1;
	unsigned long max, min;

	scanf("%d", &k);

	for (int i = 0; i < k; i++)
	{
		scanf("%ld", &a[i]);
	}

	max = 3, min = 2;

	if (a[k - 1] != 2)
	{
		flag = 0;
	}
	else
		for (int i = k - 2; i >= 0; i--)
		{
			if (a[i] > max)
			{
				flag = 0;
				break;
			}
			else
			{
				max = ((max / a[i]) + 1)*a[i] - 1;

				if (min%a[i] != 0)
				{
					min = ((min / a[i]) + 1)*a[i];
				}
			}

			if (max <= min)
			{
				flag = 0;
				break;
			}
		}

	if (flag)
		printf("%ld %ld", min, max);
	else
		printf("-1");

	return 0;
}

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

const ll mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> L(k);
    vector<int> R(k);
    rep(i,k){
        cin >> L[i] >> R[i];
    }
    vector<mint> dp(n+1);
    vector <mint> dpsum(n+1);
    dpsum[1] = 1;
    dp[1] = 1;
    for (int i = 2; i < n+1; i++){
        rep(j,k){
          int li = i-R[j];
          int ri = i-L[j];
          if (ri < 0) continue;
          li = max(1,li);
          dp[i] += dpsum[ri]-dpsum[li-1];
        }
        dpsum[i] = dpsum[i-1]+dp[i];
    }
    
    cout << dp[n] << endl;
    return 0;
}

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

int main(){
   long long int a, b, min;
   cin >> a;
  min = a+1;
  for(b=1;b<=sqrt(a);b++){
   if(a%b==0){
        if((b + a/b) < min)
          min = b + a/b;
     }
    }
   cout<< min - 2 <<endl;

  
  return 0;
}


Measured memory_bytes: 256
#abc045_b
import sys

a=list(raw_input())
b=list(raw_input())
c=list(raw_input())

ch=a.pop(0)

while True:
 if ch=='a':
  if len(a)==0:
   print 'A'
   sys.exit()
  ch=a.pop(0)
 elif ch=='b':
  if len(b)==0:
   print 'B'
   sys.exit()
  ch=b.pop(0)
 elif ch=='c':
  if len(c)==0:
   print 'C'
   sys.exit()
  ch=c.pop(0)


Measured memory_bytes: 2568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            for (int i = 0; i < n; i++) {
                while (true) {
                    if (a[i] % 2 != 0) break;
                    a[i] = a[i] / 2;
                    ans++;
                }
            }
            // 出力
            out.println(ans);

        }

    }
}



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int A[110000];
pint CB[110000];
signed main() {
    cin >> N >> M;
    rep(i, N) { cin >> A[i]; }
    rep(i, M) { cin >> CB[i].second >> CB[i].first; }
    sort(A, A + N);
    sort(CB, CB + M), reverse(CB, CB + M);
    int idx = 0;
    rep(i, M) {
        pint p = CB[i];
        rep(j, p.second) {
            if (A[idx] < p.first) { A[idx] = p.first; }
            idx++;
            if (idx == N) { goto nene; }
        }
    }
    nene:
    int ans = 0;
    rep(i, N) { ans += A[i]; }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    std::cin >> n>>x;
    if(n*500>=x)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    string s;
    cin >> s;

    int count = 0;
    int max = -1;
    for (char c : s)
    {
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
        {
            count++;
            max = max < count ? count : max;
        }
        else
        {
            count = 0;
            max = max < count ? count : max;
        }
    }
    cout << max << "\n";
    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (A == 1) {
			A = 14;
		}
		
		if (B == 1) {
			B = 14;
		}
		
		if (A > B) {
			System.out.println("Alice");
		} else if (A < B) {
			System.out.println("Bob");
		} else {
			System.out.println("Draw");
		}

		sc.close();
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
vector<ll> to[10];
//理論的には巡回セールスマン問題でやっているはずなのでしっかりできるようにしておこう
//DPで到着済みを表す配列とはまた異なる配列が必要。

vector<ll> done(10); //0だと訪れていない.1だと訪れたのできては行けない。
int n, m;
int dp(int u, int h) //閉回路の場合は親だけではないので、親情報はいらない・
{
    if (h == n - 1) //現在n-1歩目の時、たどり着いたとして1を返す。
    {
        return 1;
    }
    int res = 0;
    for (int x : to[u]) //木の要素
    {
        if (done[x] == 1)
        {
            continue;
        }
        done[x] = 1; //訪れたとして、
        res += dp(x, h + 1);
        //これだけではループを回したときに訪れたことになってしまう説があるので、うまく変更したいところ
        done[x] = 0; //訪れていないことにする。
    }
    return res;
}
int main()
{

    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i, m)
    {
        int a, b;

        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    done[0] = 1;
    cout << dp(0, 0); //0からスタートして全部行くパターン(距離がn-1個になるパターン,今現在0歩)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  ll k, a, b;
  cin >> k >> a >> b;

  if (a + 1 >= b || k == 1 || k == a)
  {
    cout << k + 1 << endl;
  }
  else
  {
    ll sum = 0;

    k -= a + 1;
    sum += b;

    sum += k / 2 * (b - a);
    k -= k / 2 * 2;
    sum += k;

    cout << sum << endl;
  }

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<string, ll> a;

    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        a[s]++;
    }

    ll ans = 0;
    for (auto c : a) ans += c.second * (c.second - 1) / 2;

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


Measured memory_bytes: 11264
A,B,C,X,Y=map(int,input().split())
ans=0
if X>0 and Y>0:
    n=min(X,Y)
    m=min(A+B,2*C)
    X-=n
    Y-=n
    ans+=m*n
ans+=min(A,2*C)*X+min(B,2*C)*Y
print(str(ans))

Measured memory_bytes: 3064
#include <math.h>
#include <stdio.h>
int n, m, q, p[10], A[11], a[50], b[50], c[50], d[50];
int sum, max = 0;
int n, m, A[11];
void dfs(int num, int pt) {
	if (pt == n + 1) {
		sum = 0;
		for (int i = 0; i < q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				sum += d[i];
			}
		}
		if (sum > max)
			max = sum;
		return;
	}
	A[pt] = num;
	while (A[pt] <= m) {
		dfs(A[pt], pt + 1);
		A[pt]++;
	}
	return;
}
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
	}
	dfs(1, 1);
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1700
s = gets.chomp

case s
when "SUN" then
	puts 7
when "MON" then
	puts 6
when "TUE" then
	puts 5
when "WED" then
	puts 4
when "THU" then
	puts 3
when "FRI" then
	puts 2
when "SAT" then
	puts 1
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, m;
    cin >> n >> m;
    int maiorl = 0, menorr = INFINITO;

    fo(i, m) {
        int l, r;
        cin >> l >> r;
        maiorl = max(maiorl, l);
        menorr = min(menorr, r);
    }

    cout << max(0, menorr - maiorl + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<double> b(N);
    rep(i,N){
        b[i] = (a[i]+1) / 2.0;
    }

    vector<double> l(N);
    l[0] = b[0];
    REP(i,N-1){
        l[i] = l[i-1] + b[i];
    }

    double ans = l[K-1];

    REP(i,N-K){
        chmax(ans, l[i+K-1] - l[i-1]);
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4992
N = 8
FREE = 1
NOT_FREE = -1


row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)

board = [[False] * N for _ in range(N)]

k = int(input())

for _ in range(k):
    r, c = map(int, input().split())
    board[r][c] = True


def slove(i):
    if i == N:
        print_board()
        return

    for j in range(N):
        if ((col[j] == NOT_FREE) or
            (dpos[i + j] == NOT_FREE) or
            (dneg[i - j + N - 1] == NOT_FREE)):
            continue

        row[i] = j
        col[j] = NOT_FREE
        dpos[i + j] = NOT_FREE
        dneg[i - j + N - 1] = NOT_FREE

        slove(i + 1)

        row[i] = FREE
        col[j] = FREE
        dpos[i + j] = FREE
        dneg[i - j + N - 1] = FREE
       

def print_board():
    for i in range(N):
        for j in range(N):
            if board[i][j] and row[i] != j:
                return
    
    for i in range(N):
        for j in range(N):
            if row[i] == j:
                mark = "Q"
            else:
                mark = "."
            print(mark, end="")
        print()

slove(0)



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

int main() {
    vector<int> ans(1001);
    int sum = 0;
    for (int i = 1; i < 1000; ++i) {
        sum = i;
        for (int j = i + 1; j < 1000; ++j) {
            sum += j;
            if (sum <= 1000)
                ans[sum]++;
        }
    }

    int n;
    while (cin >> n, n) {
        cout << ans[n] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
string mat[1010];
ll dp[1010][1010];
inline ll add(ll a, ll b)
{
    a = ((a % MOD) + MOD) % MOD;
    b = ((b % MOD) + MOD) % MOD;
    return (a + b) % MOD;
}
int main()
{
    int w, h;
    cin >> w >> h;
    for (int i = 0; i < w; ++i)
    {
        cin >> mat[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < w; ++i)
    {
        for (int j = 0; j < h; ++j)
        {
            if (mat[i][j] == '#')
                continue;
            if (i > 0)
                dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if (j > 0)
                dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << dp[w - 1][h - 1];
    return 0;
}

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

int main()
{
      int64_t n;
      cin>>n;
      
      map<string,int>s;
      int64_t cnt =0;
     for(int i=0;i<n;i++)
     {
           string sn;
           cin>>sn;
        
           if(!s.count(sn))
           {
             cnt++;
             s[sn] =1;
           }  
       
  
     
     }
  
      
   cout<<cnt<<endl;




}


Measured memory_bytes: 19204
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >>b;
	int cnt = 0;
	int x = 1;
	while(true){
		if(x >= b) break;
		cnt++;
		x += (a-1);
	}
	cout <<cnt << '\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;
using lint=long long;

template<class R>
class matrix{
	vector<vector<R>> a;
public:
	matrix(int n):a(n,vector<R>(n)){}
	matrix(int m,int n):a(m,vector<R>(n)){}

	matrix& operator+=(const matrix& A){
		assert(h()==A.h() && w()==A.w());
		int m=h(),n=w();
		rep(i,m) rep(j,n) (*this)[i][j]+=A[i][j];
		return *this;
	}
	matrix& operator-=(const matrix& A){
		assert(h()==A.h() && w()==A.w());
		int m=h(),n=w();
		rep(i,m) rep(j,n) (*this)[i][j]-=A[i][j];
		return *this;
	}
	matrix& operator*=(const matrix& A){
		assert(w()==A.h());
		int m=h(),n=w(),l=A.w();
		matrix B(m,l);
		rep(i,m) rep(j,l) rep(k,n) B[i][j]+=(*this)[i][k]*A[k][j];
		swap(*this,B);
		return *this;
	}
	matrix operator+(const matrix& A)const{ return matrix(*this)+=A; }
	matrix operator-(const matrix& A)const{ return matrix(*this)-=A; }
	matrix operator*(const matrix& A)const{ return matrix(*this)*=A; }
	const vector<R>& operator[](int i)const{ return a[i]; }
	vector<R>& operator[](int i){ return a[i]; }

	vector<R> operator*(const vector<R>& v)const{
		assert(w()==v.size());
		int m=h(),n=w();
		vector<R> res(m);
		rep(i,m) rep(j,n) res[i]+=(*this)[i][j]*v[j];
		return res;
	}

	int h()const{ return a.size(); }
	int w()const{ return a.empty()?0:a[0].size(); }

	static matrix identity(int n){
		matrix I(n);
		rep(i,n) I[i][i]=R{1};
		return I;
	}
};

template<class R>
matrix<R> pow(matrix<R> A,long long k){
	assert(A.h()==A.w());
	matrix<R> B=matrix<R>::identity(A.h());
	for(;k>0;k>>=1){
		if(k&1) B*=A;
		A*=A;
	}
	return B;
}

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator*(long long y,const mint& m){ return m*y; }

int main(){
	lint n,m; scanf("%lld%lld",&n,&m);

	matrix<mint> A(2);
	A[0][0]=1; A[0][1]=1;
	A[1][0]=1; A[1][1]=0;

	vector<mint> b(n+1);
	b[0]=-1;
	b[1]=-2;
	for(int i=2;i<=n;i++) b[i]=3*b[i-1]-b[i-2];

	mint ans=( b[n]-3*b[n-1])*pow(A, m )[0][1]
			+(-b[n]+2*b[n-1])*pow(A,m+1)[0][1];
	mint coef=1;
	rep(i,n-1){
		if(i>0) coef*=mint(m+i)/i;
		ans+=coef*b[n-i-2];
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 1024
/*************************************
 * @contest:      ABC149.
 * @user_name:    hkxadpall.
 * @time:         2019-12-29.
 * @language:     C++.
 * @upload_place: AtCoder.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

int n, k;
int r, s, p;
char t[100007];
int f[100007][3], ans = 0; // 0-r 1-s 2-p
#define max3(a, b, c) max(max((a), (b)), (c))

int earn(int pos, int cse)
{
    if (t[pos] == 'r' && cse == 2) return p;
    if (t[pos] == 's' && cse == 0) return r;
    if (t[pos] == 'p' && cse == 1) return s;
    return 0;
}

int main()
{
    cin >> n >> k >> r >> s >> p;
    scanf("%s", t + 1);
    for (int i = 1; i <= k; i++) {
        f[i][0] = earn(i, 0);
        f[i][1] = earn(i, 1);
        f[i][2] = earn(i, 2);
        for (int j = i + k; j <= n; j += k) {
            f[j][0] = max(f[j - k][1], f[j - k][2]) + earn(j, 0);
            f[j][1] = max(f[j - k][0], f[j - k][2]) + earn(j, 1);
            f[j][2] = max(f[j - k][0], f[j - k][1]) + earn(j, 2);
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     printf("r-%-4d s-%-4d p-%-4d\n", f[i][0], f[i][1], f[i][2]);
    // }
    for (int i = n - k + 1; i <= n; i++) {
        ans += max3(f[i][0], f[i][1], f[i][2]);
    }
    write(ans);
    return 0;
}

Measured memory_bytes: 1536
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [0 for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(wa)


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

int main(){
    string A,B,C;
    cin >> A >> B >> C;
    bool X=false;
    if (A[A.size()-1]==B[0] && B[B.size()-1]==C[0]) X=true ;
    if (X) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
  	int x[10][10]={0};
    int D=0;
  	int N=0;
  int count=0;
  scanf("%d",&N);
  scanf("%d",&D);
 	for(int i=0;i<N;i++){
      for(int j=0;j<D;j++){
      		scanf("%d",&x[i][j]);
      }
    }
    for(int i=0;i<N-1;i++){
    	for(int j=i+1;j<N;j++){
          	int sum=0;
        	for(int p=0;p<D;p++){
            	sum=(x[i][p]-x[j][p])*(x[i][p]-x[j][p])+sum;
            }
          	double sum_d=sqrt(sum);
          	sum=sqrt(sum);
          	if(sum_d==sum){
            	count++;
            }
        }
    }
  
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair
const int mod = 1e9+7;

signed main(){
  string s;
  cin>>s;
  int a=count(s.begin(),s.end(),'a');
  int b=count(s.begin(),s.end(),'b');
  int c=count(s.begin(),s.end(),'c');
  if(abs(a-b)<2&&abs(b-c)<2&&abs(c-a)<2)cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    long long a, b;
    char c;
    cin >> a >> b;
    cin >> c;
    int d;
    cin >> d;
    cout << a * b + (a * d / 100) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 
const int SEARCH_MAX = 6e3;

int main() {
  long long int A, B, X;
  cin >> X;
  for (long long int i = -SEARCH_MAX; i <= SEARCH_MAX; ++i) {
    for (long long int j = -SEARCH_MAX; j <= SEARCH_MAX; ++j) {
      if (i*i*i*i*i - j*j*j*j*j == X) {
        A = i;
        B = j;
        break;
      }
    }  
  }
  cout << A << ' ' << B << endl;
}

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

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

    rep(i, n) {
        ll minDist = 1e12;
        int idx = 0;
        rep(j, m) {
            ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < minDist) idx = j, minDist = dist;
        }
        cout << idx + 1 << endl;
    }

    return 0;
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    int N;
    cin >> N;
    vector<int> buka(N+1, 0);
    REP(i, N-1) {
        int A;
        cin >> A;
        buka[A]++;
    }
    REP(i, N) {
        cout << buka[i+1] << endl;
    }
}


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

int main() {
  long long N; cin >> N;
  
  int ans = 0;
  int size = 0;
  vector<int> m(0);
  
  if(N<10) {
    cout << N << endl;
    return 0;
  }
  
  while(N > 0) {
    size++;
    m.push_back(N%10);
    N /= 10;
  }
  
  int n=1;
  rep(i, size-1) {
    if(m[i] != 9) n=0;
  }

  if(n==1) {
    cout << 9*(size-1)+m[size-1] << endl;
    return 0;
  }
  
  cout << 9*(size-1) + m[size-1]-1 << endl;
  
}


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

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	unordered_map<int,int> m;
	long long int count = 0;
	for(int i = 0; i < n; i++)
	{
		if(m.find((i - A[i])) != m.end())
		{
			count += m[i - A[i]];
		}
		m[(i +A[i])]++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 12164
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    cin >> h >> w;
    REP(i,h) REP(j,w){
        string s;
        cin >> s;
        if (s == "snuke"){
            cout << (char)('A'+j) << i+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

vector<int> G[100010];
deque<int> dq;
bool used[100010];

void dfs(int v, int c){
    used[v] = true;
    for(int nv: G[v])if(!used[nv]){
        if(c == 0) dq.push_back(nv);
        else dq.push_front(nv);
        dfs(nv, c);
        return;
    }
    return;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    dq.push_back(0);
    rep(i, n) used[i] = false;
    dfs(0, 0);
    dfs(0, 1);
    printf("%d\n", dq.size());
    for(int v: dq) printf("%d ", v+1);
}

Measured memory_bytes: 11008
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S; cin >> S;
	int N = S.size() + 1;
	vector<int> v(N, -1);

	rep(i, 0, N - 1) {
		if (S[i] == '>' && S[i + 1] == '<') {
			v[i + 1] = 0;
		}
	}
	if (S[0] == '<')v[0] = 0;
	if (S.back() == '>')v[N - 1] = 0;
	dump(v);
	
	rep(i, 0, N - 1) {
		if (S[i] == '<') {
			chmax(v[i + 1], v[i] + 1);
		}
	}
	rrep(i, 0, N - 1) {
		if (S[i] == '>') {
			chmax(v[i], v[i + 1] + 1);
		}
	}
	dump(v);

	int ans = accumulate(all(v), 0LL);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4764
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    double a, b, x;
    double ans_rad, ans;
    scanf("%lf%lf%lf", &a, &b, &x);

    if ( x > a*a*b/2 )
        ans_rad = atan((2*(a*a*b-x))/(a*a*a));
    else
        ans_rad = M_PI / 2 - atan(2*x/(a*b*b));

    ans = 180 * ans_rad / M_PI;

    printf("%lf\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> s(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    ans += s[i];
  }
  sort(s.begin(), s.end());
  if (ans % 10 > 0) {
    cout << ans << endl;
    return 0;
  } else if (ans % 10 == 0) {
    for (int i = 0; i < N; i++) {
      if (s[i] % 10 != 0) {
        cout << ans - s[i] << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n % 2 == 0) {
			System.out.print(n);
		} else {
			System.out.print(n * 2);
		}
	}
}

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

bool ok(string s) {
	if (s.length() % 2 != 0)return false;
	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() / 2 + i])return false;
	}
	return true;
}

int main() {
	string s;
	cin >> s;
	for (int i = 2; i < s.length(); i += 2) {
		string t = s.substr(0, s.length() - i);
		if (ok(t)) {
			cout << s.length() - i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256