akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <limits>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define lli long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define mem(data_structure, val) memset(data_structure, val, sizeof(data_structure))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
const ll mod = 1e9+7;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
um<pii, int, hash_pair> map_with_pair{};
priority_queue <int, vector<int>, greater<int> > pq_desc; // decreasing order

const int N = 101;
const int W = 1e5+1;
lli dp[N][W];

lli knapsack1(int idx, lli n, lli w, pll *items) {
	// cout << idx << " " << n << " " << w << endl;
	if(idx >= n || w<=0) return 0;
	if(dp[idx][w] != -1) return dp[idx][w];
	lli ans = 0;
	ans = max(ans, knapsack1(idx+1, n, w, items));
	if(w-items[idx].F >= 0)
		ans = max(ans, items[idx].S+knapsack1(idx+1, n, w-items[idx].F, items));
	return dp[idx][w] = ans;
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	mem(dp, -1);

	lli n, w;
	cin >> n >> w;

	pll items[n];
	fo(i, n) {
		cin >> items[i].F >> items[i].S;
	}

	lli ans = knapsack1(0, n, w, items);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 79232
/*
  AOJ 2663
  Title:RUPC
  @kankichi573
  2015/8/15 WA 3/43
*/
#include <stdio.h>
int N,M;
int a[1000001];
long long runsum[1000001],c;
int b[300000];
main()
{
  int i,p,ret;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&p);
      a[p]++;
    }
  for(i=1;i<=1000000;i++)
    runsum[i] = runsum[i-1]+i*a[i];
  /*    
  for(i=0;i<=5;i++)
    printf("%2d|",a[i]);
  printf("\n");
  for(i=0;i<=5;i++)
    printf("%2d|",runsum[i]);
  printf("\n");
  */
  scanf("%d",&M);
  for(i=0;i<M;i++)
    scanf("%d",&b[i]);
  for(i=ret=0;i<M;i++)
    {
      scanf("%lld",&c);
      //printf("%lld %lld|",c,runsum[b[i]]);
      if(c<=runsum[b[i]])
	printf("Yes\n");
      else
	printf("No\n");
    }
  return(0);
}

Measured memory_bytes: 13472
//
//  main.cpp
//  A - Parking
//
//  Created by wenhan on 2017/12/3.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}
	
int main(){
	init();
	ll N,W;
	cin>>N>>W;
	vector<ll>w(N);
	vector<ll>v(N);
	ll base_w;
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
		if(i==0)base_w=w[i];
		w[i]-=base_w;
		//cout<<w[i]<<endl;
	}
	
	ll dp[N+1][N+1][3003];
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<3003;k++){
				dp[i][j][k]=-1;
			}
		}
	}
	dp[0][0][0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<3003;k++){
				if(dp[i][j][k]==-1)continue;
				//use i
				dp[i+1][j+1][k+w[i]]=
				max(dp[i+1][j+1][k+w[i]],dp[i][j][k]+v[i]);
				
				//not use 
				dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
			}
		}
	}
	ll ans=0;
	for(int j=0;j<=N;j++){
		for(int k=0;k<3003;k++){
			if(base_w*j+k<=W)ans=max(dp[N][j][k],ans);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 239616
let inf = 1 lsl 47

let n = read_int()
let m = n - 1

let vec = Array.make n []

let rec read_graph i =
  if i < m then (
    let u, v, w = Scanf.scanf " %d %d %d" (fun u v w -> u - 1, v - 1, w) in
    vec.(u) <- (v, w) :: vec.(u);
    vec.(v) <- (u, w) :: vec.(v);
    read_graph (i + 1)
  )

let shortest_path s =
  let d = Array.make n inf in
  d.(s) <- 0;
  let rec dfs = function
    [] -> ()
  | u :: stack ->
      let rec update stack = function
        [] -> stack
      | (v, w) :: rest ->
          if d.(v) < inf then update stack rest
          else (
            d.(v) <- d.(u) + w;
            update (v :: stack) rest
          ) in
      dfs (update stack vec.(u)) in
  dfs [s];
  d

let () =
  read_graph 0;
  let q, k = Scanf.scanf " %d %d" (fun q k -> q, k - 1) in
  let d = shortest_path k in
  let rec query i =
    if i < q then (
      let x, y = Scanf.scanf " %d %d" (fun x y -> x - 1, y - 1) in
      Printf.printf "%d\n" (d.(x) + d.(y));
      query (i + 1)
    ) in
  query 0


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

const int mod = 1e9+7;
const int maxn = 2e5+10;

ll c[2][maxn];

ll qpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1)
            res = res*a%mod;
        a = a*a%mod;
        b >>= 1;
    }
    return res;
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    c[0][0] = c[1][0] = 1;
    for(int i=1; i<=n; i++) {
        if(i<=n-1)
            c[0][i] = c[0][i-1]*(n-i)%mod*qpow(i, mod-2)%mod;
        c[1][i] = c[1][i-1]*(n-i+1)%mod*qpow(i, mod-2)%mod;
    }
    k = min(k, n-1);
    ll ans = 0;
    for(int i=n-k; i<=n; i++)
        ans = (ans+c[0][i-1]*c[1][i]%mod)%mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    bool flg[20000] = {};

    for (int i = 0; i * i < 20000; ++i) {
        flg[i * i] = 1;
    }

    int x[n][d];

    REP (i, n) {
        REP (j, d) {
            scanf("%d", &x[i][j]);
        }
    }

    int cnt = 0;
    REP (i, n) {
        FOR (j, i + 1, n) {
            int dist = 0;
            REP (k, d) {
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if (flg[dist]) cnt++;
        }
    }

    OUT(cnt);

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,y,a;
  scanf("%d%d",&x,&y);
  if(y < x){
    a=x;
    x=y;
    y=a;
  }
  a=x%y;
  while(a != 0){
    x=y;
    y=a;
    a=x%y;
   
  }
  printf("%d\n",y);
  return 0;
}



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

int main()
{
	int n,m,i,cnt=0;
	scanf("%d%d",&n,&m);
	vector<int>h(n+1);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	vector<int>c[n+1];
	for(i=1;i<=m;i++)
	{
		int p,q;
		scanf("%d%d",&p,&q);
		c[p].push_back(h[q]);
		c[q].push_back(h[p]);
	}
	for(i=1;i<=n;i++)
	{
		sort(c[i].rbegin(),c[i].rend());
	}
	for(i=1;i<=n;i++)
	{
		if(c[i].size()==0)
		{
			cnt++;
		}
		else
		{
			if(c[i][0]<h[i])
			{
				cnt++;
			}
		}
	}
	printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 8860
// 5/8 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    string S;
    cin >> S;

    rep(i, S.size()) cout << 'x';

    cout << endl;
}


Measured memory_bytes: 256
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq
import string

setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
town=[]
for i in range(n):
    p,g=stdin.readline().rstrip().split()
    town.append((p,int(g),i+1))
town.sort(key=lambda x:(x[0],-x[1]))
for i in town:
    print(i[2])

Measured memory_bytes: 38768
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_ADDR = 1000000000;

/* typedef */

struct Range {
  int i0, i1;	// [i0, i1)
  int id;
  Range() {}
  Range(int _i0, int _i1, int _id): i0(_i0), i1(_i1), id(_id) {}
  bool operator<(const Range& r0) const { return i1 < r0.i1; }
  void print() const { printf("(%d,%d)=%d\n", i0, i1, id); }
};

typedef set<Range> sr;
typedef vector<Range> vr;
typedef map<int,vr> mivr;

/* global variables */

sr sctrs, blnks;
mivr dir;

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    sctrs.clear();
    blnks.clear();
    dir.clear();

    sctrs.insert(Range(0, MAX_ADDR + 1, -1));
    blnks.insert(Range(0, MAX_ADDR + 1, -1));
    
    while (n--) {
      char op;
      int l, s, p;

      cin >> op;
      if (op == 'W') {
	cin >> l >> s;
	//printf("W: %d %d\n", l, s);
	
	while (s) {
	  sr::iterator bit = blnks.begin();
	  Range r = *bit;
	  sr::iterator sit = sctrs.find(r);
	  int rsz = r.i1 - r.i0;

	  if (s >= rsz) {
	    r.id = l;
	    blnks.erase(bit);
	    sctrs.erase(sit);
	    dir[l].push_back(r);
	    sctrs.insert(r);
	    s -= rsz;
	  }
	  else {
	    Range r1(r.i0, r.i0 + s, l);
	    r.i0 += s;
	    blnks.erase(bit);
	    sctrs.erase(sit);
	    dir[l].push_back(r1);
	    blnks.insert(r);
	    sctrs.insert(r1);
	    sctrs.insert(r);
	    s = 0;
	  }
	}
      }
      else if (op == 'D') {
	cin >> l;
	//printf("D: %d\n", l);

	vr& dirl = dir[l];
	for (vr::iterator vit = dirl.begin(); vit != dirl.end(); vit++) {
	  sr::iterator sit = sctrs.find(*vit);
	  Range r = *sit;
	  sctrs.erase(sit);

	  r.id = -1;
	  blnks.insert(r);
	  sctrs.insert(r);
	}
	dirl.clear();
      }
      else {
	cin >> p;
	//printf("R: %d\n", p);

	sr::iterator sit = sctrs.upper_bound(Range(p, p, -1));
	cout << sit->id << endl;
      }

      if (false) {
	cout << "blnks: ";
	for (sr::iterator bit = blnks.begin(); bit != blnks.end(); bit++)
	  bit->print();
	cout << "sctrs: ";
	for (sr::iterator sit = sctrs.begin(); sit != sctrs.end(); sit++)
	  sit->print();
      }
    }

    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 30824
#include<stdio.h>
#include<string.h>
int main()
{
	char s[15];
	scanf("%s",&s);
	int n=strlen(s);
	int f=1;
	if(s[0]!='A')
	f=0;
	if(s[1]=='C'||s[n-1]=='C')
	f=0;
	int sumc=0,sumall=0;

	for(int i=1;i<n;i++)
	{
		if(s[i]=='C')
		sumc++;
		if(s[i]>='A'&&s[i]<='B'||s[i]>='D'&&s[i]<='Z')
		sumall++;
	}
	if(f==1&&sumc==1&&sumall==0)
	printf("AC");
	else
	printf("WA");
}

Measured memory_bytes: 128
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int n, k;
char s[55];
int main() {
	cin >> n >> k;
	cin >> s;
	s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s;
	return 0;
}

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

typedef int32_t i32;
typedef int64_t i64;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

typedef struct add_max_node {
  i64 add;
  i64 max;
} add_max_node;

typedef struct RMQandRAQ {
  add_max_node *a;
  i32 bit;
  i32 size;
} RMQandRAQ;

RMQandRAQ* new_RMQandRAQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) ++k;
  RMQandRAQ *s = (RMQandRAQ *) calloc (1, sizeof (RMQandRAQ));
  s->a = (add_max_node *) calloc (2 << k, sizeof (add_max_node));
  s->bit = k;
  s->size = 1 << k;
  return s;
}

static inline i64 max (i64 a, i64 b) {
  return a > b ? a : b;
}

static inline i64 eval (RMQandRAQ *s, i32 k) {
  return s->a[k].add + s->a[k].max;
}

void propagate (RMQandRAQ *s, i32 x) {
  x += s->size;
  for (i32 bit = s->bit; bit > 0; bit--) {
    i32 k = x >> bit;
    s->a[2 * k].add += s->a[k].add;
    s->a[2 * k + 1].add += s->a[k].add;
    s->a[k].add = 0;
    s->a[k].max = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void save (RMQandRAQ *s, i32 x) {
  for (i32 k = (x + s->size) >> 1; k >= 1; k >>= 1) {
    s->a[k].max = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void add (RMQandRAQ *s, i32 l, i32 r, i64 v) {
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->a[x++].add += v;
    if (y & 1) s->a[--y].add += v;
  }
  save (s, l);
  save (s, r - 1);
}

i64 find (RMQandRAQ *s, i32 l, i32 r) {
  //propagate (s, l);
  //propagate (s, r - 1);
  i64 ans = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max (ans, eval (s, l++));
    if (r & 1) ans = max (ans, eval (s, --r));
  }
  return ans;
}

typedef struct node {
  i32 l, v, next;
} node;

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  node *a = (node *) calloc (m + 1, sizeof (node));
  i32 *start = (i32 *) calloc (n + 1, sizeof (i32));
  for (i32 i = 1; i <= m; ++i) {
    i32 l = read_int();
    i32 r = read_int();
    i32 v = read_int();
    a[i] = (node) {l, v, start[r]};
    start[r] = i;
  }
  RMQandRAQ *s = new_RMQandRAQ (n + 1);
  for (i32 i = 1; i <= n; ++i) {
    i64 v = find (s, 0, i);
    add (s, i, i + 1, v);
    for (i32 p = start[i]; p; p = a[p].next) {
      add (s, a[p].l, i + 1, a[p].v);
    }
  }
  print_int (find (s, 0, n + 1));
  putchar ('\n');
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  bitset<64> b(0);
  while (q--) {
    int x;
    int op;
    cin >> op;
    switch (op) {
    case 0:
      cin >> x;
      cout << b.test(x) << endl;
      break;
    case 1:
      cin >> x;
      b.set(x);
      break;
    case 2:
      cin >> x;
      b.reset(x);
      break;
    case 3:
      cin >> x;
      b.flip(x);
      break;
    case 4:
      cout << b.all() << endl;
      break;
    case 5:
      cout << b.any() << endl;
      break;
    case 6:
      cout << b.none() << endl;
      break;
    case 7:
      cout << b.count() << endl;
      break;
    case 8:
      cout << b.to_ulong() << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

vector<int> g[200005];
int n, d[200005];
ll f[200005] = {1}, e[200005], h[200005], z[200005], w[200005], b[200005], c[200005];

ll inv(ll a) {
    ll b = mod - 2, c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

void dfs(int x, int p) {
    d[x] = z[x] = h[x] = b[x] = c[x] = 1;
    for (int i : g[x]) if (i != p) {
        dfs(i, x);
        d[x] += d[i];
        z[x] = z[x] * z[i] % mod * e[d[i]] % mod;
        c[x] = c[x] * e[d[i]] % mod;
        b[x] = b[x] * z[i] % mod;
    }
    z[x] = z[x] * f[d[x] - 1] % mod;
}

void dfs2(int x, int p) {
    for (int i : g[x]) if (i != p) {
        h[i] = c[x] * f[d[i]] % mod * f[n - d[i] - 1] % mod * e[n - d[x]] % mod * b[x] % mod * inv(z[i]) % mod * h[x] % mod;
        dfs2(i, x);
    }
    w[x] = f[n - 1] * c[x] % mod * e[n - d[x]] % mod * b[x] % mod * h[x] % mod;
}

int main() {
    ios::sync_with_stdio(false);
    int u, v;
    e[200000] = 750007460;
    h[1] = 1;
    for (int i = 1; i <= 200000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 199999; i >= 0; i--) e[i] = e[i + 1] * (i + 1) % mod;
    cin >> n;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    dfs(1, 1);
    dfs2(1, 1);
    for (int i = 1; i <= n; i++) cout << w[i] << '\n';
}


Measured memory_bytes: 26600
#include <bits/stdc++.h>
#define MEM 1000
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
long long t,n,m;
string s;
int main()
{
    sanic;
    cin >> t >> n >> m;
    cout << t/(n+m)*n+(t%(n+m)>n ? n:t%(n+m));
}


Measured memory_bytes: 256
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let s = read_one::<String>().chars().collect::<Vec<char>>();

    let mut cnt = 0;
    for i in 0..n {
        let mut a = s.clone();
        a.split_off(i);
        let b = &s[i..n];
        let mut cnt_i = 0;

        a.sort();
        a.dedup();

        for c in a {
            if b.contains(&c) {
                cnt_i += 1;
            }
        }
        cnt = cmp::max(cnt, cnt_i);
    }

    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

const int N = 2e5 + 10;

vector<int> g[N];
int n, q;
long long ans[N];

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> q;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> v >> u;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    for (int i = 1; i <= q; i++)
    {
        int v, x;
        cin >> v >> x;
        ans[v] += x;
    }
    dfs(1, 1);
    for (int i = 1; i <= n; i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

int main(){
    ll X, Y; cin >> X >> Y;
    int ans = 0;
    for(ll i = X; i <= Y; i *= 2){
        ans++;
    }
    COUT(ans);
}

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

int main() {
    int a;
    int b;
    cin >> a >> b;
    cout << a/b << ' ' << a%b << ' ' ;
    cout << fixed << setprecision(5);
    cout << (double)a/b << endl;
    return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

bool ans[85][85][13000];

int main() {
  ll H,W;
  cin>>H>>W;
  graph g(H,vector<ll>(W));
  graph A(H,vector<ll>(W)),B(H,vector<ll>(W));
  rep(i,H){
    rep(j,W) cin>>A[i][j];
  }
  rep(i,H){
    rep(j,W) cin>>B[i][j];
  }
  rep(i,H){
    rep(j,W) g[i][j] = abs(A[i][j]-B[i][j]);
  }
  rep(i,H){
    rep(j,W){
      if(i==0&&j==0) ans[0][0][g[0][0]]=true;
      if(i!=0) {
        rep(k,13000){
          if(ans[i-1][j][k]) {
            ans[i][j][abs(k+g[i][j])] = true;
            ans[i][j][abs(k-g[i][j])] = true;
          }
        }
      }
      if(j!=0) {
        rep(k,13000){
          if(ans[i][j-1][k]) {
            ans[i][j][abs(k+g[i][j])] = true;
            ans[i][j][abs(k-g[i][j])] = true;
          }
        }
      }
    }
  }
  rep(i,13000) {
    if(ans[H-1][W-1][i]) {
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 67708
// Bismillahir Raahmanir Raahim
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i;
    for(i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for (i=0;i<5;i++)
    {
        if(!a[i]){
            cout<<i+1<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 3552
n = gets.to_i
h = {}
prev = ""
ok = true
n.times{
    word = gets.chomp
    if (prev != "" && prev[-1] != word[0]) || h[word] == true
        ok = false
        break
    end
    prev = word
    h[word] = true
}
puts ok ? "Yes" : "No"


Measured memory_bytes: 3836
//  Created by conan1024hao on 2019/11/18.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
     
    int N, T;
     
    int dp[3000 + 10][3000 + 10][2];//dp[i][j][k] := i品目まで食べるかを選んで、jの時間がかかったときのおいしさの最大値
    //kが0の時は、最後に食べるものをまだ選んでない 1の時は最後に食べるものをもう選んでる状態
    vector<int> A, B;
        cin >> N >> T;
        for (int i = 0; i < N; i++) {
            int a, b;
            cin >> a >> b;
            A.push_back(a);B.push_back(b);
        }
        dp[0][0][0] = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= T - 1; j++) {
                for (int k = 0; k < 2; k++) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k]);
                    if (j - A[i - 1] >= 0)
                        dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - A[i - 1]][k] + B[i - 1]);
                    //最後に食べるとする
                    if (k == 0) {
                        dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + B[i - 1]);
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= T - 1; i++)
            ans = max(ans, dp[N][i][1]);
        cout << ans << endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

int main(){
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    int f = 0;
    ll ans;
    for(int i  = 0; i < n; i++){
        if(s1[i] == s2[i]){
            if(f == 0){
                ans = 3;
            }else if(f == 1){
                ans = (ans * 2) % div;
            }else if(f == 2){
                //
            }
            f = 1;
        }else if(s1[i] == s1[i+1]){
            if(f == 0){
                ans = 6;
            }else if(f == 1){
                ans  = (ans *2) % div;
            }else if(f == 2){
                ans = (ans * 3) % div;
            }
            f = 2;
            i++;
        }
        //cout  << i << " " << f << " " << ans << endl;
    }
    cout << ans << endl;
}

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

int main()
{
    string a, b, c;
    cin >> a >> b >>c;

    bool ans = true;
    ans &= a[a.size() - 1] == b[0];
    ans &= b[b.size() - 1] == c[0];
    
    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
int x[5];
for(int i=0;i<5;i++)
    cin>>x[i];
int k;cin>>k;
sort(x,x+5);
cout<<((x[4]-x[0])>k?":(":"Yay!")<<endl;
return 0;}


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

his=[False]*N

A=[[0]*2 for i in range(M)]
for i in range(M):
    a,b=map(int,input().split())
    A[i][0],A[i][1] =a-1,b-1

def search(now,his,A):
    
    if all(his):
        return 1
    
    else:
        cnt=0
        for a in A:
            if now in a:
                nex=a[(a.index(now)+1)%2]
                if not his[nex]:
                    his[nex]=True
                    cnt+=search(nex,his,A)
                    his[nex]=False
       
        return cnt

his[0]=True
print(search(0,his,A))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct f{
	int a,b,c;
};
int main(){
	int o;
	cin>>o;
	vector<f> e;
	int r=log2(o);
	int n=r+1;
	for(int i=0;i<r;i++){
		e.push_back(f{i+1,i+2,0});
		e.push_back(f{i+1,i+2,1<<i});
	}
	int p=1<<r;
	for(int i=r;i>=1 && o-p>0;i--){
		int w=1<<(i-1);
		if(o-p>=w){
			o-=w;
			e.push_back(f{i,n,o	});
		}
	}
	cout<<n<<' '<<e.size()<<endl;
	for(int i=0;i<e.size();i++)
	cout<<e[i].a<<' '<<e[i].b<<' '<<e[i].c<<endl;
}

Measured memory_bytes: 3760
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<llong> A;
vector<llong> B;
llong  X;
llong ANS = 0;

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		llong a;
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < N - 1; i++) {
		llong b = A[i + 1] + A[i];
		B.push_back(b);
	}
	B.push_back(0);

	for (int i = 0; i < B.size(); i++) {
		if (B[i] > X) {
			ANS += B[i] - X;
			if (B[i] - X < A[i + 1]) {
				A[i + 1] -= B[i] - X;
				B[i + 1] -= B[i] - X;
				B[i] = X;
			}
			else {
				B[i + 1] -= A[i + 1];
				A[i] -= B[i] - X - A[i + 1];
				A[i + 1] = 0;
				B[i] = X;
			}
		}
	}

	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    stack<int> s1;
    stack<pair<int, int>> s2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') {
            s1.push(i);
        } else if (ch == '/' && s1.size() > 0) {
            int j = s1.top();
            s1.pop();
            sum += i - j;
            int a = i - j;
            while (s2.size() > 0 && s2.top().first > j) {
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    int t = 0;
    while (s2.size() > 0 ) {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " ";
        t += ans[i];
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;

const int nmax = 100005;

LL N,a[nmax],sol[nmax],nr;
map<LL,int>viz,cnt;

struct el{
 int x,j;
 bool operator <(const el&A)const
 {
    return x < A.x;
 }
}b[nmax];

int main()
{
    LL i,j,q,x,pr,lg,aux;
//    #ifndef ONLINE_JUDGE
//        freopen ("txt.in","r",stdin);
//        freopen ("txt.out","w",stdout);
//    #endif
   ios::sync_with_stdio(false);

    cin >> N;
    aux = N;
    x = 0;
   for(i = 1; i <= N; ++i){
      cin >> a[i];
      if(!viz[a[i]])
         b[++x].x = a[i],b[x].j = i;

      viz[a[i]] = 1;
      ++cnt[a[i]];
   }
   b[++x].x = 0;
   N = x;
   sort(b+1,b+N+1);

   for(i = N; i > 1; --i){
      lg = b[i].x-b[i-1].x;

      nr = cnt[b[i].x];
      b[i-1].j = min(b[i-1].j,b[i].j);
      sol[b[i].j]+= nr*lg;
      cnt[b[i-1].x]+=nr;
   }
   N = aux;
   for(i = 1; i <= N; ++i)
      cout << sol[i] << '\n';

    return 0;
}


Measured memory_bytes: 15872
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int ans = 0;
        for (int i = 0; i < 5; i++) {
            int j = sc.nextInt();
            if (j == 0) {
                ans = i + 1;
            }
        }
        System.out.println(ans);

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){
    int n,k;
    int p[1000];
    int t=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int tmp;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (p[i] > p[j]) {
                tmp =  p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
    for(int i=0;i<k;i++){
        t=t+p[i];
    }
    cout<<t<< "\n";

}


Measured memory_bytes: 3588
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    {
        ll n,x,t,k=0;
        cin>>n>>x>>t;
        if(n%x==0)
        cout<<(n/x)*t<<"\n";
        else
        cout<<(n/x+1)*t<<"\n";
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
using namespace std;
#include <bits/stdc++.h>
const double PI = acos(-1);
double to_deg(double r){
    return r * 180.0 / PI;
}
int main(){
    double a,b,x;
    cin >> a >> b >> x;
    int A = (int)a;
    int B = (int)b;
    int X = (int)x;
    double ans = 0;
    if(X*2 <= A*A*B){
        double tmp1 = to_deg(atan(2 * x/pow(a, 3.0)));
        double tmp2 = to_deg(atan(a*b*b/(2*x)));
        ans = max(tmp1, tmp2);
    }else{
        ans = to_deg(atan(2 * (A*A*B - x) / pow(a, 3.0)));
    }
    std::cout << std::setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n');

  const m = Number(s[0].split(' ')[1]);
  const xyz = s.slice(1, -1).map(l => l.split(' ').map(n => Number(n)));

  const sign = [1, -1];

  let ans = 0;

  for (let i = 0; i <= 1; i++) {
    for (let j = 0; j <= 1; j++) {
      for (let k = 0; k <= 1; k++) {

        xyz.sort((a, b) => {
          const formula_a = sign[i] * a[0] + sign[j] * a[1] + sign[k] * a[2];
          const formula_b = sign[i] * b[0] + sign[j] * b[1] + sign[k] * b[2];
          return formula_a - formula_b;
        });

        const eachSum = [0, 0, 0];
        xyz.slice(0, m).forEach(xyz => {
          eachSum[0] += xyz[0];
          eachSum[1] += xyz[1];
          eachSum[2] += xyz[2];
        });

        const allSum = eachSum.reduce((a, b) => Math.abs(a) + Math.abs(b));

        ans = Math.max(ans, allSum);
      }
    }
  }

  console.log(ans);
}

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


Measured memory_bytes: 9776
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int tmp=0;  
    for(int i=0;i<a.size();i++){
        if(a[i]=='C'){
            tmp=1;}
        if(a[i]=='F'&&tmp==1){
            cout<<"Yes";return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<vector<int>> r(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        r[a-1].push_back(b-1);
        r[b-1].push_back(a-1);
    }
    vector<int> s(n);
    rep(i,k) {
        int p,x;
        cin >> p >> x;
        s[p-1]+=x;
    }
    queue<int> q;
    vector<int> cost(n,-1);
    q.push(0);
    cost[0]=0;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        rep(i,r[now].size()) {
            int next=r[now][i];
            if (cost[next]==-1) {
                s[next]+=s[now];
                cost[next]=cost[now]+1;
                q.push(next);
            }
        }
    }
    rep(i,n) cout << s[i] << ' ';
    cout << endl;


    return 0;   
}


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

#define endl '\n'

void quicken(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout.tie(0);
}

int main(){
    quicken();

    int n; cin >> n;
    long long arr[n], maxi, ans=LONG_MAX, mini, mi, ma;
    for(int i=0; i<n; i++) cin >> arr[i];

    mi = *min_element(arr, arr+n);
    ma = *max_element(arr, arr+n);
    for(long long i=mi; i<=ma; i++){
        mini = 0;
        for(int j=0; j<n; j++)
            mini += pow((arr[j]-i), 2);
        ans = min(mini, ans);
        /// cout << mini << " " << ans << endl;
    }

    cout << ans;
    return 0;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (auto &e : s) {
		cin >> e;
	}
	vector<pair<int, int>> d = {make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0), make_pair(0, -1)};
	vector<vector<int>> a(h, vector<int>(w, INT_MAX));
	queue<pair<int, int>> q;
	a[0][0] = 0;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		auto f = q.front();
		q.pop();
		for (auto e : d) {
			int i = f.first + e.first, j = f.second + e.second;
			if (0 <= i && i < h && 0 <= j && j < w && s[i][j] == '.') {
				if (a[f.first][f.second] + 1 < a[i][j]) {
					a[i][j] = a[f.first][f.second] + 1;
					q.push(make_pair(i, j));
				}
			}
		}
	}
	int m;
	if (a[h - 1][w - 1] == INT_MAX) {
		m = -1;
	} else {
		int t = 0;
		for (auto r : s) {
			for (auto e : r) {
				t += e == '.';
			}
		}
		m = t - a[h - 1][w - 1] - 1;
	}
	cout << m << endl;
	return 0;
}


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

using namespace std;    
const int turn[10][8]={{1,1,1,1,1,1,0},{0,1,1,0,0,0,0},{1,1,0,1,1,0,1},{1,1,1,1,0,0,1},{0,1,1,0,0,1,1},{1,0,1,1,0,1,1},{1,0,1,1,1,1,1},{1,1,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};

int main(void){
	int n;
	int a,b;
	int seven[8];
	while(1){
		cin >> n;
		if(n==-1)break;
		memset(seven,0,sizeof(seven));
		for(a=0;a<n;a++){
			int nn;
			cin >> nn;
			for(b=0;b<7;b++){
				if(turn[nn][b]!=seven[b])seven[b]=1;
				else seven[b]=0;
			}
			for(b=6;b>=0;b--)printf("%d",seven[b]);
			printf("\n");
			for(b=0;b<7;b++)seven[b]=turn[nn][b];
		}
	}
	return 0;
}

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

using namespace std;

string S,T;
int main(){
    cin >> S >> T;
    bool c=true;
    for(int i=0;i<S.size();i++){
        if(T[i]!=S[i]) c=false;
    }
    if(c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	
	int ma = 0;
	int mi = __INT_MAX__;
	rep(i,n){
		int a;
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
	}
	cout << ma - mi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    vector<pair<int,int> > p,q;
    int sm = 0;
    bool flag = 1;
    rep(i,n){
        int c = 0;
        int mi = 0;
        rep(j,s[i].size()){
            if(s[i][j]=='('){
                c++;
                sm++;
            }else{
                c--;
                sm--;
            }
            chmin(mi,c);
            if(mi!=0)flag = 0;
        }
        if(c>0){
            p.push_back(MP(mi,c));
        }else{
            q.push_back(MP(mi,c));
        }
    }
    if(sm!=0){
        cout << "No\n";
        return 0;
    }
    if(flag){
        cout << "Yes\n";
        return 0;
    }
    int d = 0;
    vector<pair<int,int> > r;
    for(auto x:p){
        if(x.first==0){
            d += x.second;
        }else{
            r.push_back(x);
        }
    }
    if(d==0){
        cout << "No\n";
        return 0;
    }
    sort(r.rbegin(),r.rend());
    for(auto x:r){
        if(d+x.first<0){
            cout << "No\n";
            return 0;
        }else{
            d += x.second;
        }
    }
    pair<int,int> las=MP(inf,inf);
    int qid = -1;
    rep(i,q.size()){
        if(q[i].first==q[i].second){
            if(chmin(las,q[i])){
                qid = i;
            }
        }
    }
    if(qid==-1){
        cout << "No\n";
        return 0;
    }
    q.erase(q.begin()+qid);
    int m = q.size();
    vector<pair<int,pair<int,int> > > qq;
    rep(i,m){
        qq.push_back(MP(q[i].first+q[i].second,MP(q[i].first,q[i].second)));
    }
    sort(qq.begin(),qq.end());
    rep(i,m){
        if(d+qq[i].second.first<0){
            cout << "No\n";
            return 0;
        }else{
            d += qq[i].second.second;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3236
import java.util.*;

public class Main {

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

    for(int i = 0;i < 4;i++) {
      c[i] = s.charAt(i);
    }

    Arrays.sort(c);

    if(c[0] == c[1] && c[2] == c[3] && c[1] != c[2]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }


  }

}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    vector<vector <int> > A(3, vector<int> (3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
        
    }
    int N;
    cin >> N;
    bool b[100] = {false};
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        b[tmp - 1] = true;
    }
    
    bool bin[3][3] = {false};
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (b[A[i][j] - 1] == true)
            {
                //cout << A[i][j] << "は出ているぞ！" << '\n';
                bin[i][j] = true;
            }else{
                //cout << A[i][j] << "は出ていないぞ！" << '\n';
            }

        }
        
    }

    int n = 0;
    for (int i = 0; i < 3; i++)
    {
        if (bin[i][0] & bin[i][1] & bin[i][2])
        {
            n += 1;
        }
        
    }
    for (int j = 0; j < 3; j++)
    {
        if (bin[0][j] & bin[1][j] & bin[2][j])
        {
            n += 1;
        }

    }
    if(bin[0][0] & bin[1][1] & bin[2][2]) n += 1;
    if(bin[0][2] & bin[1][1] & bin[2][0]) n += 1;

    if (n > 0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
S = input()

# do shakutori
#以下が an mod p を求めるソースコードです.
def power_func(a, n, p):
    res = 1 #これは答え
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p #1が立っているかどうかに関わらず次のaの累乗を用意しておく
        n = n >> 1
    return res

Q = [0]
for i in range(len(S)-1, -1, -1):
    pow = len(S) - i - 1
    Q.append((Q[-1] + power_func(10, pow, 2019) * int(S[i])) % 2019)
# print(Q)

import collections
dct = dict(collections.Counter(Q))
# print(dct)
ans = 0
for val in dct.values():
    ans += val * (val - 1) // 2
print(ans)



Measured memory_bytes: 82876
#include <stdio.h>

int main(void)
{
  int pasta;
  int juice;
  int i;
  int p_min = 2000;
  int j_min = 2000;

  for(i = 0; i < 3; i++){
    scanf("%d", &pasta);
    if (p_min > pasta){
      p_min = pasta;
    }
  }

  for(i = 0; i < 2; i++){
    scanf("%d", &juice);
    if (j_min > juice){
      j_min = juice;
    }
  }

  printf("%d\n", p_min + j_min - 50);

  return (0);
}

Measured memory_bytes: 592
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))


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

	ans = n + m;
	if (ans >= 24) ans = ans - 24;

	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

n=int(input())
A=list(map(int,input().split()))
data=[0]*(10**6+10)
for ai in A:
    arr=prime_factor(ai)
    for ni,ci in arr:
        data[ni]=max(data[ni],ci)
pro=1
for i in range(1,len(data)):
    pro=pro*(i**data[i])
    pro%=mod

for ai in A:
    ans+=pow(ai,mod-2,mod)
print(ans*pro%mod)

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

using namespace std;

int A,B,C,K;
void input(){
  cin >> A >> B >> C >> K;
}

int main(){
  input();
  if(K<A){
    cout << K << endl;
  }else {
    if(K<A+B){
    cout << A << endl;
    }else{
    cout << A - (K-A-B) << endl;
    }
  }
}

Measured memory_bytes: 3644