akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 1000010
 
int main(){
	IOS;
	tihs;
	
	ll k,n;cin>>n>>k;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	ll cnt=k,s=0;
	for(ll i=n-1;i>=0;--i){
		if(cnt)cnt--;
		else s+=a[i];
	}
	cout<<s;
	return 0;
}

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



int main() {
  int n,k;
  cin >>n >>k;
  string s;
  cin >>s;
  k--;
  s[k]+=32;
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

using mint = ModInt<MOD>;
int main() {
	int n; cin >> n;
	int a[n]; rep(i,n) cin >> a[i];
	mint sum = 0;
	rep(i,n) {
		sum += a[i];
	}
	mint ans = 0;
	rep(i,n) {
		sum -= a[i];
		ans += sum * a[i];
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = sz(s);
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) {
    a[i] = i % 2;
    b[i] = (i+1) % 2;
  }
  int count_a = 0;
  rep(i,n) {
    if(a[i] != (s[i] - '0')) count_a++;
  }
  int count_b = 0;
  rep(i,n) {
    if(b[i] != (s[i] - '0')) count_b++;
  }
  cout << min(count_a,count_b) << endl;
  return 0;
}

Measured memory_bytes: 1280
n = int(input())
A = []
B = []
C = []
for _ in range(n):
    [a,b,c] = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    C.append(c)

dp_a = [0]*n
dp_b = [0]*n
dp_c = [0]*n

dp_a[0] = A[0]
dp_b[0] = B[0]
dp_c[0] = C[0]

for i in range(1, n):
    dp_a[i] = max(dp_b[i-1], dp_c[i-1]) + A[i]
    dp_b[i] = max(dp_a[i-1], dp_c[i-1]) + B[i]
    dp_c[i] = max(dp_b[i-1], dp_a[i-1]) + C[i]

print(max(dp_a[-1], dp_b[-1], dp_c[-1]))


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

int main(){
    long long a,b,c,d,e,f,g,h,nen,tuki,hi;
    char s[10];
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    e=s[5]-'0';
    f=s[6]-'0';
    g=s[8]-'0';
    h=s[9]-'0';
    nen=1000*a+100*b+10*c+d;
    tuki=10*e+f;
    hi=10*g+h;
    
    if (nen<=2019&&tuki<=4&&hi<=30) {
        cout<<"Heisei"<<endl;
    }
    else cout<<"TBD"<<endl;
    
    
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    ans = ["x" for _ in range(n)]
    if n == 1 and m == 0:
        print(0)
        return

    for _ in range(m):
        s, c = map(int, input().split())
        if (s == 1 and c == 0 and n != 1) or s > n:
            print(-1)
            return

        if ans[s-1] != "x" and ans[s-1] != str(c):
            print(-1)
            return

        ans[s-1] = str(c)

    if ans[0] == "x":
        ans[0] = "1"
    print("".join(ans).replace("x", "0"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){   
    ll k,a,b;cin>>k>>a>>b;
    ll profit = max(b-a,2ll);
    if(k<a-1){
        cout<<k+1<<"\n";
        return;
    }
    k-=a-1;
    ll cookies = a;
    cookies += (k/2)*profit;
    if(k%2==1){
        cookies++;
    }
    cout<<cookies<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		for (int j = 0; i+j <= s.size(); j++) {
			string now = s.substr(i, j);
			bool ok = true;
			rep(k, j) {
				char c = now[k];
				if(c!='A'&&c!='T'&&c!='G'&&c!='C') ok = false;
			}
			if (ok) ans = max(ans, j);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N);
    vector<P> p(M);
    for(int i=0; i<N; ++i) {
        cin >> a[i] >> b[i];
    }
    for(int i=0; i<M; ++i) {
        cin >> p[i].first >> p[i].second;
    }
    vector<int> res(N);
    for(int i=0; i<N; ++i) {
        int r = 0;
        int d = 1e9;
        for(int j=0; j<M; ++j) {
            int t = abs(a[i] - p[j].first) + abs(b[i] - p[j].second);
            if(d > t) {
                d = t;
                r = j;
            }
        }
        res[i] = r;
    }
    for(int i=0; i<N; ++i) {
        cout << res[i]+1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    REP(i, N)cin >> T[i];

    sort(ALL(T));
    int res = 0;
    int ptr = 0;
    while(ptr<N){
        res++;
        int go = T[ptr] + K;
        int cnt = 0;
        while(ptr < N && cnt < C && T[ptr] <= go){
            cnt++;
            ptr++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main {
	public void ci() {
		Scanner sc = new Scanner(System.in);
		int x0 = 0,y0 = 0;
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if(x - r >= 0) {
			if(y - r >= 0) {
				if(x + r - W <= 0) {
					if(y + r - H <= 0) {
						System.out.println("Yes");
					} else {
						System.out.println("No");
					}
				} else { 
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
	public static void main(String[] args) {
		new Main().ci();
	}
}

Measured memory_bytes: 17328
using System;

namespace Judge
{
    class Program
    {
        static void Main(string[] args)
        {
            string inD0 = Console.ReadLine();
            int N  = int.Parse(inD0);

            int cnt_AC = 0;
            int cnt_WA = 0;
            int cnt_TLE = 0;
            int cnt_RE = 0;


            for (int i = 0; i <= N - 1; i++)
            {
                string inD2 = Console.ReadLine();

                switch (inD2)
                {
                    case "AC":
                        cnt_AC++;
                        break;
                    case "WA":
                       cnt_WA++;
                        break;
                    case "TLE":
                        cnt_TLE++;
                        break;
                    case "RE":
                        cnt_RE++;
                        break;
                }


            }
            Console.WriteLine("AC x "+ cnt_AC);
            Console.WriteLine("WA x " + cnt_WA);
            Console.WriteLine("TLE x " + cnt_TLE);
            Console.WriteLine("RE x " + cnt_RE);

        }
    }
}


Measured memory_bytes: 30640
from sys import setrecursionlimit

def find(parent, i):
  t = parent[i]
  if t < 0:
    return i
  t = find(parent, t)
  parent[i] = t
  return t

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[j] += parent[i]
  parent[i] = j

setrecursionlimit(10**6)

N, M = map(int, input().split())
AB = [[int(c) - 1 for c in input().split()] for _ in range(M)]

parent = [-1]*N
inconvenience = N*(N-1) // 2
result = []
for a, b in AB[::-1]:
  result.append(inconvenience)
  pa, pb = find(parent, a), find(parent, b)
  if pa != pb:
    inconvenience -= parent[pa] * parent[pb]
  unite(parent, a, b)

for i in range(len(result)-1,-1,-1):
  print(result[i])

Measured memory_bytes: 43508
import java.util.Arrays;
import java.util.Scanner;

//Gather on the Clock
public class Main{

	int n;
	int[] a;
	int[][] dp;
	
	int get(int i, int j){
		if(i==j)return 0;
		if(dp[i][j]!=-1)return dp[i][j];
		if((i+1)%n==j)return dp[i][j]=Math.abs(a[i]-a[j]);
		int res = get(i, (j-1+n)%n) + Math.abs(a[i]-a[j]);
		int k = (i+1)%n;
		while(k!=j){
			res = Math.max(res, get(i, k)+get(k, j));
			k = (k+1)%n;
		}
		return dp[i][j] = res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			n = sc.nextInt();
			a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			dp = new int[n][n];
			for(int[]d:dp)Arrays.fill(d, -1);
			int res = 0;
			for(int i=0;i<n;i++)res=Math.max(res, get(i, (i-1+n)%n));
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
import math
import itertools
import statistics
#n = int(input())
#n, d = list(input().split())
n, m = list(map(int, input().split()))
s = []
c = []
for i in range(m):
    x,y = [int(j) for j in input().split()]
    s.append(x)
    c.append(y)

keta_min = [10]*n
keta_max = [-1]*n

if m==0:
    if n==1:
        print(0)
    elif n==2:
        print(10)
    else:
        print(100)
    exit()


for i in range(m):
    if keta_min[s[i]-1] > c[i]:
        keta_min[s[i]-1]=c[i]
    if keta_max[s[i]-1] < c[i]:
        keta_max[s[i]-1]=c[i]

#print(keta_min)
#print(keta_max)

for i in range(n):
    if keta_min[i]!=keta_max[i]:
        if keta_min[i]==10 and keta_max[i]==-1:
            if i!= 0:
                keta_min[i]=0
                keta_max[i]=0
            else:
                keta_min[i]=1
                keta_max[i]=1
        else:
            print(-1)
            exit()
    elif keta_min[0]==0 and keta_max[0]==0 and n!=1:
            print(-1)
            exit()

#print(keta_min)
#print(keta_max)

for i in range(n):
    print(keta_min[i], end="")



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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,K;
vector<int> A;
map<int, int> cnt;
int res;
int main() {
    cin >> N >> K;
    A.resize(N);
    for (auto &val : A){
        cin >> val;
        res = max(res, val);
        cnt[val]++;
        if (val == K){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if (res < K){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    for (int i = 0; i < N; i++){
        int val = abs(A[i] - K);
        if (cnt[val] >= 1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

   return 0;
 }


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int T,O;
  if (C%B == 0) {
    T = C/B;
  }
  else {
    T = C/B+1;
  }
  if (A%D == 0) {
    O = A/D;
  }
  else {
    O = A/D+1;
  }
  if (T <= O) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int N, M;
	string s[110], t[110];

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> s[i];

	cin >> M;
	for (int i = 0; i < M; i++)
		cin >> t[i];

	int sum, ans = 0;
	string x;
	for (int i = 0; i < N; i++){
		x = s[i];
		sum = 0;

		//青いカード
		for (int j = 0; j < N; j++){
			if (x == s[j]){
				sum++;
			}
		}

		//紅いカード
		for (int j = 0; j < M; j++){
			if (x == t[j]){
				sum--;
			}
		}

		ans = max(ans, sum);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            int[] a = new int[n];
            string[] input = getsplit();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }
            bool s = true;
            int count = 0;
            while (s)
            {
                s = false;
                for (int j = n-1; j > 0; j--)
                {
                    if (a[j]<a[j-1])
                    {
                        int k = a[j - 1];
                        a[j - 1] = a[j];
                        a[j] = k;
                        count++;
                        s = true; 
                    }
                }
            }
            for (int i = 0; i < n-1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine(a[n-1]);
            Console.WriteLine(count);
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
    }
}

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
typedef struct { double x,y;} point;

double nai(point a,point b){ return a.x*b.x+a.y*b.y; }

int main(){
point p1,p2;
double x,y;
cin>>x>>y;
p1.x=x;
p1.y=y;
cin>>x>>y;
p2.x=x;
p2.y=y;
point vec={p2.x-p1.x , p2.y-p1.y};
point e={vec.x/sqrt(nai(vec,vec)) , vec.y/sqrt(nai(vec,vec))};
int q;
cin>>q;
for(int i=0;i<q;i++){
cin>>x>>y;
point p;
p.x=x-p1.x;
p.y=y-p1.y;
printf("%0.9lf %0.9lf\n",p1.x+nai(p,e)*e.x,p1.y+nai(p,e)*e.y);


}
return 0;
}



Measured memory_bytes: 3292
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,j,i;
	char z[10000][10000];
	scanf("%d %d",&a,&s);
	for(i=0;i<a;i++)
		scanf("%s",z[i]);
	for(i=0;i<a*2;i++){
		d=i/2;
		for(j=0;j<s;j++){
			printf("%c",z[d][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2560
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cumsumA = [0] + list(accumulate(A))
    cumsumB = [0] + list(accumulate(B))

    res = 0

    for i in range(N+1):
        if i == 0:
            for j in range(M, -1, -1):
                if cumsumB[j] <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
        else:
            for j in range(max_j, -1, -1):
                time = cumsumA[i] + cumsumB[j]
                if  time <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51792
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long a,b,v,w,t;
int main()
{
	cin>>a>>v>>b>>w>>t;
	if(v<w){
		cout<<"NO";return 0;
	}
	if(abs(v-w)*t>=abs(a-b))cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 3624
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

bitset <4000010> w;

int main()
{
	int n;scanf("%d",&n);
	w[0]=1;int s=0;
	for (int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);w=w|(w<<x);s+=x;
	}
	for (int i=(s+1)/2;i<=s;i++) if (w[i]) {printf("%d\n",i);return 0;}
	return 0;
}



Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll N,M;
vector<vector<pair<ll,ll>>> graph;
vector<ll> table;

//dp
ll dp(ll n){
  if(n==N-1) return 0;
  if(table.at(n)>-INF) return table.at(n);
  
  table.at(n)++;
  for(auto p:graph.at(n)){
    ll to,cost;
    tie(to,cost)=p;
    chmax(table.at(n),dp(to)+cost);
  }
  
  return table.at(n);
}

int main()
{
  cin>>N>>M;
  graph=vector<vector<pair<ll,ll>>>(N,vector<pair<ll,ll>>(0));
  rep(i,M){
    ll a,b,c; cin>>a>>b>>c;
    graph.at(a).push_back({b,c});
  }
  
  //dp
  table=vector<ll>(N,-INF);
  cout<<dp(0)<<endl;
  return 0;
}



Measured memory_bytes: 3184
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int tx[] = {1,0};
int ty[] = {0,1};

int main(){
	int sum=0;
	string str;
	while(cin >> str){
		int n;
		scanf("%d",&n);
		int res=0;
		for(int i=0;i<n;i++){
			string tmp;
			cin >> tmp;
			for(int i=0;i<tmp.size();i++){
				string tmp2 = tmp;
				rotate(tmp2.begin(),tmp2.begin()+i,tmp2.end());
				if(tmp2.find(str) != string::npos){
					res++;
					break;
				}
			}
		}
		printf("%d\n",res);
	}
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int h, w;
int main(void){
    cin >> h >> w;
    rep(i, h) {
        string c;
        cin >> c;
        cout << c << endl << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

inline int max(int a,int b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

const int maxn=1e3+10;
int num[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int x;
	while(cin>>x)
		cout<<(x^1)<<endl;
	
	return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] v = new int[n];
    int[] c = new int[n];
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextInt();
    }
    for(int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
      if(v[i] > c[i]) ans += (v[i] - c[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
# 英小文字からなる文字列　S
# 入力される整数 K
# S の長さが K以下であれば、S をそのまま出力
# S の長さが Kをうわまってるならば、先頭K文字だけを切り出し、末尾に'...'を付加して出力
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[0:K] + '...')

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c;
int main() {
    cin >> a >> b >> c;
    if (c - b == b - a)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    bool ok = true;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x == 1) ok = false;
        if(x == cnt + 1) cnt++;
    }
    if(ok) cout << -1;
    else cout << n - cnt;
}

 
int main(){
    barsik;
    int q = 1;
    for(ll i = 1; i <= q; i++){
        solve();
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  int l[1010] = {}, r[1010] = {};
  int count = 0;
  scanf("%d", &N);
  for(int i = 1; i <= N; i++){
    scanf("%d%d", &l[i], &r[i]);
    count += r[i] - l[i] + 1;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;

struct State {
	int station, silver;
	long long time;
};
struct Edge {
	int to, cost, time; 
};
struct Exchange {
	int rate, time;
};

int main() {

	int n, m, s;
	cin >> n >> m >> s;

	s = min(s, 2500);
	vector<Edge> adj[50];
	for(int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		adj[u].push_back(Edge({ v, a, b }));
		adj[v].push_back(Edge({ u, a, b }));
	}

	vector<Exchange> exchanges(n);
	for(int i = 0; i < n; i++) {
		int c, d;
		cin >> c >> d;
		exchanges[i] = Exchange({ c, d });
	}

	vector<vector<long long>> min_time(n, vector<long long>(2501, oo));
	min_time[0][s] = 0ll;

	const auto comparator = [](const State &a, const State &b) {
		return a.time > b.time;
	};
	
	priority_queue<State, vector<State>, decltype(comparator)> pq(comparator);
	pq.push({ 0, s, 0ll });

	while(!pq.empty()) {
		State state = pq.top(); pq.pop();
		if(state.time != min_time[state.station][state.silver]) continue;

		//going to a different station
		for(Edge edge : adj[state.station]) if(edge.cost <= state.silver) { 
			if(min_time[edge.to][state.silver - edge.cost] > state.time + edge.time) {
				min_time[edge.to][state.silver - edge.cost] = state.time + edge.time;
				pq.push(State({ edge.to, state.silver - edge.cost, state.time + edge.time }));
			}
		}

		//doing a transaction here
		state.silver += exchanges[state.station].rate;
		state.time += exchanges[state.station].time;
		state.silver = min(state.silver, 2500);
		
		if(min_time[state.station][state.silver] > state.time) {
			min_time[state.station][state.silver] = state.time;	
			pq.push(State({ state.station, state.silver, state.time }));
		}
	}

	for(int i = 1; i < n; i++) {
		cout << *min_element(min_time[i].begin(), min_time[i].end()) << '\n';
	}

	return 0;
}

Measured memory_bytes: 6344
function main(input) {
    var args = input.split(' ');
    var N = parseInt(args[0], 10);
    var count = 0;
    for(var i = 1; i <= N ; i++) {
        if(String(i).length % 2 === 1) {
            count++;
        }
    }

    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
s = input()
p = input()
p_len = len(p)

if p in s:
    print("Yes")
else:
    for i in range(p_len):
        if (p[:i] == s[-i:]) and (p[i:] == s[:p_len - i]):
            print("Yes")
            break
    else:
        print("No")

Measured memory_bytes: 7492
def gcd(x,y):
    while y != 0:
        x, y = y, x%y
    return x
n = int(input())
a = [int(i) for i in input().split()]
ans = gcd(a[0],a[1])
for i in range(2,n):
    ans = gcd(ans,a[i])
print(ans)

Measured memory_bytes: 62832
x, y, a = 0, 0, 90
while s = gets
  r, aa = s.split(',').map(&:to_i)
  break if r == 0 && aa == 0
  x += r * Math.cos(a * Math::PI/180)
  y += r * Math.sin(a * Math::PI/180)
  a -= aa
end
puts x.to_i
puts y.to_i

Measured memory_bytes: 2408
import java.util.Scanner;

class Main{
	
	public static void main(String args[]){	
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i;
		String str = sc.next();
		
		for(i=0;i<n-1;i++){
			if((str.charAt(i) =='x') && (str.charAt(i+1) =='x'))break;
		}
		System.out.println(i+1);
	}	
}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	ll cnt = 0;
	for(int i = 1; i <= n; i++) {
		string s= to_string(i);
		if(s.length() & 1 )
			cnt++;
	}
	cout << cnt;
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y; C *= 2;
  long t;
  if(A + B <= C) t = A * X + B * Y;
  else if(A >= C && B >= C) t = max(X, Y) * C;
  else if(A >= C && B <= C) t = X * C + max(Y - X, 0) * B;
  else if(A <= C && B >= C) t = Y * C + max(X - Y, 0) * A;
  else if(A <= C && B <= C) t = min(X, Y) * C + max(X - Y, Y - X) * ((max(X - Y, Y - X) == X - Y) ? A : B);
  else t = -1;
  cout << t << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

struct Corr{
  ll y;
  ll x;
  ll depth;
};

vector<string> field;
queue<Corr> q;
vector<int> x_vec = {0, 0, +1, -1};
vector<int> y_vec = {+1, -1, 0, 0};

ll H, W; //height, width
ll s_y, s_x, g_y, g_x; //Start, Goal
ll y, x, depth; //現在位置

ll bfs(){
  while (!q.empty()){
    y = q.front().y, x = q.front().x, depth = q.front().depth; q.pop();
    if (y == g_y && x == g_x) return depth;
    for (int i = 0; i < 4; ++i){
      Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
      if (0 <= next.y && next.y < H && 0 <= next.x && next.x < W && field[next.y][next.x] == '.'){
        q.push(next);
        field[next.y][next.x] = 'x';
      }
    }
  }
  return 0;
}

int main(){
  cin >> H >> W;
  field.resize(H);
  rep(i, H) cin >> field[i];
  vector<string> tmp = field;

  ll ans = 0;
  for (int sy = 0; sy < H; ++sy){
    for (int sx = 0; sx < W; ++sx){
      for (int gy = 0; gy < H; ++gy){
        for (int gx = 0; gx < W; ++gx){
          Corr start = {sy, sx, 0};
          if (field[sy][sx] == '#') continue;
          queue<Corr>().swap(q);
          q.push(start);
          g_y = gy, g_x = gx;
          ll tmp_ans = bfs();
          //cout << sy << " " << sx << " " << gy << " " << gx << " " << tmp_ans << endl;
          ans = max(ans, tmp_ans);
          field = tmp;
        }
      }
    }
  }
  cout << ans << endl;
}


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

typedef pair<int,int> ii;

const int N = 100009;

int n, m;
ii a[N] = {};

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a[i].first, &a[i].second);
    }

    sort(a, a + m);
    int ans = 0, l = 0, rl = 0, rr = 1e9;
    while (l < m) {
        rl = a[l].first;
        if (a[l].first >= rr) {
            ans++;
            rr = 1e9;
        }
        rr = min(rr, a[l].second);
        l++;
    }

    printf("%d\n", ans + 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>;

int n;
void dfs(string str, char c) {
    if (str.size() == n) {
        cout << str << endl;
    } else {
        for (char ch='a'; ch<=c+1; ch++) {
            dfs(str+ch, max(c, ch));
        }
    }
    return;
}

int main() {
    cin >> n;
    dfs("", 'a'-1);
    return 0;
}


Measured memory_bytes: 1536
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
#define lowbit(x) ((x)&(-x))
#define hh putchar('\n')
#define kg putchar(' ')
using namespace std;
const int maxn=200005,mod=20101009;
int n,a[4],ans[maxn];
char s[maxn][4];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
signed main()
{	
	n=read();
	a[0]=read();a[1]=read();a[2]=read();
	int flag=0;
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
	{
		int x=s[i][1]-'A',y=s[i][2]-'A';
		if(a[x]<a[y])
			a[x]++,a[y]--,ans[i]=x;
		else if(a[y]<a[x])
			a[x]--,a[y]++,ans[i]=y;
		else
		{
			if(a[x]==1&&!a[3-x-y])
			{
				if(i==n||(s[i+1][1]!=3-x-y+'A'&&s[i+1][2]!=3-x-y+'A'))
				{
					a[x]--;
					a[y]++;
					ans[i]=y;
				}
				else
				{
					int x1=s[i+1][1]-'A',x2=s[i+1][2]-'A';
					if(x1==x||x2==x)
					{
						ans[i]=x;
						a[x]++;
						a[y]--;
					}
					else
					{
						ans[i]=y;
						a[x]--;
						a[y]++;
					}
				}
			}
			else
			{
				a[x]--;
				a[y]++;
				ans[i]=y;
			}
		}
		if(a[x]<0||a[y]<0)
		{
			flag=1;
			break;
		}
	}
	if(flag)
		puts("No");
	else
	{
		puts("Yes");
		for(int i=1;i<=n;i++)
			printf("%c\n",ans[i]+'A');
	}
	return 0;
}


Measured memory_bytes: 5044
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long N = long.Parse(Console.ReadLine());
        long M = N;
        long count = 0;
        long[,] dp = new long[63,3];
        dp[0,0] = 1;
        int i;
        for(i=1;i<63;i++){
            if(M <= 3){
                break;
            }
            M /= 2;
            if((N & ((long)(1) << (i - 1))) != 0){
                dp[i,0] = (2*dp[i-1,0] + dp[i-1,1]) % Define.mod;
                dp[i,1] = (dp[i-1,0] + 2*dp[i-1,1] + 2*dp[i-1,2]) % Define.mod;
                dp[i,2] = dp[i-1,2]; 
            }
            else{
                dp[i,0] = dp[i-1,0];
                dp[i,1] = (2*dp[i-1,0] + 2*dp[i-1,1] + dp[i-1,2]) % Define.mod;
                dp[i,2] = (dp[i-1,1] + 2*dp[i-1,2]) % Define.mod;
            }
        }
        if(M == 1){
            count = 2;
        }
        else if(M == 2){
            count = (4*dp[i-1,0] + 2*dp[i-1,1] + dp[i-1,2]) % Define.mod;
        }
        else{
            count = (5*dp[i-1,0] + 4*dp[i-1,1] + 2*dp[i-1,2]) % Define.mod;
        }
        sb.Append(count+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ok(n + 1, true);
    rep(i, 0, m) {
        int a;
        cin >> a;
        ok[a] = false;
    }

    ll dp[100050] = {};
    dp[0] = 1;
    rep(i, 0, n) {
        if (ok[i + 1]) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if (ok[i + 2]) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }
    
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 100001;
vector<vector<int>> mul(const vector<vector<int>>& A, const vector<vector<int>>& B){
  int n = A.size();
  vector<vector<int>> C(n, vector<int>(n));
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      for(int k = 0;k < n;k++)
        C[i][j] = (C[i][j] + 1ll * A[i][k] * B[k][j] % MOD) % MOD;
  return C;
}
vector<vector<int>> pow1(vector<vector<int>> A, ll p){
  if(p == 1)
    return A;
  if(p & 1)
    return mul(A, pow1(A, p - 1));
  return pow1(mul(A, A), p / 2);
}

int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  ll k;
  cin >> n >> k;
  vector<vector<int>> arr(n, vector<int>(n));
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      cin >> arr[i][j];
  arr = pow1(arr, k);
  ll res = 0;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      (res += arr[i][j]) %= MOD;
  cout << res;
  return 0;
}



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

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

  vector<string> image_a(n, string(""));
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    image_a[i] = str;
  }

  vector<string> image_b(m, string(""));
  for (int i = 0; i < m; i++) {
    string str;
    cin >> str;
    image_b[i] = str;
  }

  bool ans = false;
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool is_include = true;
      for (int y = 0; y < m; y++) {
        for (int x = 0; x < m; x++) {
          if (image_b[y][x] != image_a[i + y][j + x]) {
            is_include = false;
          }
        }
      }
      if (is_include) {
        ans = true;
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> rmq(n,
			   [](int a,int b){return min(a,b);}, //F to parents
			   [](int a,int b){return b;}, //G update num b to a
			   INT_MAX);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}



Measured memory_bytes: 3860
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll a, b;
    cin >> a >> b;
    if (a > 0) {
        cout << "Positive" << endl;
    } else if (b >= 0) {
        cout << "Zero" << endl;
    } else {
        if ((b - a) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll u_int64_t
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() {
	int n, m;
	cin >> n >> m;
	Graph G(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		G[a-1].push_back(b);
		G[b-1].push_back(a);
	}
	vector<int> flag(n, -1);
	queue<int> que;

	flag[0] = 0;
	que.push(1);

	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (auto nv : G[v-1]) {
			if (flag[nv-1] != -1) continue;

			flag[nv-1] = v;
			que.push(nv);
		}
	}
	rep(i, n) {
		if (flag[i] == -1) cout << "No" << endl;
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << flag[i] << endl;
	}
}

Measured memory_bytes: 10264
# サンプルを眺めてるとx,y,zぜんぶ同じ長さ（立方体）でいいんじゃないかという気がしてくる
# だがLが3の倍数でないときは？めんどくせぇしたぶん誤差内に入るやろってことでふつうに3で割って3乗したやつを出すことにしてみる
# これはべつに考察と呼べるものではない

l = int(input())
print((l / 3)**3)


Measured memory_bytes: 2940