akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

	    String a= gs();
	    String b= gs();
	    String c= gs();

        System.out.print(a.toUpperCase().substring(0,1)+b.toUpperCase().substring(0,1)+c.toUpperCase().substring(0,1));
//        if (b-a==c-b) {
//        	System.out.print("YES");
//        }else{
//        	System.out.print("NO");
//        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 39188
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)


Measured memory_bytes: 28436
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <math.h>

#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define vec vector

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

int main() {
  string s;
  cin >> s;
  say(string(s.length(), 'x'));
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

template<class T, class B, class...V>struct Vec {
  typedef Vec<T, V...>A; typedef vector<typename A::t>t; t nvec(B a, V...b) { return t(a, A().nvec(b...)); }
};
template<class T, class B>struct Vec<T, B> { typedef vector<T>t; t nvec(B a) { return t(a); } };
template<class T>tuple<T>Init(T t) { return tuple<T>(t); }
template<class T, class C>struct Vec<T, tuple<C>> { using t = T; T nvec(tuple<C> a) { return get<0>(a); } };
template<class T = int, class...B> typename Vec<T, B...>::t nvec(B...b) { return Vec<T, B...>().nvec(b...); }


vector<vector<int>> v;

void Calc() {


  int n, m;
  in, n, m;

  v = nvec((int) pow(2, n), 0);
  rep(i, m) {
    int a, b;
    in, a, b;
    a--, b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (auto& i : v) {
    sort(all(i));
  }
  auto dp = nvec(n+1, 1 << n);
  dp[1][1] = 1;
  rep(i, 1, 1 << n) {
    rep(j, n) rep(k, n) {
      if ((i & (1 << k)) == 0) {
        if (std::find(all(v[j]), k) != v[j].end()) {
          dp[k+1][i | (1 << k)] += dp[j+1][i];
        }
      }
    }
  }
  err(dp);

  int cnt = 0;
  for (auto& i : dp) {
    cnt += i[(1 << n) - 1];
  }
  cout <<  cnt<< endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long;
int main()
{
    int n,k;
    cin>>n>>k;
    if(k==1)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<n-k<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long K){
    vl a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[K-1]<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
}


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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    ll M = 1;
    while( N > 0 ){
        if(N / 10 == 0){
            break;
        }
        N /= 10;
        M++;
    }
    return M;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}


// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n);
    for(ll i=0;i<n;++i){
        cin>>x[i];
    }

    ll ans = INF;
    for(ll i=0;i<110;++i){
        ll flag = 0;
        for(ll j=0;j<n;++j){
            flag += pow(x[j] - i, 2);
        }
        ans = min(ans, flag);
    }
    cout<<ans<<endl;

    return 0;
}

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

#define MOD 998244353
#define MAX 100000

int N;
long long A[MAX];

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

	sort( A, A + N );
	long long ans = 1;
	for( long long i = 0; i < N; i++ ) {
		ans = ans * __gcd( A[i], i ) % MOD;
	}

	cout << ans << endl;

	return 0;
}


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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x%2==1 && i%2==1)cnt++;
	}
	cout<<cnt;
}


Measured memory_bytes: 3592
n,k=gets.split.map(&:to_i)
s=$*.tap{gets.each_char.with_index{|c,i|c!=$a&&$*<<[c.hex,i];$a=c}}
p s.map.with_index{|(a,b),i|(s[i+2*k+a]&.[](1)||n)-b}.max

Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int al,bl,i,j;
  string a,b;
  cin>>a>>b;
  al=a.length();
  bl=b.length();
  string kotae[2][bl+1];
  for(i=0;i<bl+1;i++){
    kotae[0][i]="";
  }
  for(i=0;i<al;i++){
    for(j=-1;j<bl;j++){
      if(j==-1){
        kotae[1][j+1]="";
      }else if(a[i]==b[j]){
        kotae[1][j+1]=kotae[0][j]+a[i];
      }else if(kotae[0][j+1].length()>kotae[1][j].length()){
        kotae[1][j+1]=kotae[0][j+1];
      }else{
        kotae[1][j+1]=kotae[1][j];
      }
    }
    for(j=0;j<bl+1;j++){
      kotae[0][j]=kotae[1][j];
    }
  }
  cout<<kotae[0][bl];  
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;
    for (char &c : s) {
        if (c == ',') c = ' ';
    }

    cout << s << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    if(N == 1) PR(0);
    else {
        vec L(N, 0), R(N, 0);
        REP(i,0,N) {
            for(ll j=i-1; j>=0; --j) {
                if(A[j] < A[i]) ++L[i];
            }
            REP(j,i+1,N) {
                if(A[i] > A[j]) ++R[i];
            }
        }
        ll sumL = 0, sumR = 0;
        REP(i,0,N) {
            sumL = (sumL + L[i]) % MOD;
            sumR = (sumR + R[i]) % MOD;
        }
        sumL = (sumL * (((K * (K-1)) / 2) % MOD)) % MOD;
        sumR = (sumR * (((K * (K+1)) / 2) % MOD)) % MOD;
        PR((sumL+sumR)%MOD);
    }
    
    return 0;
}

/*



*/

Measured memory_bytes: 3600
from math import ceil
def gcd(a,b):
  while b:
    a,b = b,a%b  
  return a

def lcm(a,b):
  return a*b//gcd(a,b)  
  
n,m = map(int,input().split())
A = list(map(int,input().split()))

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()

if n == 1:
  ans = A[0]
else:
  ans = lcm(A[0],A[1])  
  for i in range(n-2):  
    if ans > m:
      print(0)
      exit()
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))  

Measured memory_bytes: 14892
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N;
    scanf("%lld", &N);

    vector<ll> A(N);
    ll ans = 0;
    scanf("%lld", &A[0]);
    for (ll i = 1; i < N; i++)
    {
        scanf("%lld", &A[i]);
        ll dif = max(A[i - 1] - A[i], (ll)0);
        A[i] += dif;
        ans += dif;
    }

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


Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
using namespace std;
int dp[21111];
int c,n,m;
main()
{
	cin>>c>>n>>m;
	for(int i=0;i<n;i++)
	{
		int s,p;cin>>s>>p;
		for(int j=c;j>=0;j--)dp[j+s]=max(dp[j+s],dp[j]+p);
	}
	for(int i=1;i<=m;i++)cout<<dp[c/i]*i<<endl;
}



Measured memory_bytes: 3172
class DisjointSet():
    def __init__(self, n):
        self._p = [x for x in range(n)]
        self._size = [-1 for x in range(n)]
        self._rank = [0 for x in range(n)]
    
    def find(self, p):
        while p != self._p[p]:
            p = self._p[p]
        return p

    def union(self, p, q):
        pp, qq = self.find(p), self.find(q)
        if pp != qq:
            if self._rank[pp] > self._rank[qq]:
                self._p[qq] = pp
                self._rank[pp] += 1
                self._size[pp] += self._size[qq]
            else:
                self._p[pp] = qq
                self._rank[qq] += 1
                self._size[qq] += self._size[pp]
    
    def size(self, p):
        return self._size[self.find(p)]


n, m = [int(x) for x in input().split()]
b =  [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
b.reverse()
r = []
t = n*(n-1)//2
ds = DisjointSet(n)
for q, p in b:
  r.append(t)
  qq, pp = ds.find(p), ds.find(q)
  if pp != qq:
    t -= ds.size(pp) * ds.size(qq)
  ds.union(p, q)
for x in reversed(r):
  print(x)

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

int main() {

  int a,b,c,d,e,f;

  while( cin >> a >> b >> c >> d >> e >> f ) {

    double x = 1.00;
    if ( ( c*e - f*b ) * ( a*e - d*b ) != 0 ) {
      x = x * ( c*e - f*b ) / ( a*e - d*b );
    }else {
      x = 0.00;
    }
    double y = 1.00;
    if ( ( c*d - f*a ) * ( b*d - e*a ) != 0 ) {
      y = y * ( c*d - f*a ) / ( b*d - e*a );
    }else {
      y = 0.00;
    }

    cout << fixed << setprecision(3) << x << " " << y << endl;

  }

  return 0;

}

Measured memory_bytes: 1236
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x>=1800){
            System.out.println(1);
        }else if (x>=1600){
            System.out.println(2);
        }else if (x>=1400){
            System.out.println(3);
        }else
        if (x>=1200){
            System.out.println(4);
        }else
        if (x>=1000){
            System.out.println(5);
        }else
        if (x>=800){
            System.out.println(6);
        }else
        if (x>=600){
            System.out.println(7);
        }else
        if (x>=400){
            System.out.println(8);
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> r(N);
  
  for (int i=0; i<N; i++){
    string s;
    int a;
    cin >> s >> a;
    r.at(i) = make_tuple(s, a, i+1);
  }

  vector<pair<int, int>> win(N);
  
  for (int i=0; i<N; i++){
    int count=0;

    for (int j=0; j<N; j++){
      if (i==j){
        continue;
      }
      
      if (get<0>(r.at(i)) == get<0>(r.at(j))){        
        if (r.at(i)<r.at(j)){
          count++;
        }
      }
      else { 
        if (r.at(i)>r.at(j)){
          count++;
        }
      }
    }
    int b;
    tie(ignore, ignore, b) = r.at(i); 
    win.at(i) = make_pair(count, b);
  }
    
  sort(win.begin(), win.end());
  
  for (int i=0; i<N; i++){
    int b;
    tie(ignore, b) = win.at(i);
    cout << b << endl; 
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int A, B, T;
  scanf("%d%d%d",&A,&B,&T);
  int ans=0;
  for(int i=A; i<T+0.5; i+=A){
    ans += B;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1e6+10;
int a[MAXN];
int main(){
    int n,k;
    while(~scanf("%d %d",&k,&n)){
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        int mx=k-a[n]+a[1];
        for(int i=2;i<=n;i++){
            mx=max(mx,a[i]-a[i-1]);
        }
        printf("%d\n",k-mx);
    }
    return 0;
}


Measured memory_bytes: 1024
alpha = "abcdefghijklmnopqrstuvwxyz"
A = ["a"]+[i for i in alpha[::-1]]
s = list(input())
k = int(input())
n = len(s)
for i in range(n):
    if s[i] == "a":
        continue
    j = A.index(s[i])
    if j <= k:
        s[i] = "a"
        k -= j
    if k == 0:
        print("".join(s))
        exit()
else:
    k %= 26
    l = alpha.index(s[-1])
    if l + k <= 25:
        s[-1] = alpha[k+l]
    else:
        s[-1] = alpha[k+l-26]
    print("".join(s))

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);
const ld E=2.71828182845904523536;

int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    ll n,ans=0,q;
    cin>>n;

    for(ll i=1;i<ceil(sqrt(n));i++)
        if(n%i==0) {
            q=n/i -1;
            if(n/q==n%q)
                ans+=q;
        }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x)  for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
inline void read(int &x){
	x=0;char ch=getchar();int f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}x*=f;
}
inline void judge(){
	freopen("table.in","r",stdin);
	freopen("table.out","w",stdout);
}
const int maxn=100005;
typedef long long i64;
int num,n,m,head[maxn],t[maxn<<1],ne[maxn<<1],v[maxn<<1];
inline void addedge(int x,int y,int z){
	ne[++num]=head[x];head[x]=num;t[num]=y;v[num]=z;
}
bool vis[maxn];
int cnt[4],d[maxn],T;
bool godie=0;
inline void dfs(int x,int l){
	vis[x]=1;d[x]=l;cnt[l]++;
	forE(i,x)if(!vis[t[i]]){
		dfs(t[i],(l+v[i])%3);T++;
	}else{
		if((l+v[i])%3!=d[t[i]])godie=1;T++;
	}
}i64 ans=0;
int main(){
	read(n);read(m);
	rep(i,1,n)head[i]=-1;
	rep(i,1,m){
		int x,y;read(x);read(y);
		addedge(x,y,1);
		addedge(y,x,2);
	}
	rep(i,1,n){
		if(vis[i])continue;memset(cnt,0,sizeof(cnt));godie=0;T=0;
		dfs(i,0);i64 sum=cnt[0]+cnt[1]+cnt[2];
		if(godie){
			ans+=sum*sum;continue;	
		}else{
			if(cnt[0]&&cnt[1]&&cnt[2]){
				ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[0]*cnt[2]+1ll*cnt[1]*cnt[2];
			}else{
				ans+=T/2;
			}
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
                {
                    if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
                        cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;


return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535
 
int main() 
{
    FAST;
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y;
    return 0;
}

Measured memory_bytes: 256
# 深さdの現実的な上限を先に決める
N = int(input())
# Aは，葉として残す必要があるものの数
A = list(map(int, input().split()))

# 深さdのノード数の上限
limit = [1]  # ルートのノードの上限数 : 当然1
for d in range(1, N+1):
    if d == N:  # 1番深いところの上限はA[N]
        limit.append(A[d])
    else:
        limit.append((limit[-1]-A[d-1])*2)
        # limit[-1] < A[d-1]の場合，葉を確保することができていない
        if limit[-1] < 0:
            print(-1)
            exit()

# Nが0の時の処理
if N == 0:
    if A[0] != 1:
        print(-1)
        exit()

# 1番深いところから構築して最後にsumを取る
ans = [limit[-1]]
# 1番深いところから構築しており，今現在のオードの数
now_node = limit[-1]
for d in range(N-1, -1, -1):
    # limitは深さが浅いところから押さえつけながら構築したと考える
    ans.append(min(now_node+A[d], limit[d]))  # now_nodeは深さd+1のノードの数, 今は深さdの部分の構築をしている
    now_node = ans[-1]  # 現在のノードの数

# 構築したものに対してジャッジする
ans.reverse()
for d in range(N):
    if (ans[d]-A[d])*2 < A[d+1]:  # 1つ深い部分の葉を構築するだけの労力を確保できているかどうか
        print(-1)
        exit()
print(sum(ans))


Measured memory_bytes: 707824
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let a: Vec<usize> = vec(n, |_| scan(tokens));
    let sum: usize = a.iter().sum();
    let mut x: usize = sum;
    let mut r: Vec<usize> = vec![0; n];
    loop {
        while sum % x != 0 {
            let y = (sum + x - 1) / x;
            x = sum / y;
        }
        for i in 0..n {
            r[i] = a[i] % x;
        }
        r.sort();
        let mut i = 0;
        let mut j = n - 1;
        let mut cnt = 0;
        while i < j {
            r[j] += r[i];
            cnt += r[i];
            i += 1;
            while r[j] >= x {
                r[j - 1] += r[j] % x;
                j -= 1;
            }
        }
        if cnt <= k {
            println!("{}", x);
            return;
        }
        x -= 1;
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;
int main()
{
    short n;
    cin >> n;

    for(int i = 1; ; i++)
    {
        if (pow(2, i) > n)
        {
            cout << pow(2, i-1) << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  vector<bool> dp(k+1,false);
  for(int j=a[0];j<=k;++j){
      bool flag=false;
      rep(i,n){
          if(j<a[i])break;
          if(!dp[j-a[i]])flag=true;
      }
      dp[j]=flag;
  }
	if(dp[k]){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
  return 0;
}


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

int main (){
  int K,N;
  cin >> K >> N;
  vector<int>A(N);
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  L.at(0)=A.at(0)+K-A.at(N-1);
  int max=L.at(0);
  for(int i=1;i<N;i++){
    L.at(i)=A.at(i)-A.at(i-1);
    if(max<L.at(i)){
      max=L.at(i);
    }
  }
  cout << K-max << endl;
}


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

Measured memory_bytes: 596
#include<cstdio>
#define ll long long
#include<map>
using namespace std;
map<ll,ll>m;
ll t,n,a,b,c,d;
inline ll dfs(ll x){
	if(x==1)return d;
	if(x==0)return 0;
	if(m[x])return m[x];
	m[x]=(ll)min((__int128)1e16,(__int128)x*d);
	if((x&1)==0)m[x]=min(m[x],min(dfs(x/2-1)+a+2*d,dfs(x/2)+a));
	else m[x]=min(m[x],min(dfs(x/2)+a+d,dfs(x/2+1)+a+d));
	if(x%3==0)m[x]=min(m[x],min(dfs(x/3-1)+b+3*d,dfs(x/3)+b));
	else m[x]=min(m[x],min(dfs(x/3)+b+(x%3)*d,dfs(x/3+1)+b+(3-x%3)*d));
	if(x%5==0)m[x]=min(m[x],min(dfs(x/5-1)+c+5*d,dfs(x/5)+c));
	else m[x]=min(m[x],min(dfs(x/5)+c+(x%5)*d,dfs(x/5+1)+c+(5-x%5)*d));
	return m[x];
}
int main(){
	for(scanf("%lld",&t);t;--t)
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d),
		m.clear(),printf("%lld\n",dfs(n));
	return 0;
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vec;
typedef vector< vec > mat;
map < mat , int > d;

int solve(mat A){
  queue< mat > Q;
  Q.push(A);
  

    
  d[A]=1;
  while(!Q.empty()){
    mat a=Q.front();Q.pop();
   
    bool f=true;
    
    for(int i=0;i<4;i++){
      for(int j=0;j<8;j++){
        if(a[i][j]!=0&&i*10+10+j+1!=a[i][j]){
          f=false;
        }
      }
    }
    if(f)return d[a]-1;

    for(int i=0;i<4;i++){
      for(int j=1;j<8;j++){
        if(a[i][j]!=0)continue;
        
        mat b=a;
        int c=a[i][j-1]+1;

        int h=-1,w;
        for(int k=0;k<4;k++){
          for(int l=0;l<8;l++){
            if(b[k][l]==c){
              h=k,w=l;
            }
          }
        }

        if(h==-1)continue;

        swap(b[h][w],b[i][j]);

        if(d[b]==0){
          d[b]=d[a]+1;
          Q.push(b);
        }
      }
    }

  }
  return -1;
}

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    d.clear();
    mat A(4, vec(8) );
    for(int i=0;i<4;i++){
      A[i][0]=i*10+10+1;
      for(int j=0;j<7;j++){
        cin>>A[i][j+1];
        if(A[i][j+1]%10==1)A[i][j+1]=0;
      }
    }
    cout<<solve(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 25832
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'o') {
      c++;
    }
  }
  cout << 700 + c * 100 << endl;
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void dfs(int pos, LL sum);

vector<int> tree[SIZE];
LL counter[SIZE];
int visit[SIZE];

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

    int n;
    int q;
    cin >> n >> q;
    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree[a].pb(b);
        tree[b].pb(a);

    }

    while(q--) {
        int p, x;
        cin >> p >> x;
        counter[p] += x;

    }

    dfs(1, 0);
    for(int i = 1; i <= n; ++i) cout << counter[i] << " ";
    cout << endl;

    return 0;
}

void dfs(int pos, LL sum) {
    if(visit[pos]) return;
    visit[pos] = true;
    counter[pos] += sum;

    for(int i = 0; i < tree[pos].size(); ++i) {
        dfs(tree[pos][i], counter[pos]);

    }

    return;
}


Measured memory_bytes: 25088
#include <stdio.h>
int main(void)
{
	int a,b,c,d,e,f=0;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a>0)f=(b-a)*e;
	else if(a<0)f=(0-a)*c+d+b*e;
	else f=d+b*e;
	printf("%d\n",f);
	return 0;
}


Measured memory_bytes: 1996
#include <iostream>
using namespace std;
long long n, a, b, c, d, x, y;
int main() {
	cin>>n>>a>>b>>c>>d;
	n--;
	for(int i=n; i>=0; i--) {
		x = i*c - (n-i)*d + a;
		y = i*d - (n-i)*c + a;
		if(x<=b && b<=y) {cout<<"YES"; return 0;}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int N;scanf("%d",&N);
	printf("%d",N*N*N);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int partition(int* a, int p, int r)
{
    int x = a[r];
    int i = p-1;
    for(int j=p; j<r; j++){
        if(a[j] <= x){
            i++;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
    }
    int tmp = a[i+1];
    a[i+1] = a[r];
    a[r] = tmp;
    return i+1;
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int index = partition(a, 0, n-1);
    for(int i=0; i<n; i++){
        if(i == index){
            cout << "[" << a[i] << "]";
        }else{
            cout << a[i];
        }
        if(i != n-1) cout << " ";
        else cout << endl;
    }
}


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


int main() {
	// your code goes here
	ll i,j,k,n,m,t, inc = 0;
	cin>>n;
	if(n%2 == 0 || n%5==0){
	    cout<<"-1\n";
	    return 0;
	}
	k = 0;
	while(k < n){
	    k = k* 10+7;
	    inc += 1;
	}
	
	for(int i=0;i<=1000000;i++){
	    k%=n;
	    if(k == 0) {
	        cout<<inc + i<<"\n";
	        return 0;
	    }
	    k = (k * 10 + 7);
	}
	cout<<"-1\n";
	
	
	
	
	return 0;
}


Measured memory_bytes: 3604
# https://beta.atcoder.jp/contests/abc050/tasks/abc050_b


def solve():
    _ = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    for _ in range(M):
        total = 0
        P, X = map(int, input().split())
        for index, time in enumerate(T):
            if index + 1 == P:
                total += X
            else:
                total += time

        print(total)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

#define int long long 

const int mod = 1e9+7;

vector< vector< int > > dp(2009, vector< int > (2009,-1));

int comb(int k, int n){
	if(k < 0 || n < 0 || k > n) return 0;
	if(k == 0 || (n == k)) return 1;
	if(dp[k][n] != -1) return dp[k][n];
	return dp[k][n] = (comb(k-1,n-1)+comb(k,n-1))%mod;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	
	for(int i = 1; i <= k; i++){
		cout << comb(i-1,k-1)*comb(n-k-i+1,n-k+1)%mod << endl;
	}
}


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

using namespace std;

int main(void) {
  int n;
  cin >> n;

  int sum = 0, cn = n;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  cout << (cn % sum == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean ans = false;
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (i*j == N) ans = true;
            }
        }
        System.out.println(ans? "Yes": "No");
    }
}

Measured memory_bytes: 23892
/* ex7_3
   masaaki52	*/
#include <stdio.h>
#include <stdlib.h>
int main(void){
  //rblack,cblackは各行・列の＃数を数える配列
  int row,column,i,j,rblack[100]={0},cblack[100]={0};
  char **matrix;
  scanf("%d %d",&row,&column);
  //各行の配列へのポインタ分のメモリ領域を確保
  matrix = (char**)calloc(row,sizeof(char*));
  if(matrix == NULL){
    exit(1);
  }
  //各行の要素分のメモリ領域を確保
  for(i=0;i<row;i++){
    matrix[i] = (char*)calloc(column,sizeof(char));
    if(matrix[i] == NULL){
      exit(1);
    }
  }
  for(i=0;i<row;i++){//matrix内全てに
    for(j=0;j<column;j++){
      scanf(" %c",&matrix[i][j]);//.#の入力
      if(matrix[i][j] == '#'){//matrix内のあるマスが#のとき
        rblack[i] += 1;//配列rblackの、＃のあった行番目に＋１
        cblack[j] += 1;//配列cblackの、＃のあった列番目に＋１
      }
    }
  }
  for(i=0;i<row;i++){//matrix内の全マス目について
    for(j=0;j<column;j++){
      if(rblack[i] != 0 && cblack[j] != 0){//そのマスのある行と列のどちらにも＃があれば
        printf("%c",matrix[i][j]);//マスの値を出力
      }
    }
    if(rblack[i] != 0){//ある行が全て.でなければ
      printf("\n");//改行
    }
  }
  //メモリ領域の開放。各行の要素分の領域を開放し、
  //各行の配列へのポインタの領域を開放（メモリ領域の確保と逆順）
  for(i=0;i<row;i++){
    free(matrix[i]);
  }
  free(matrix);
  
  return 0;
}

Measured memory_bytes: 1632
#include<iostream>
#include<map>

#define ALP 26 //????£??????°????????§

using namespace std;

typedef struct{
	char index; //????£????
	int mat[2]; //???????\¨??°[0]??????????????§???????\¨??°[1]
}calset;

int main() {
	int n;
	char c;
	char gomi; //???????????¨
	calset cal[ALP] = {0}; //?????????????????????

	int tmp0, tmpj;
	int max0, max1;
	max0 = max1 = 0;

	while (1) {
		cin >> n;
		if (n == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> c;
			for (int j = 0; j < ALP; j++) {
				if (cal[j].index == 0) { //??°??????????£??????????
					cal[j].index = c;
					cal[j].mat[0]++;
					break;
				}
				else if (cal[j].index == c) { //???????\¨??°????????±??´??°
					cal[j].mat[0]++;
					break;
				}
			}
			//mat[1]????????±??´??°&mat[0]????????§???????±???????
			for (int j = 0; j < ALP; j++) {
				tmp0 = cal[j].mat[0];
				cal[j].mat[1] = tmp0 + (n - i - 1);

				if (max0 < tmp0) {
					max0 = tmp0;
					tmpj = j;
				}
			}
			//mat[0]????????§???????£??????\?????§mat[1]????????§??¨????????????????±???????
			for (int j = 0; j < ALP; j++) {
				if (j == tmpj) continue;
				if (max1 < cal[j].mat[1]) {
					max1 = cal[j].mat[1];
				}
			}
			if (max0 > max1) { //???????\¨??¨?????????????????????tmpj??????????\¨??°???????????????????¢?
				cout << cal[tmpj].index << " " << (i + 1) << endl;

				for (int j = n; j > (i + 1); j--) {
					cin >> gomi; //??\????????????
				}
				break; //?¬??????\??????
			}

			if (i == (n - 1)) { //???????????§?±???????????????£?????´???
				cout << "TIE" << endl;
			}
			//?????????
			max0 = max1 = 0;
		}
		//???????????????????????´??????????????????
		max0 = max1 = 0;
		for (int i = 0; i < ALP; i++) {
			cal[i] = { 0 }; //????????????????????????
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

vector<ll> s, t;
vector<pair<ll, ll> > st;
ll A, B, Q;

ll calc(pair<ll, ll> p){
  if(p.second == 0){
    ll right = distance(t.begin(), upper_bound(ALL(t), p.first));
    ll left = right-1;
    return min(t[right] - p.first, p.first - t[left]);
  }
  else{
    ll right = distance(s.begin(), upper_bound(ALL(s), p.first));
    ll left = right-1;
    return min(s[right] - p.first, p.first - s[left]);
  }
}

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  cin >>A >> B >> Q;
  s.resize(A); t.resize(B);
  rep(i, A) cin >> s[i];
  rep(j, B) cin >> t[j];
  s.push_back(LLINF);
  s.push_back(-LLINF);
  t.push_back(LLINF);
  t.push_back(-LLINF);

  sort(ALL(s));
  sort(ALL(t));
  rep(i, Q){
    ll x; cin >> x;
    ll tr = distance(t.begin(), upper_bound(ALL(t), x));
    ll tl = tr - 1;
    ll t1 = t[tr] - x + calc({t[tr], 1});
    ll t2 = x - t[tl] + calc({t[tl], 1});
    if(t1 < 0) t1 =LLINF;
    if(t2 < 0) t2 =LLINF;
    // DEBUG(t[tr]);
    // DEBUG(t[tl]);
    // DEBUG(t1);
    // DEBUG(t2);

    ll sr = distance(s.begin(), upper_bound(ALL(s), x));
    ll sl = sr - 1;
    ll s1 = s[sr] - x + calc({s[sr], 0});
    ll s2 = x - s[sl] + calc({s[sl], 0});
    ll ans = LLINF;
    if(s1 < 0) s1 =LLINF;
    if(s2 < 0) s2 =LLINF;
    // DEBUG(s[sr]);
    // DEBUG(s[sl]);
    // DEBUG(s1);
    // DEBUG(s2);
    ans = min(min(t1, t2), min(s1, s2));
    cout << ans << endl;
  }
}  


Measured memory_bytes: 2912
import numpy as np
from numba import njit
def main():
    R, C, K = map(int, input().split())
    field = np.full((R+1,C+1), 0, dtype='int64')
    dpt = np.full((R+1,C+1,4), 0, dtype='int64')
    for i in range(K):
        r, c, v = map(int, input().split())
        field[r][c] = v
    dp(R, C, field, dpt)
    print(max(dpt[-1][-1]))

@njit('i4(i4,i4,i8[:,:],i8[:,:,:])', cache=True)
def dp(R, C, field, dpt):
    for r in range(1, R+1):
        for c in range(1, C+1):
            for taken in range(4):
                max_v = 0
                if taken == 0:
                    max_v = max(dpt[r-1][c])
                    max_v = max(dpt[r][c-1][0], max_v)
                elif taken == 1:
                    max_v = max(dpt[r][c-1][taken-1] + field[r][c],
                                dpt[r][c-1][taken],
                                max(dpt[r-1][c]) + field[r][c])
                else:
                    max_v = max(dpt[r][c-1][taken-1] + field[r][c],
                                dpt[r][c-1][taken])
                dpt[r][c][taken] = max_v
    return 1

if __name__ == '__main__':
    main()


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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

ll solve(int i,int w,int n,vector<int>&wts,vector<int>&vals)
{
    if(i==n) return 0;

    ll skip_current = solve(i+1,w,n,wts,vals);

    ll add_current = INT_MIN;
    if(wts[i] <= w)
    {
        add_current = vals[i] + solve(i+1,w-wts[i],n,wts,vals);
    }

    return max(skip_current,add_current);
}


int main()
{
	FASTIO; 

    int n,w;
    cin>>n>>w;

	vector<int> val(n);
    vector<int> wts(n);

    for(int i = 0;i<n;i++)
    {
        cin>>wts[i]>>val[i];
    }

    // Recusive
    // cout<<solve(0,w,n,wts,val);

    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));

    for(int i = n-1;i>=0;i--)
    {
        for(int wt = w;wt>=0;wt--)
        {
            ll skip_current = dp[i+1][wt];

            ll add_current = INT_MIN;
            if(wts[i] <= wt)
            {
                add_current = val[i] + dp[i+1][wt-wts[i]];
            }

            dp[i][wt] = max(skip_current,add_current);
        }
    }

    cout<<dp[0][w];
}

Measured memory_bytes: 80384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    ll N,M;
    cin>>N;

    ll ans=0ll;
    ans+=N/500ll*1000ll;

    ans+=(N%500ll)/5ll*5ll;

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
/*　単一始点最短経路問題　*/
#include <stdio.h>
#include <limits.h>


#define MAX_V 100    /*　最大頂点数　*/
#define BLACK 1
#define GRAY  2
#define WHITE 0
#define NIL -1


void dijkstra(int, int);


typedef struct{

  int k;                  /* その頂点はk個の他の頂点と繋がりを持つ　*/
  int adj[MAX_V];         /*　隣接する各頂点の番号　*/
  int w[MAX_V];           /*　隣接する各頂点とをつなぐ有向辺の重み　*/
}VERTEX;


int color[MAX_V];
int pi[MAX_V];
int d[MAX_V];             /*　d[i]　頂点sから頂点iまでの最短経路上の辺の重みの総和　*/
VERTEX G[MAX_V];          /*　有向グラフG　*/

int main()
{
  int i, j, u, n;

  /* G, color, pi, dを初期化　*/
  for( i = 0; i<MAX_V; i++ )
    {
      color[i] = WHITE;
      pi[i]    = NIL;
      d[i]     = INT_MAX;
      for( j = 0; j<MAX_V; j++ )
	G[i].adj[j] = NIL;
    }
  
  scanf("%d", &n);
  for( i = 0; i<n; i++ )
    {
      scanf("%d", &u);
      scanf("%d", &G[u].k );

      for( j = 0; j<G[u].k; j++ )
	scanf("%d%d", &G[u].adj[j], &G[u].w[j] );
    }

  dijkstra(0, n);

  /* 各頂点の番号iと距離d[i]を表示　*/
  for( i = 0; i<n; i++ )
    printf("%d %d\n", i, d[i] );
  
  return 0;
}


/* ダイクストラ法を用いて単一始点最短経路のコストを求める関数　
　　引数 s: 始点となる頂点の番号　n: 与えられた有向グラフの頂点数　*/
void dijkstra(int s, int n)
{
  int i, j, u, t, mincost;

  d[s] = 0;
  pi[s] = NIL;
  color[s] = GRAY;
  
  while(1)
    {
      mincost = INT_MAX;
      u = NIL;
      
      for( i = 0; i<n; i++ )
	{
	  if( color[i] != BLACK && d[i] < mincost )
	    {
	      mincost = d[i];
	      u = i;
	    }
	}

      if( mincost == INT_MAX )
	break;

      color[u] = BLACK;

      for( i = 0, j = G[u].adj[i]; i<G[u].k; j = G[u].adj[++i] )
	{
	  if( color[j] != BLACK && G[u].w[j] != INT_MAX )
	    {
	      if( d[j] > G[u].w[i] + d[u] )
		{
		  d[j]  = d[u] + G[u].w[i];
		  color[j] = GRAY;
		  pi[j] = u;
		}
	    }
	}
    }
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
ll dp[100100];
ll n,w;
ll s[101][3];


int main(){

    cin>>n>>w;
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&s[i][0],&s[i][1]);
        for(int i=0;i<=100010;i++)
            dp[i]=1e12;
        dp[0]=0;
        for(int i=0;i<n;i++)
        {
            for(int j=100010;j>=1;j--)
                if(j-s[i][1]>=0)
                dp[j]=min(dp[j],dp[j-s[i][1]]+s[i][0]);
        }
        ll ans=0;
        for(ll i=0;i<=100010;i++)
        {
            if(dp[i]<=w)
                ans=max(ans,i);
        }
        cout<<ans;
}


Measured memory_bytes: 1024
def main():
    INF = float('inf')
    N, M = map(int, input().split())
    dp = [INF for _ in range(2**N)]
    dp[0] = 0
    for i in range(M):
        a, _ = map(int, input().split())
        *C, = map(int, input().split())
        open_bit = 0
        for i in C: open_bit |= 1 << i-1
        for i in range(2**N): dp[i|open_bit] = min(dp[i|open_bit], dp[i] + a)
    print(dp[-1] if dp[-1] != INF else -1)
if __name__ == '__main__':
    main()

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

using namespace std;

int main() {


    long long int n;

    cin >> n;

    string ans = "";

    while(n != 0){
        if(n % 2 != 0){
            n--;
            ans = "1" + ans;
        }
        else{
            ans = "0" + ans;
        }

        n /= -2;
    }
    
    if(ans == ""){
        ans = "0";
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  string s;
  cin>>s;
  unsigned long long sum=0;
  for(unsigned long long i=0;i<s.size();i++){
    sum+=s.at(i)-'0';
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int gcd[250][250];

int gcd1(int a, int b) {
	while (b) {
		a %= b;
		swap (a, b);
	}
	return a;
}
void solve(){
    for(int i = 1; i <= 240; ++i) {
        for(int j = 1; j <= 240; ++j) {
            gcd[i][j] = gcd1 (i, j);
        }
    }
    int m;
    cin >> m;
    ll ans = 0;
    for(int i = 1; i <= m; ++i) {
        for(int j = 1; j <= m; ++j) {
            for(int k = 1; k <= m; ++k) {
                ans += gcd[gcd[i][j]][k];
            }
        }
    }
    cout << ans;
} 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;

const int N = 100005;

int n, f[N];
vector<int> g[N];

void dfs(int u, int fa) {
  for (auto v : g[u]) {
    if (v != fa) {
      dfs(v, u);
      f[u] ^= f[v] + 1;
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf ("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 1);
  puts(f[1] ? "Alice" : "Bob");
  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    map<int, int> mp;

    rep(i, n) {
        int d;
        cin >> d;
        mp[d]++; 
    }

    int m;
    cin >> m;
    rep(i, m) {
        int t;
        cin >> t;
        if(mp[t] == 0) {
            cout << "NO" << endl;
            return 0;
        }
        mp[t]--;
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600