akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 using namespace std;

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof(a))
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO

  
  int a[3];

  cin>>a[0]>>a[1]>>a[2];

  int sum=0;

  sort(a,a+3);

  sum=a[2]*10 + a[1]+ a[0];
  cout<<sum;

  timer();
  return 0;
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct List List;
struct List{
	List *next;
	List *prev;
	int val;
};

List list;

void initialize(){
	list.next = &list;
	list.prev = &list;
}

void insert(int x){
	//list ha val nasi
	List *p;
	p = (List*)malloc(sizeof(List));
	p->val = x;
	p->prev = &list;

	list.next->prev = p;
	p->next = list.next;
	list.next = p;
}

void delete(int x){
	List *p;
	for(p=list.next;p!=&list;p=p->next){
		if(p->val==x){
			p->prev->next = p->next;
			p->next->prev = p->prev;
			break;
		}
	}
}

void deleteFirst(){
	List *p;
	p = list.next;
	list.next = p->next;
	p->next->prev = &list;
}

void deleteLast(){
	List *p;
	p = list.prev;
	list.prev = p->prev;
	p->prev->next = &list;
}

void display(){
	List *p;
	for(p=list.next;p!=&list;p=p->next){
		printf("%d",p->val);
		if(p->next!=&list)printf(" ");
		else printf("\n");
	}
}

int main(){
	int i,n;
	char command[20];
	int x;
	initialize();
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",command,&x);
		if(!strcmp(command,"insert")){
			insert(x);
		}else if(!strcmp(command,"delete")){
			delete(x);
		}else if(!strcmp(command,"deleteFirst")){
			deleteFirst();
		}else if(!strcmp(command,"deleteLast")){
			deleteLast();
		}else{
			printf("no command\n");
		}
	}
	display();
}

Measured memory_bytes: 36156
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if (S == U) A--;
    else B--;
    printf("%d %d\n", A, B);
}

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

int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int counter = 0;
  X -= Z;
  while(X >= Y + Z){
    X -= Y + Z;
    counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int main() {
	int h, m, s;
	
	while (1) {
		cin >> h >> m >> s; if (h==-1 && m==-1 && s==-1) break;
		
		int sum = h*60*60 + m*60 + s;
		int rest = 120*60 - sum;
		
		int ah, am, as;
		ah = rest/3600;
		rest %= 3600;
		am = rest/60;
		rest %= 60;
		as = rest;
		
		printf("%02d:%02d:%02d\n", ah, am, as);
		
	 	sum *= 3;
	 	rest = 120*60*3 - sum;
		
		ah = rest/3600;
		rest %= 3600;
		am = rest/60;
		rest %= 60;
		as = rest;
		
		printf("%02d:%02d:%02d\n", ah, am, as);
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

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

		double r = Double.parseDouble(line);

		double a = (double) (r * r * Math.PI);
		double b = (double) (r * 2 * Math.PI);

		System.out.printf("%5f", a);
		System.out.print(" ");
		System.out.printf("%5f", b);

	}

}



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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 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; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1){}
  int root(int x) {
    if(d[x]<0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y){
    x = root(x); y=root(y);
    if(x==y) return false;
    if (d[x]>d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x)==root(y);}
  int size(int x) {return -d[root(x)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  
};

bool inc(char c){
  string AGCT = "AGCT";
  bool ans = false;
  rep(i, 4) if(c==AGCT[i]) ans = true;
  return ans;
}

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

  int ans=0;
  int cnt=0;
  int j=min(a,b);
  while(1){
    if(a%j==0 && b%j==0) {
      cnt++;
      if(cnt==k) {
	ans= j;
	break;
      }

    }
    j--;
	

  }
  
  cout << ans <<endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

string s[302];

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);  
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    int ans = 0;
    for (int iter = 0; iter < n; ++iter) {
        for (int i = 0; i < n; ++i) {
            rotate(s[i].begin(), s[i].begin() + 1, s[i].end());
        }

        bool fl = true;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                fl &= (s[i][j] == s[j][i]);
            }
        }

        ans += fl;
        
    }

    cout << ans * n << "\n";
}

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

int main(){
    int N;
    int X1,X2;
    cin >> N;
    X1 = (int)(N/1.08);
    X2 = X1 + 1;
    if(N == (int)(X1*1.08)){
        cout << X1 << endl;
    }else if(N == (int)(X2*1.08)){
        cout << X2 << endl;
    }else{
        cout << ":(" << endl;
    }

    return(0);
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> has_treat(n, false);

    int p, q;
    for(int i=0; i!=k; i++){
        cin >> p;
        for(int j=0; j!=p; j++){
            cin >> q;
            has_treat.at(q-1) = true;
        }
    }
    int out =0;
    for(const auto hi:has_treat)if(!hi) out++;
    cout << out << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int max(int a,int b){
	return a>b?a:b;
}

int min(int a,int b){
	return a>b?b:a;
}


int main(void){
	int i, j, q, n, x, y, w, h, cat_x, cat_y, ans;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d%d",&x,&y,&w,&h);
		scanf("%d",&n);
		ans = 0;
		for(i = 0;i < n;i++){
			scanf("%d%d",&cat_x,&cat_y);
			if(min(x,x + w) <= cat_x && cat_x <= max(x,x + w) && min(y,y + h) <= cat_y && cat_y <= max(y,y + h)){
				ans++;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main () {
  int count=0;
string a,b;
  cin>>a>>b;
  for(int i=0;i<3;i++){
    if(a[i]==b[i]){
     count++;
    }
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    ans = -1
    for last, first in ((0, 0), (0, 1), (1, 0), (1, 1)):
        vec = [0] * N
        vec[-1] = last
        vec[0] = first
        for i in range(N):
            if vec[i] == 0:
                if S[i] == 'o':
                    vec[(i + 1) % N] = vec[i - 1]
                else:
                    vec[(i + 1) % N] = 1 - vec[i - 1]
            else:
                if S[i] == 'o':
                    vec[(i + 1) % N] = 1 - vec[i - 1]
                else:
                    vec[(i + 1) % N] = vec[i - 1]

        if vec[-1] == last and vec[0] == first:
            ans = ''.join('S' if a == 0 else 'W' for a in vec)
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 11216
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)


struct Log{
	int t,n,m,s;
}lg[1000];
int numL;
int n,m;
int r,q;

int solve(int s,int e,int m){
	int res=0;
	int a=s,c=0;
	for(int i=0;i<r;i++){
		if(lg[i].m!=m)continue;
		if(lg[i].t<s){
			if(lg[i].s==1)c++;
			else c--;
			continue;
		}
		if(lg[i].t>=e){
			if(c)res += e-a;
			break;
		}
		if(lg[i].s==1){
			if(0==c++)a=lg[i].t;
		}else{
			if(0==--c){
				res += lg[i].t-a;
			}
		}
	}
	return res;
}
int main(){
	while(cin>>n>>m,n||m){
		cin>>r;
		for(int i=0;i<r;i++){
			Log &a=lg[i];
			cin>>a.t>>a.n>>a.m>>a.s;
		}
		cin>>q;
		while(q--){
			int s,e,m;
			cin>>s>>e>>m;
			cout<<solve(s,e,m)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
import math
n,k=map(int,input().split())
now=k
cnt=0 #割った回数
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) #最小値
    if now!=int(now):
        c=int(now) #最大値
    else:
        c=int(now)-1
    cnt+=1
    if b>min(k-1,n): #調べる最大値(K-1かNの小さいほう)が最小値より大きいとき
        now=a
        continue
    elif c>min(k-1,n): #最大値より小さいとき
        c=min(k-1,n) #最大値を補正
    ans+=1/(2**cnt)*(c-b+1)
    now=a
    if now==1:
        break
print(ans/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;++i)
using namespace std;

int main() {
    int N,R;
    cin >> N >> R;
    if(N >= 10){
        log(R);
    }else{
        log(R+100*(10-N));
    }
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    sort(all(A));
    if (n % 2) {
        vector<vector<int> > coef(2);
        rep(i, n / 2) coef[0].push_back(-2);
        rep(i, 2) coef[0].push_back(1);
        rep(i, n - 2 - n / 2) coef[0].push_back(2);

        rep(i, n - 2 - n / 2) coef[1].push_back(-2);
        rep(i, 2) coef[1].push_back(-1);
        rep(i, n / 2) coef[1].push_back(2);

        llong ans1 = 0, ans2 = 0;
        rep(i, n) ans1 += A[i] * coef[0][i], ans2 += A[i] * coef[1][i];

        cout << max(ans1, ans2) << endl;
    } else {
        vector<int> coef;
        rep(i, (n - 2) / 2) coef.push_back(-2);
        coef.push_back(-1), coef.push_back(1);
        rep(i, (n - 2) / 2) coef.push_back(2);

        llong ans = 0;
        rep(i, n) ans += A[i] * coef[i];

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
	string w, s;
	int count=0;
	
	cin >> w;
	transform( w.begin(), w.end(), w.begin(), ::tolower );
	
	while(1){
		cin >> s;
		if(s == "END_OF_TEXT") break;
		
		transform( s.begin(), s.end(), s.begin(), ::tolower );
		if(w == s) ++count;
	}
	
	printf("%d\n", count);	

	return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>

int main(){
    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if ((x + r <= w) && (x - r >= 0) && (y + r <= h) && (y - r >= 0)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

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

using namespace std;

int main(){
string s;

cin >> s;

int l = s.size();

int i  = 0;
  int first;
while(true){
	if(s[i] == 'A'){
		first = i;
		break;
	}
	i++;
}
int j = l-1,last;
while(true){
	if(s[j] == 'Z'){
		last = j;
		break;
	}
	j--;
}

cout << j-i+1 <<endl;
}

Measured memory_bytes: 640
/**
 * Created by hiramekun at 15:11 on 2019-09-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    vector<queue<ll>> v(n);
    rep(i, n) {
        rep(j, n - 1) {
            ll a;
            cin >> a;
            v[i].push(--a);
        }
    }

    queue<ll> next;
    ll res = n * (n - 1);
    ll ans = 0;
    bool plus = false;
    vector<bool> seen(n);

    rep(i, n) {
        if (v[i].empty()) continue;
        ll j = v[i].front();
        if (v[j].empty()) continue;
        if (!seen[j] && !seen[i] && v[j].front() == i) {
            seen[i] = seen[j] = true;
            v[i].pop(), v[j].pop();
            next.push(i), next.push(j);
            res -= 2;
            plus = true;
        }
    }
    if (plus) ans++;
    else {
        cout << -1 << '\n';
        return;
    }

    while (res > 0) {
        bool plus = false;
        vector<bool> seen(n);
        queue<ll> tmp;
        while (!next.empty()) {
            ll now = next.front();
            next.pop();

            if (v[now].empty()) continue;
            ll j = v[now].front();
            if (v[j].empty()) continue;

            if (!seen[j] && !seen[now] && v[j].front() == now) {
                seen[j] = seen[now] = true;
                v[j].pop(), v[now].pop();
                tmp.push(j), tmp.push(now);
                res -= 2;
                plus = true;
            }
        }
        if (!plus) {
            cout << -1 << '\n';
            return;
        }
        ans++;
        next = tmp;
    }

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

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int ans = 0,x;
    for(int i=0;i<n;i++){
    	cin >> x;
    	if(x>=k) ans++;
	}
	cout << ans << endl; 
    
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=set(map(int,input().split()))
b=set(map(int,input().split()))
c=1;N=0;M=0
for k in range(m*n,0,-1):
  if k in a and k in b:
    N+=1;M+=1
  elif k in a:
    c*=M;N+=1
  elif k in b:
    c*=N;M+=1
  else:
    c*=M*N-m*n+k
  c%=10**9+7
print(c)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

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

  cout << min(N%K, K-N%K) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

int main(void){
	ll x,y;
	cin>>x>>y;
	cout<<(abs(x-y)<=1?"Brown":"Alice")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
  int h,w;
  char c[101][101]={};
  int i,j;
  
  scanf("%d %d",&h,&w);
  
  for(i=0;i<h;i++)
  {
     scanf("%s",&c[i]);
   }
  
  
  for(i=0;i<2*h;i++)
  {
    for(j=0;j<w;j++)
    {
      printf("%c",c[i/2][j]);
    }
    printf("\n");
  }
  
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main(){
    char c[2][3];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            scanf("\n%c",&c[i][j]);
        }
    }

    for(int i = 0; i < 3; i++){
        int j = 2 - i;
        if(c[0][i] != c[1][j]){
        printf("NO\n");

        return 0;
        }
    }
    printf("YES\n");

    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int a = s.size();
  int count = 0;
  for(int i=0; i<a; i++){
    if (s.at(i) != t.at(i)){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
	int flag, count = 0;
	int i, n, tmp;
	int a[100];

	scanf("%d", &n);

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

	flag = 1;

	while (flag) {
		flag = 0;
		for (i = n - 1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				tmp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = tmp;
				flag = 1;
				count++;
			}
		}
	}

	for (i = 0; i < n; i++) {
		printf("%d", a[i]);
		if (i == n - 1) {
			printf("\n");
		}
		else {
			printf(" ");
		}
	}
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2140
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a = []
n.times do
  a.push(inp[0])
end
ans = 0
now = -1
a.size.times do |i|
  if(a[i] > (now + 1))
    p -1
    exit
  end
  now = a[i]
end
now = 0
a.size.times do |i|
  [i,1]
  if(a[i] == (now + 1))
    ans += 1
  else
    ans += [(a[i]),0].max
  end
  now = a[i]
end
p ans

Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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 INF = 10000000;
ll mod = 1000000007;//10^9+7


//番号ズレ注意！！
int main() {
    int N,L;
    cin>>N>>L;
    int taste[202];
    int app=-1;
    REP(i,N){
        taste[i]=L+i;
        if(taste[i]==0){app=i;}
    }
    if(app==-1){
        if(taste[0]>0){app=0;}
        else{app=N-1;}
    }
    int pie=-taste[app];
    REP(i,N){
        pie+=taste[i];
    }
    cout<<pie<<endl;

}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()

A = sorted(A, reverse=True)
ans = A[0]
A = A[1:]
i = 0

while i < N-2:
	ans += A[i//2]
	i += 1

print(ans)


Measured memory_bytes: 31572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int cnt;
vector<int> ch(10010);
vector<int> v[10010];

void dfs(int x, int p){
  ch[x] = cnt;
  cnt++;
  for(auto to:v[x]){
    if(to==p) continue;
    dfs(to,x);
  }
}

int main(){
  int n;
  cin >> n;
  
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  vector<P> c(n);
  int ans = 0;
  rep(i,n){
    cin >> c[i].F;
    c[i].S = i;
    ans += c[i].F;
  }
  sort(c.rbegin(),c.rend());
  ans -= c[0].F;

  cnt = 0;
  dfs(0,-1);

  cout << ans << endl;
  rep(i,n){
    cout << c[ch[i]].F << (i!=n-1?" ":"");
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[200005],t[200005];
ll dp[1005][1005];
bool flag,dame;
int main(){
	cin >> a >> b >> c >> n;
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			num = n - a * i - b * j;
			if(num % c == 0 && 0 <= num)ans++;
		}
	}

	p(ans);
	
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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; }
using namespace std;

signed main(void){
    
    int N; cin >> N;
    vector<int> s(N);
    rep(i, N)cin >> s[i];

    int step = N - 1, ans = 0;
    for(int i = 1; i <= step; i++){
        int tmp = 0;
        if(step % i == 0){
            for(int j = i; j <= step; j += i){
                int fr = j, ba = step - j;
                if(fr >= ba)break;
                chmax(ans, tmp += (s[fr] + s[ba]));
            }
        } else {
            for(int j = i; j <= step; j += i){
                int fr = j, ba = step - j;
                if(fr + i > step)break;
                chmax(ans, tmp += (s[fr] + s[ba]));
            }
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int H, W, N;
vector<string> g;
vector<vector<int>> dist;

void Bfs(int si, int sj, int gi, int gj) {
  queue<int> qi, qj;
  qi.push(si), qj.push(sj);
  dist[si][sj] = 0;

  while (!qi.empty() && !qj.empty()) {
    int i = qi.front(), j = qj.front();
    qi.pop(), qj.pop();

    int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
    for (int a = 0; a < 4; ++a) {
      int ni = i + di[a], nj = j + dj[a];
      if (ni < 0 || H <= ni || nj < 0 || W <= nj)
        continue;
      if (g[ni][nj] == 'X' || dist[ni][nj] != -1)
        continue;

      qi.push(ni), qj.push(nj);
      dist[ni][nj] = dist[i][j] + 1;
    }
  }
}

int main() {
  cin >> H >> W >> N;
  g.resize(H);
  for (int i = 0; i < H; ++i)
    cin >> g[i];

  int pi, pj;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      if (g[i][j] == 'S')
        pi = i, pj = j;

  int ans = 0;
  for (int a = 0; a < N; ++a) {
    dist.resize(H, vector<int>(W, -1));
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (g[i][j] == '1' + a) {
          Bfs(pi, pj, i, j);
          ans += dist[i][j];
          pi = i, pj = j;
        }
      }
    }

    dist.clear();
  }

  cout << ans << endl;
}


Measured memory_bytes: 7876
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+6;
struct permutain
{
    int a[N];
    permutain(){memset(a,0,sizeof a);}
    int& operator [](int x){return a[x];}
}p,q,ip,iq,A,B,ans;
int n,k;
permutain operator *(permutain a,permutain b){
    permutain c;
    for(int i=1;i<=n;i++)
        c[i]=a[b[i]];
    return c;
}
permutain inv(permutain a)
{
    permutain b;
    for(int i=1;i<=n;i++)
        b[a[i]]=i;
    return b;
}
permutain operator ^(permutain a,int b)
{
    permutain c;
    for(int i=1;i<=n;i++)
        c[i]=i;
    while(b){
        if(b&1)
            c=c*a;
        a=a*a;
        b>>=1;
    }
    return c;
}
void Print(permutain x)
{
    for(int i=1;i<=n;i++)
        printf("%d ",x.a[i]);
    puts("");
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&p[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&q[i]);
    ip=inv(p);
    iq=inv(q);
    int f=(k-1)/6,g=k-f*6;
    permutain h=q*ip*iq*p;
    A=h^f;
    if(g==1)
        B=p;
    else if(g==2)
        B=q;
    else if(g==3)
        B=q*ip;
    else if(g==4)
    {
        A=A*q;
        B=ip;
    }
    else if(g==5)
    {
        A=A*q*ip;
        B=iq;
    }
    else
    {
        A=A*q*ip;
        B=iq*p;
    }
    ans=A*B*inv(A);
    Print(ans);
}

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

long long int K;

template<size_t mx>
struct SnukeNumber{
    long long int ans[mx];
    long double a, b;

    constexpr long long int dsum(long long a){
        long long ret = 0;
        while(a){
            ret += a % 10;
            a /= 10;
        }
        return ret;
    }

    constexpr long double f(long long a){
        long long ret = dsum(a);
        return a / static_cast<long double>(ret);
    }

    constexpr SnukeNumber() : ans(), a(f(1)), b(){
        size_t cnt = 0;
        long long int s = 1, t = 1;
        for(long long int i = 1; cnt < mx; i += s){
            b = f(i + s);
            if(a < b){
                s = t;
                b = f(i + s);
            }
            if(a > b){
                if(s == t)t *= 10;
            }else{
                ans[cnt] = i;
                ++cnt;
            }
            long double tmp = a;
            a = b;
            b = tmp;
        }
    }
};

constexpr SnukeNumber<792> S = SnukeNumber<792>();

int main(){
    scanf("%lld", &K);
    for(int i = 0; i < K; ++i)cout << S.ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int s = stdIn.nextInt();
			if(s == 0)
			{
				break;
			}
			int t = stdIn.nextInt();
			Queue<Integer> que1 = new ArrayDeque<Integer>();
			Queue<Integer> que2 = new ArrayDeque<Integer>();
			boolean[] flag1 = new boolean[t + 1];
			boolean[] flag2 = new boolean[s + 1];
			int count1 = 0;
			int count2 = 0;
			if(s == 1)
			{
				++count1;
			}
			que1.add(1);
			while(!que1.isEmpty())
			{
				int n = que1.poll();
				if(n * 2 <= t && !flag1[n * 2])
				{
					flag1[n * 2] = true;
					que1.add(n * 2);
					++count1;
				}
				if(n * 3 <= t && !flag1[n * 3])
				{
					flag1[n * 3] = true;
					que1.add(n * 3);
					++count1;
				}
				if(n * 5 <= t && !flag1[n * 5])
				{
					flag1[n * 5] = true;
					que1.add(n * 5);
					++count1;
				}
			}
			que2.add(1);
			while(!que2.isEmpty())
			{
				int n = que2.poll();
				if(n * 2 < s && !flag2[n * 2])
				{
					flag2[n * 2] = true;
					que2.add(n * 2);
					++count2;
				}
				if(n * 3 < s && !flag2[n * 3])
				{
					flag2[n * 3] = true;
					que2.add(n * 3);
					++count2;
				}
				if(n * 5 < s && !flag2[n * 5])
				{
					flag2[n * 5] = true;
					que2.add(n * 5);
					++count2;
				}
			}
			System.out.println(count1 - count2);
		}
	}
}

Measured memory_bytes: 12000
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.next());
		}
		System.out.println(set.size()==3 ? "Three" : "Four");
	}
}


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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m],cnt[n+1] = {};
  for (int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    cnt[a[i]] += 1;
    cnt[b[i]] += 1;
  }
  for (int i = 1; i <= n; i++){
    cout << cnt[i] << '\n';
  }
  return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int max = -999999999;
		for(int i = 0; i < n; ++i)
		{
			int sum = 0;
			for(int j = i; j < n; ++j)
			{
				sum += Vec[j];
				if(sum > max)
				{
					max = sum;
				}
			}
		}
		cout << max << endl;
	}
}

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

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

const int maxn = 3e5+5;

char a[maxn];
int n;

int main() {
	// ios::sync_with_stdio(false);
	// cin.tie(0);
	
	scanf("%s",a+1);
	int len=strlen(a+1);
	int pos=1,ans=0;
	while(pos<=len){
		if(a[pos] == a[pos-1]){
			if(pos>=len) 
				ans--;
			pos+=2;
			a[pos-1] = 0;
			ans++;
		}
		else{
			pos++;
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

fee = 0
day = 1
if N < K:
    fee = N*X
else:
    while day <= K:
        fee += X
        day += 1
    while K < day <= N:
        fee += Y
        day += 1
    

print(fee)


Measured memory_bytes: 3064
N, M = map(int, input().split())

N, M = min(N, M), max(N, M)

if M-N >= 2:
  print(0)
  exit()
  
frac = [1]*(M+1)
for i in range(M):
  frac[i+1] = frac[i] * (i+1) % 1000000007
  
if M-N == 1:
  ans = frac[M] * frac[N] % 1000000007
  print(ans)
else:
  ans = 2 * frac[M] * frac[M] % 1000000007
  print(ans)
  

Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	string S;	cin>>S;
	rep(i,0,S.size()){
		int d=S[i]-'A';
		d+=N;
		d%=26;
		S[i]='A'+d;
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

int N;
int a[101010];
int zero, one, two;

signed main()
{
    cin >> N;
    REP(i,N) {
        cin >> a[i];
        if (a[i] % 4 == 0) {
            two++;
        } else if (a[i] % 2 == 0) {
            one++;
        } else {
            zero++;
        }
    }

    if (two < zero - 1) {
        cout << "No" << endl;
        return 0;
    }

    if (zero - 1 == two) {
        if (one > 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
h = LIST()

INF = 10**23
dp = [INF] * N

dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1],
                abs(h[i]- h[i-2]) + dp[i-2])

print(dp[-1])

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

#define fastIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define asc(s) sort(s.begin(), s.end())
#define des(s) sort(s.rbegin(), s.rend())
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define rev(v) reverse(v.begin(), v.end())
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define precision(x, p) fixed << setprecision(p) << x
#define set_bits(n) __builtin_popcount(n);
#define mod 1000000007
#define PI 3.14159265358979
typedef long long ll;

#ifndef ONLINE_JUDGE
#define debug(x) cout << x << endl;
#else
#define debug(x)
#endif

template <class T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) { return a * b / gcd(a, b); };

vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string> beg(buf), end;
    vector<string> list(beg, end);
    return list;
}

bool isvowel(char c)
{
    string s = "aeiou";
    if (find(s.begin(), s.end(), c) != s.end())
        return true;
    return false;
}

bool cmp(pair<int, int> &a, pair<int, int> &b)
{
    return a.second > b.second || (a.second == b.second && a.first > b.first);
}

bool isprime(ll n)
{
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
            return false;

    return true && (n != 1);
}

void solve()
{
    int k, x;
    cin >> k >> x;

    for (int i = x - k + 1; i < k + x; i++)
        cout << i << ' ';
}

int main()
{
    fastIO

        int t = 1;
    // cin>>t;

    for (int test_case = 1; test_case <= t; test_case++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
def main(sbj:str,n:int):
    ans =sbj[0]
    if ans!="1":
        return int(ans)
    counter=0
    for i in range(len(sbj)):
        if sbj[i]=="1":
            counter += 1
            if counter >=n:
                return 1
        else:
            return int(sbj[i])
sbj = input()
n =int(input())
print(main(sbj,n))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl "\n"
const int N=101005;
using namespace std;
ll w[105],n;
ll v[105],memo [105][N];
ll W;
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>W;
    int ans=0;
    for(int i=0;i<n;++i)
    cin>>w[i]>>v[i];
    for(int i=0;i<=n;++i)
        for(int j=0;j<100003;++j)
             memo[i][j]=2e9;

            memo[0][0]=0;
            memo[0][v[0]]=w[0];
    for(int i=1;i<n;++i)
    {
        for(int j=0;j<100003;++j)
        memo[i][j]=memo[i-1][j];
       for(int j=0;j<100003;++j)
              memo[i][j+v[i]]=min(memo[i-1][j]+w[i],memo[i][j+v[i]]);
    }

    for(int i=0;i<=n;++i)
        for(int j=0;j<100003;++j)
        if((memo[i][j]<2e9)&&(memo[i][j]<=W))
            ans=max(ans,j);
  cout<<ans;

}



Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	ll ans=0;
	priority_queue<pll>pq;
	rep(i,a){
		int x;
		cin>>x;
		pq.push(pll(x,0));
	}
	rep(i,b){
		int x;
		cin>>x;
		pq.push(pll(x,1));
	}
	rep(i,c){
		int x;
		cin>>x;
		pq.push(pll(x,2));
	}
	int r=0,g=0,cnt=0;
	while(cnt<x+y){
		pll p=pq.top();
		pq.pop();
		if(p.se==2){
			ans+=p.fi;
			cnt++;
		}
		else if(p.se==0&&r<x){
			ans+=p.fi;
			r++;
			cnt++;
		}
		else if(p.se==1&&g<y){
			ans+=p.fi;
			g++;
			cnt++;
		}
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 10348
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll l, r;
	cin >> l >> r;
	r = min(r, l + 2019);
	ll ans = 2018;
	for (ll i = l; i <= r; i++) {
		for (ll j = i + 1; j <= r; j++) {
			ll x = i * j % 2019;
			ans = min(ans, x);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int A,B,C,ans,a,b,c;
  cin>>A>>B>>C;
  ans=0;
  for(int i=0;i<101;i++){
    if(A%2==1||B%2==1||C%2==1){
      cout<<ans<<endl;
      return 0;
    }
    else{
      a=B/2+C/2;
      b=A/2+C/2;
      c=A/2+B/2;
      A=a;
      B=b;
      C=c;
      ans++;
    }
    if(i==100){
      cout<<-1<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int W,H,x,y,r;

scanf("%d %d %d %d %d %d",&W,&H,&x,&y,&r);

if( r <= x && r <= y && x + r <= W && y + r <= H)
 printf("Yes\n");

else
 printf("No\n");

return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define div div_
const int maxn = 200200, mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int pwr(long long a, long long b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
int div(int a, int b){
	return mul(a, pwr(b, mod - 2));
}
int fat[maxn], ifat[maxn];
void init(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(i, fat[i - 1]);
	ifat[maxn - 1] = pwr(fat[maxn - 1], mod - 2);
	for(int i = maxn - 2; i >= 0; i--) ifat[i] = mul(i + 1, ifat[i + 1]);
	for(int i = 0; i < maxn; i++) assert(mul(fat[i], ifat[i]) == 1);
}
int ncr(int n, int r){
	if(n < r) return 0;
	return mul(fat[n], mul(ifat[r], ifat[n - r]));
}
int main(){
	init();
	int n, a, b, c; cin >> n >> a >> b >> c;
	int ans = 0, den = a + b;
	a = mul(a, pwr(den, mod - 2));
	b = mul(b, pwr(den, mod - 2));
	c = mul(100, pwr(100 - c, mod - 2));
	for(int i = n; i < 2 * n; i++){
		int tk_win = mul(ncr(i - 1, n - 1), mul(pwr(a, n), pwr(b, i - n)));
		int ao_win = mul(ncr(i - 1, n - 1), mul(pwr(b, n), pwr(a, i - n)));
		int dr = mul(i, c);	
		ans += mul(ao_win, dr);
		if(ans >= mod) ans -= mod;
		ans += mul(tk_win, dr);
		if(ans >= mod) ans -= mod;
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> h(n);
	for(int i=0;i<n;i++){cin>>h[i];}
	h[0]--;
	for(int i=1;i<n;i++){
		if(h[i-1]>h[i]){
			cout<<"No"<<endl;
			return 0;
		}
		else if(h[i-1]<h[i])h[i]--;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll a[1000000]={0};
 ll x,y,z,k;
 ll mx=sqrt(n+1)+1;
 ll m;
 //pr(mx);
 //rep(i,0,n*2)a[i]=0;
 rep(x,1,mx+1){
  rep(y,1,mx+1){
   rep(z,1,mx+1){
    m=x*x+y*y+z*z+x*y+y*z+z*x;
    a[m]++;
   }
  }
 }
 rep(i,1,n+1)pr(a[i]);
return 0;}

Measured memory_bytes: 11368
n = int(input())
s = input()

cnt = 0
ans = 0
for i in s:
    if i == 'A':
        cnt = 1
        # print(cnt)
    elif i == 'B' and cnt == 1:
        cnt = 2
        # print(cnt)
    elif i == 'C' and cnt == 2:
        cnt = 3
        # print(cnt)
    else:
        cnt = 0
    if cnt == 3:
        ans += 1

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int d[6],e[6];

void N()
{
  int tmp=d[0];
  d[0]=d[1];
  d[1]=d[5];
  d[5]=d[4];
  d[4]=tmp;
}
void E()
{
  int tmp=d[0];
  d[0]=d[3];
  d[3]=d[5];
  d[5]=d[2];
  d[2]=tmp;
}
void S()
{
  int tmp=d[0];
  d[0]=d[4];
  d[4]=d[5];
  d[5]=d[1];
  d[1]=tmp;
}
void W()
{
  int tmp=d[0];
  d[0]=d[2];
  d[2]=d[5];
  d[5]=d[3];
  d[3]=tmp;
}
void T()
{
  int tmp=d[1];
  d[1]=d[2];
  d[2]=d[4];
  d[4]=d[3];
  d[3]=tmp;
}

bool C()
{
  bool ans=0;
  for (int i = 0; i < 4; ++i)
  {
    bool f=1;
    for (int j = 0; j < 6; ++j) if(d[j]!=e[j]) f=0;
    if(f) ans=1;
    T();
  }
  return ans;
}

int main(){
  bool f=0;
  for (int i = 0; i < 6; ++i) cin>>d[i];
  for (int i = 0; i < 6; ++i) cin>>e[i];
  f=C();
  if(!f) N(),f=C();
  if(!f) S();S(),f=C();
  if(!f)
  {
    N();
    for (int i = 0; i < 4; ++i) 
    {
      E();
      f=C();
      if(f) break;
    }
  }
  cout<<(f?"Yes\n":"No\n");
}


Measured memory_bytes: 3100