akhauriyash/Code-Regression huggingface dataset:
// Fri May  1 19:19:10 IST 2020                 
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = a ; ii < b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5; 
const int INF = 2e9;
int tests()
{     
    int s,w ;
    cin >> s >> w ;
    if(w >= s)
        return cout << "unsafe\n",0;
    cout << "safe\n";
    return 0;
}   
int32_t main(){
    I__O ;          
    //  #ifndef ONLINE_JUDGE 
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    // #endif
    int cases = 1 ; 
    // cin >> cases ; 
    for(int i = 1 ;i  <= cases ; i++ ){   
    // cout << "Case #" << i << ": ";
      tests(); 
    }
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3816
from math import gcd
k = int(input())
n = 0
combi = []
for a in range(k-2):
    for b in range(a+1,k-1):
        for c in range(b+1,k):
            n += gcd(a+1,gcd(b+1,c+1)) * 3*2

for a in range(k):
    n += a+1

for a in range(k-1):
    for b in range(a+1,k):
        n += gcd(a+1,b+1) * 3 *2
            

print(n)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n;
    cin >> n;
    vec(t,n);
    vec(x,n);
    vec(y,n);
    REP(i,n){
        cin >> t[i] >> x[i] >> y[i];
    }
    int ti = 0,xi=0,yi=0,ans=0;
    REP(i,n){
        int sum = abs(xi-x[i])+abs(yi-y[i]);
        int tm = t[i] - ti;
        if(tm >= sum && (tm-sum)%2==0){

        }
        else{
            ans=1;
            break;
        }
        ti=t[i];
        xi=x[i];
        yi=y[i];
    }
    (ans == 0)? cout << "Yes" : cout << "No";

    return 0;
}


Measured memory_bytes: 2560
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define MP make_pair
#define PB push_back
#define FST first
#define SND second
#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define REP(i,x,y) for(int i=(x);i<=(y);i++)

using namespace std;

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

const int maxn=1e5+5;
const ll INF=1e18+7;

int n,k;
ll ans=INF;
ll a[maxn];

int main(){
	scanf("%d%d",&n,&k);
	FOR(i,0,n) scanf("%lld",a+i);
	int pos=lower_bound(a,a+n,0)-a;
	if(!pos){
		printf("%d\n",a[k-1]);
		return 0;
	}
	if(pos==n){
		printf("%d\n",abs(a[n-k]));
		return 0;
	}
	FOR(i,pos,n){
		int rt=i-pos+1;
		int lf=k-rt;
		if(lf>=0&&pos-lf>=0){
//			printf("%d %d %d %lld %lld\n",lf,rt,pos,abs(a[pos-lf])*2+a[i],a[i]*2+abs(a[pos-lf]));
			ll res=min(abs(a[pos-lf])*2+a[i],a[i]*2+abs(a[pos-lf]));
			ans=min(ans,res);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

int main()
{
	int n;
	cin>>n;
	vpii X(n);
	for(int i=0;i<n;i++)
	{
		cin>>X[i].first>>X[i].second;
	}
	vi D(n),S(n);
	for(int i=0;i<n;i++)
	{
		D[i] = X[i].first-X[i].second;
		S[i] = X[i].first+X[i].second;
	}
	sort(all(D));
	sort(all(S));
	cout<<max(D[n-1]-D[0],S[n-1]-S[0])<<endl;

}

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

int comp(const void *a, const void *b)
{
    return (*(int *)a - *(int *)b);
}

int main(void)
{
    int n;
    int a[1000];
    int min;
    int i, j;

    while (1){    
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &a[i]);
        }
        
        qsort(a, n, sizeof(int), comp);
        
        min = 1000000;
        
        for (i = 0; i < n - 1; i++){
            if (min > a[i + 1] - a[i]){
                min = a[i + 1] - a[i];
            }
        }
        
        printf("%d\n", min);
    }
    
    return (0);
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

bool possible(ll x, vector<ll> &h, ll A, ll B, ll N){
    vector<ll> h_copy(N);
    rep(i,N) h_copy[i] = h[i];
    rep(i,N) h_copy[i] -= x * B;
    ll count = 0;
    rep(i,N){
        if (h_copy[i] > 0){
            if (h_copy[i] % (A - B) == 0) count += (h_copy[i] / (A - B));
            else count += (h_copy[i] / (A - B) + 1);
        }
    }
    if (count > x) return false;
    return true;
}

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    ll left = 0;
    ll right = 1000000000;
    ll ans = 0;
    while(true){
        if (right - left == 1){
            ans = right;
            break;
        }
        else if (possible((left + right) / 2, h, A, B, N)){
            right = (left + right) / 2;
        }
        else{
            left = (left + right) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    while(N < 1000){
        if(N % 10 == N%100/10 && N%10 == N%1000/100){
            cout << N << endl;
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

int a[3005];
ll dp[3005][3005];
bool fg[3005][3005];
int n;
ll dfs(int l, int r) {
   if (r - l == 0) return 0;

   if (fg[l][r]) return dp[l][r];
   fg[l][r] = true;
   return dp[l][r] = max(a[l] - dfs(l + 1, r), a[r - 1] - dfs(l, r - 1));
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   rep(i, 0, n) cin >> a[i];
   ll ans = dfs(0, n);
   cout << ans << endl;
   return 0;
}

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

int main()
{
  int n, t;
  cin >> n >> t;
  int ans = 1001;
  for(int i = 0; i < n; ++i)
  {
    int c, t2;
    cin >> c >> t2;
    if(t2 <= t)
    {
      ans = min(ans, c);
    }
  }
  if(ans != 1001) cout << ans;
  else cout << "TLE";
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int sz = str.length(), count = 0;
		for (int i=0 ; i<sz/2 ; i++) {
			if(str.charAt(i) != str.charAt(sz-i-1)) count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  if(s[k-1]=='A')s[k-1]='a';
  if(s[k-1]=='B')s[k-1]='b';
  if(s[k-1]=='C')s[k-1]='c';
  
  cout << s << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long int ll;
ll M,N;
const ll MOD=1e9+7;
ll X[50];
ll ans=1;
int main()
{
	scanf("%lld%lld",&M,&N);
	X[0]=1;
	X[1]=M;
	for(int i=2;i<50;i++)X[i]=(X[i-1]*X[i-1])%MOD;
	for(int i=0;i<50;i++){
		if(N%2==1){
			ans*=X[i+1];
			ans%=MOD;
		}
		N/=2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    REP(i, h){
        cin >> s[i];
    }
    REP(i, h){
        REP(j, w){
            if(s[i][j] == '#'){
                bool ok = false;
                if(i > 0){
                    if(s[i - 1][j] == '#'){
                        ok = true;
                    }
                }
                if(i < h - 1){
                    if(s[i + 1][j] == '#'){
                        ok = true;
                    }
                }
                if(j > 0){
                    if(s[i][j - 1] == '#'){
                        ok = true;
                    }
                }
                if(j < w - 1){
                    if(s[i][j + 1] == '#'){
                        ok = true;
                    }
                }
                if(!ok){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define inf 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;


int32_t main(){
	fastio;
	int n,x;
	cin>>n>>x;
	vector<int> l(n+5);
	for(int i=1;i<=n;i++)cin>>l[i];
	int ant=0;
	int res=1;
	for(int i=2;i<=n+1;i++){
		ant = ant+l[i-1];
		if(ant<=x)res++;	
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	vll mnum(k,0);
	ll ans = 0;
	rep2(i,1,n+1) mnum[i%k]++;
	rep(a,k){
		int b = (k-a)%k;
		int c = (k-a)%k;
		if((b+c)%k) continue;
		ans += mnum[a]*mnum[b]*mnum[c];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]

for i in range(N):
  a=[int(x) for x in input().rstrip().split()]
  l.append(a)

ans=float('inf')
falg=1


A=[0 for x in range(M)]
for i in range(2**N):
  cost=0
  flag=1
  
  for j in range(N):
    if i>>j & 1:
      now=l[j]
      cost+=now[0]
      for t in range(M):
        A[t]+=now[t+1]

  for s in range(M):
    if X<=A[s]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
  
  A=[0 for v in range(M)]

if ans==float('inf'):
  print(-1)
else:
  print(ans)      



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

using namespace std;

typedef long long ll;
typedef long double ld;
const ld INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);
typedef pair<ll, ll> P;


int main(){
  ll N, C;
  cin >> N >> C;
  vector<vector<P> > v(C);
  for(int i=0;i<N;i++){
    ll s, t, c;
    cin >> s >> t >> c;
    c--;
    v[c].push_back(P(s, t));
  }
  vector<P> v2;
  for(int i=0;i<C;i++){
    sort(v[i].begin(), v[i].end());
    for(int j=0;j<v[i].size();){
      ll to = j;
      ll now = v[i][j].second;
      while(to + 1 < v[i].size() && v[i][to+1].first == now){
	now = v[i][to+1].second;
	to++;
      }
      v2.push_back(P(v[i][j].first, v[i][to].second));
      j = to+1;
    }
  }
  vector<ll> imos(100100);
  for(auto&& node : v2){
    ll s,t;
    tie(s, t) = node;
    imos[s]++;
    imos[t+1]--;
  }
  ll ans = 0;
  for(int i=0;i<imos.size()-1;i++)
    imos[i+1] += imos[i];
  for(int i=0;i<imos.size();i++)
    ans = max(ans, imos[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5108
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

// vars
int s, w;

void input(){
    cin >> s >> w;
}

void solve(){
    if(w >= s){
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	bool flag;
	std::string s;
	std::cin >> s;
	std::reverse(s.begin(),s.end());
	flag = (s[0]=='s');
	std::reverse(s.begin(),s.end());
	std::cout << s << (flag?"es":"s") << std::endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		string ans;
		while (n > 0)
		{
			ll rem = n % 26;
			if (rem == 0)
			{
				ans.push_back('z');
				n = n / 26 - 1 ;
			}
			else
			{
				ans.push_back(((rem - 1) + 'a'));
				n = n / 26;
			}
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

d = {}
dd = {}
for i in range(N+1):
    d[i] = abs(A[i+1] - A[i])
for i in range(N):
    dd[i] = abs(A[i+2] - A[i])

sA = sum(d.values())
for i in range(N):
    ans = sA - d[i+1] - d[i] + dd[i]
    print(ans)


Measured memory_bytes: 39040
import numpy as np
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
move=[]
for i in range(h):
    for j in range(w):
        if a[i][j]%2:
            if j<w-1:
                move.append((i,j,i,j+1))
                a[i][j+1]+=1
            elif i<h-1:
                move.append((i,j,i+1,j))
                a[i+1][j]+=1
print(len(move))
for x,y,x2,y2 in move:
    print(x+1,y+1,x2+1,y2+1)


Measured memory_bytes: 31800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll a[maxn];
ll b[maxn];
ll c[maxn];
set<ll>q;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        q.insert(a[i]);
        b[a[i]]++;
    }
    ll ans=0;
    while(!q.empty())
    {
        int x=*q.begin();
        q.erase(x);
        ans+=(b[x])*(b[x]-1)/2;
    }
    for(int i=0; i<n; i++)
    {
        ll t=(b[a[i]])*(b[a[i]]-1)/2-(b[a[i]]-1)*(b[a[i]]-2)/2;
        printf("%lld\n",ans-t);
    }
    return 0;
}


Measured memory_bytes: 10624
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MX 10000001
int p[MX+5],pn,u[MX+5],v[MX+5],a[MX+5],an,b[MX+5],bn;
namespace MaxFlow
{
	const int MV=200,ME=10200,S=MV+1,T=MV+2,INF=0x7FFFFFFF;
	struct edge{int nx,t,w;}e[ME*2+5];
	int h[MV+5],en=1,d[MV+5],q[MV+5],qn,c[MV+5];
	inline void ins(int x,int y,int w)
	{
		e[++en]=(edge){h[x],y,w};h[x]=en;
		e[++en]=(edge){h[y],x,0};h[y]=en;
	}
	bool bfs()
	{
		int i,j;
		memset(d,0,sizeof(d));
		for(d[q[i=qn=0]=S]=1;i<=qn;++i)for(j=c[q[i]]=h[q[i]];j;j=e[j].nx)
			if(e[j].w&&!d[e[j].t])d[q[++qn]=e[j].t]=d[q[i]]+1;
		return d[T];
	}
	int dfs(int x,int r)
	{
		if(x==T)return r;
		int k,u=0;
		for(int&i=c[x];i;i=e[i].nx)if(e[i].w&&d[e[i].t]==d[x]+1)
		{
			k=dfs(e[i].t,r-u<e[i].w?r-u:e[i].w);
			u+=k;e[i].w-=k;e[i^1].w+=k;
			if(u==r)return r;
		}
		return d[x]=0,u;
	}
	int dinic(){int ans=0;while(bfs())ans+=dfs(S,INF);return ans;}
};
int main()
{
	int n,i,j,ans=0;
	for(u[1]=1,i=2;i<=MX;++i)
	{
		if(!u[i])p[++pn]=i;
		for(j=1;i*p[j]<=MX;++j){u[i*p[j]]=1;if(i%p[j]==0)break;}
	}
	for(n=read();n--;)v[i=read()]^=1,v[i+1]^=1;
	for(i=1;i<=MX;++i)if(v[i])i&1?a[++an]=i:b[++bn]=i;
	using namespace MaxFlow; 
	for(i=1;i<=an;++i)ins(S,i,1);
	for(j=1;j<=bn;++j)ins(an+j,T,1);
	for(i=1;i<=an;++i)for(j=1;j<=bn;++j)if(!u[abs(a[i]-b[j])])ins(i,an+j,1);
	ans=dinic();
	ans+=((an-ans)&1)+(an+bn-2*ans);
	printf("%d",ans);
}

Measured memory_bytes: 84224
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	int a, b,c,d;

	long x,y,z;

	scanf("%d%d", &a, &b);

	for (x = 0; x < 10000000000; x++) {
		if (a == 0 || b == 0) {
			printf("IMPOSSIBLE");
			break;
		}
		if (a % 2 != b % 2) {
			printf("IMPOSSIBLE");
			break;
		}
		y = a - x;
		z = b - x;
		if (y < 0)y = y * -1;
		if (z < 0)z = z * -1;
		if (y == z) {
			printf("%ld", x);
			break;
		}
		else if (x == 10000000000 && y != z) {
			printf("IMPOSSIBLE");
			break;
		}
	}

	return 0;
}

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

int main()
{
	long long boxNum,lim,i;
	cin>>boxNum>>lim;
	long long a[boxNum];
	for(i=0;i<boxNum;i++)
	{
		cin>>a[i];
	}
	long long snukeCount=0;
	for(i=1;i<boxNum;i++)
	{
		if(a[i-1]+a[i]>lim)
		{
			snukeCount+=(a[i-1]+a[i]-lim);
			if(a[i-1]<lim)
				a[i]=lim-a[i-1];
			else
			{
				a[i]=0;
				a[i-1]=lim;
			}
		}
	}
	cout<<snukeCount<<endl;
	return 0;
 } 

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int64_t cash = 1000;
  int64_t stock = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < a[i + 1]) {
      if (stock == 0) {
        stock += cash / a[i];
        cash -= stock * a[i];
      }
    } else {
      cash += stock * a[i];
      stock = 0;
    }
  }
  cout << cash << endl;
}


Measured memory_bytes: 3604
from collections import Counter
s = input()
ac = [0]

def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

for i in range(len(s)):
    char = s[i]
    digit = len(s) - i - 1
    ac.append((ac[-1] + (int(char) * power_func(10, digit, 2019))) % 2019)
#print(ac)

C = Counter(ac)
#print(C)
ans = 0
for val in C.values():
    ans += val * (val - 1) // 2
print(ans)

Measured memory_bytes: 92308
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int h, w;
    char s[2010][2010];
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> s[i];
    
    int k[2010] = {}, l[2010] = {};
    for (int i = 0; i < h; i++) {
        while (s[i][k[i]] == '.' && k[i] < w) k[i]++;
    }
    for (int i = 0; i < w; i++) {
        while (s[l[i]][i] == '.' && l[i] < h) l[i]++;
    }
    
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                k[i] = l[j] = 0;
                while (s[i][k[i] + j + 1] == '.' && k[i] + j + 1 < w) k[i]++;
                while (s[l[j] + i + 1][j] == '.' && l[j] + i + 1 < h) l[j]++;
                //cout << 0;
            }
            else {
                ans = max(ans, k[i] + l[j] - 1);
                //cout << k[i] + l[j] - 1;
            }
        }
        //cout << endl;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int a, b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	int n;
	cin >> n;
	vector<double> wow;
	REP(i,n){
		double tmp;
		cin >> tmp;
		wow.push_back(tmp);
	}
	double ans = 0;
	sort(wow.begin(),wow.end(),greater<double>());
	for(int i = 0;i < wow.size()-1;++i){
		for(int q = i+1;q < wow.size();++q){
			double puu = 0;
			for(int j = 0;j < wow.size();++j){
				if(j != i&&j != q){
					if(puu != 0){
						puu += wow[j];
						break;
					}
					puu += wow[j];
				}
			}
			ans = max(ans,puu / abs(wow[i]-wow[q]));
		}
	}
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 3264
from collections import Counter

N, K = map(int, input().split())
A = sorted(Counter(list(map(int, input().split()))).most_common(), key=lambda x: x[1])
ans = 0
if len(A) > K:
    for i in range(len(A) - K):
        ans += A[i][1]

print(ans)


Measured memory_bytes: 37780
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, m;
vector<int>G[1005];
vector<int>ans;
bool used[1005], used2[1005];
bool con[1005][1005];
bool ng[1005];
bool dfs(int s, int x) {
	if (ng[x])return false;
	bool flag = false;
	used[x] = true;
	used2[x] = true;
	ans.push_back(x);
	for (int i : G[x]) {
		if (i == s) {
			rep(j, ans.size()) {
				rep(k, ans.size()) {
					if (j + 1 == k)continue;
					if (j == ans.size() - 1 && k == 0)continue;
					if (con[ans[j]][ans[k]])goto ng;
				}
			}
			cout << ans.size() << endl;
			rep(j, ans.size())cout << ans[j] + 1 << endl;
			exit(0);
		ng:;
			flag = true;
		}
		if (!used[i])flag |= dfs(s, i);
	}
	ans.pop_back();
	used[x] = false;
	if (!flag)ng[x] = true;
	return flag;
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		con[a][b] = true;
	}
	rep(i, n) {
		//if (used2[i])continue;
		fill(used, used + n, false);
		fill(ng, ng + n, false);
		dfs(i, i);
	}
	cout << "-1" << endl;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
  int cnt = 0;
  string str;
  cin >> str;
  for (int i = 0; i < 4; ++i){
    if (str[i] == '+'){
      cnt += 1;
    }else{
      cnt -= 1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
def solve():
    N =  int(input())
    E = [[] for _ in range(N+1)]
    D = {}
    L = [-1 for _ in range(N)]
    for i in range(1,N):
        a, b = map(int, input().split())
        E[a].append(b)
        E[b].append(a)
        D[(a,b)] = i
    r = 1
    q = [(r,0)]
    d = 0
    while q:
        v, c = q.pop()
        d = max(d, len(E[v]))
        C = 0
        for u in E[v]:
            if L[D.get((v,u), D.get((u,v),-1))] == -1:
                C += 1
                x = C
                if c == x:
                    C += 1
                    x = C
                q.append((u,x))
                L[D.get((v,u), D.get((u,v),-1))] = x
    L[0] = d
    res = '\n'.join(map(str, L))
    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 44304
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    map<ll, ll> mp;
    auto prime_factrize = [&](ll a) -> void {
        for (ll i = 2; i*i <= a; i++) {
            if (a%i != 0) continue;
            ll cnt = 0;
            while (a%i == 0) {
                cnt++;
                a /= i;
            }
            mp[i] += cnt;
        }
        if (a > 1) mp[a]++;
    };
    prime_factrize(n);
    ll ans = 0;
    for (auto v : mp) {
        // cout << v.second << endl;
        int cnt = 1;
        while (cnt <= v.second) {
            ans++;
            v.second -= cnt;
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
l, r = map(int,input().split())
ans = 2019
for i in range(l, min(r, l+2019)+1):
    for j in range(l, min(r, l+2019)+1):    
        if i >= j:
            continue
        ans = min(ans, (i * j) % 2019)
print(ans)

Measured memory_bytes: 3060
program main
    implicit none
    character(1000)::s,t
    integer::n,m,ans,i,j,nm
    integer,allocatable::aaa(:)

    ans=0

    read*,s,t
    !print*,s,t

    n=len_trim(s)
    m=len_trim(t)
    nm=n-m
    !print*,n,m,nm
    allocate(aaa(nm+1))
    !print*,s(n:n),t(m:m)
    if(nm==0) then
        do i=1,m
            if(s(i:i)/=t(i:i)) then
                !print*,s(i:i)
                ans=ans+1
            end if
        end do
        go to 100
    end if

    
    ans=0
    if(nm>0) then
        !print*,s(1:1)
        do i=1,nm+1
            aaa(i)=0
            do j=i,m+i-1
               ! print*,s(j:j)
                if(s(j:j)/=t(j-i+1:j-i+1)) then
                   ! print*,s(j:j)
                    aaa(i)=aaa(i)+1
                end if
            end do
        end do
        ans=minval(aaa)
    end if

100 print*,ans
end program main

Measured memory_bytes: 2868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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 ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  cout << a + b + c - max(a, max(b, c)) << endl;

  return 0;
}


Measured memory_bytes: 3584
N,A,B=map(int,input().split())
S=input()

tukasya=0
kaigai=0
for i in range(N):
  if (S[i]=='a' and tukasya<A+B):
    print('Yes')
    tukasya=tukasya+1
  elif S[i]=='b':
    if (kaigai<B and tukasya<A+B):
      print('Yes')
      tukasya=tukasya+1
      kaigai=kaigai+1
    else:
      print('No')
      kaigai=kaigai+1
  else:
    print('No')

Measured memory_bytes: 9340
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

a = INT()
b = INT()
h = INT()
print((a + b) * h // 2)

Measured memory_bytes: 67564
#include <stdio.h>
#define N 10000
int main(){
  int i,j,x,y,S[N],T[N],c=0;
  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&y);
  for(j=0;j<y;j++){
    scanf("%d",&T[j]);
    
  }
  for(j=0;j<y;j++){
    for(i=0;i<x;i++){
      if(S[i]==T[j]){
	c++;
	break;
      }
    }
  }

  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

template<class I, class BiOp = I (*) (I, I)>
class SegTree {
private:
  int n;
  std::vector<I> dat, lazy;
  BiOp op;
  I e;

public:
  SegTree(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
  }

  void eval(int k, int l, int r) {
    if (lazy[k] == 0) return;
    // cerr << "eval: k = " << k << ", l = " << l << ", r = " << r << endl;
    dat[k] += lazy[k] * (r - l);
    if (k < n - 1) {
      lazy[2 * k + 1] += lazy[k];
      lazy[2 * k + 2] += lazy[k];
    }
    lazy[k] = 0;
  }

  void update(int a, int b, I x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "update: a = " << a << ", b = " << b << ", x = " << x << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      // cerr << "hey!" << endl;
      lazy[k] += x;
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
    }
  }

  I query(int a, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "query: a = " << a << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (r - l == 1) return dat[k];
    int m = (l + r) / 2;
    if (a < m) {
      return query(a, 2 * k + 1, l, m);
    }
    else {
      return query(a, 2 * k + 2, m, r);
    }
  }

  void print() {
    int j = 2;
    for (int i = 0; i < 2 * n - 1; i++) {
      cerr << "(" << dat[i] << ", " << lazy[i] << ")";
      if (i == j - 2) {
        cerr << endl;
        j *= 2;
      }
      else {
        cerr << " ";
      }
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<ll> seg(n);

  // seg.print();

  rep(i, q) {
    // cerr << "i = " << i << endl;

    int t;
    cin >> t;
    if (t == 0) {
      int a, b, x;
      cin >> a >> b >> x;
      seg.update(a - 1, b, x);
    }
    else {
      int a;
      cin >> a;
      cout << seg.query(a - 1) << endl;
    }

    // seg.print();
    // cerr << endl;
  }

  return 0;
}



Measured memory_bytes: 7060
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>& X) {
        sort(X.begin(), X.end());
        int n = X.size();
        int res = 1 << 28;
        for (int x = X[0]; x <= X.back(); ++x) {
            int dis = 0;
            for (auto y : X) {
                dis += (x - y) * (x - y);
            }
            res = min(res, dis);
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> X(n);
    for (int i = 0; i < n; ++i) {
        cin >> X[i];
    }
    Solution sol;

    cout << sol.solve(X) << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		// 計算
		long result = 0;
		if((b-a)%2 == 0){
		    result = (b-a)/2;
		}else{
		    result = min(a-1, n-b) + 1 + ((b-a)-1)/2;
		}
		
		// 出力
		System.out.println(result);
	}
}


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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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

ll n, W;
ll w[maxn];
ll v[maxn];
ll memo[101][100005];

ll max_profit(ll i, ll wt_till_now) {
	if (wt_till_now > W) return INT_MIN;
	if (i == n) return 0;

	if (memo[i][wt_till_now] != -1) return memo[i][wt_till_now];

	ll q1 = max_profit(i + 1, wt_till_now);
	ll q2 = max_profit(i + 1, wt_till_now + w[i]) + v[i];

	ll res = 0;
	if (q1 > q2)	res = q1;
	else res = q2;

	return memo[i][wt_till_now] = res;
}

int main() {
	fastio();

	f(i, 0, 100) {
		f(j, 0, 100004) memo[i][j] = -1;
	}

	cin >> n >> W;

	f(i, 0, n - 1) {
		cin >> w[i] >> v[i];
	}

	cout << max_profit(0, 0);


	return 0;
}


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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n;
int a[22], b[22];
int c[22];
int ans;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", &a[i]);
    for(int i=1; i<=n; i++) scanf("%d", &b[i]);
    for(int i=1; i<n; i++) scanf("%d", &c[i]);

    for(int i=1; i<=n; i++){
        ans += b[a[i]];
        if(a[i+1] == a[i]+1) ans+=c[a[i]];
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n, d;

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

	cout << (n + 2 * d) / (2 * d + 1) << endl;
	return 0;
}

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

int main() {
	int x, y, z, num_people;
	cin >> x >> y >> z;
	
	for (num_people = 0;;num_people++) {
		if (((y + z) * num_people + z) > x) {
			cout << num_people - 1 << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  print $ solve n m

solve :: Int -> Int -> Int
solve 0 m = m `div` 4
solve n m
    | m < 2 * n = m `div` 2
    | otherwise = n + solve 0 (m - 2 * n)


Measured memory_bytes: 508
import java.util.*;
import static java.lang.System.out;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        //int a = Integer.parseInt(sc.next());
        //int b = Integer.parseInt(sc.next());
        //int c = Integer.parseInt(sc.next());
        String in = sc.nextLine();
        if(in.contains("A") && in.contains("B")) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        //System.out.println(a + " " + b + " " + c);

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>

using namespace std;

constexpr int MX = 100009;
vector<vector<pair<int,int>>> G(MX);
vector<int> checks(MX);
vector<bool> used(MX);

vector<int> ans;

int dfs( int v ){
    used[v] = true;
    int res = checks[v];
    for( auto p : G[v] ){
        if(used[p.first]) continue;
        int r = dfs( p.first );
        if(r) ans.emplace_back(p.second);
        res = res xor r;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> bombs;
    int a, b, l, r;

    bombs.push_back( make_pair( -1, 0 ));
    for(int i=0;i<N;++i){
        cin >> a >> b;
        bombs.emplace_back( make_pair( a, b ));
    }
    
    sort( bombs.begin(), bombs.end() ); 
    
    for(int i=0;i<bombs.size()-1;++i){
        checks[i] = bombs[i].second xor bombs[i+1].second;
    }
    checks[N] = bombs.back().second;

    for(int i=0;i<M;++i){
        cin >> l >> r;
        l = lower_bound( bombs.begin(), bombs.end(), make_pair(l,0)) - bombs.begin() - 1;
        r = upper_bound( bombs.begin(), bombs.end(), make_pair(r,1)) - bombs.begin() - 1;
        if(l!=r){
            G[l].emplace_back( make_pair( r, i+1));
            G[r].emplace_back( make_pair( l, i+1));
        }
    }

    for(int i=0;i<=N;++i){
        used[i] = false;
    }
    
    // for(int i=0;i<=N;++i){
    //     cout << "i = " << i << endl;
    //     for( auto e: G[i]){
    //         printf( "(%d, %d)\n" , e.first, e.second );
    //     }
    // }

    int i=0;
    while(i<=N){
        used[i] = true;
        if(dfs(i)==1) {
            cout << "-1" << endl;
            return 0;
        }else{
            while(used[i] == true){
                ++i;
            }
        }
    }

    sort( ans.begin(), ans.end() );
    cout << ans.size() << endl;
    for( auto e : ans){
        cout << e << " ";
    }
    cout << endl;
        
    return 0;
    
}


Measured memory_bytes: 16376
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int x1,x2,y1,y2;
	scan(x1);scan(y1);scan(x2);scan(y2);
	int vecx=x2-x1;
	int vecy=y2-y1;
	int vec23x=-vecy,vec23y=vecx;
	int vec34x=-vecx,vec34y=-vecy;
	int x3=x2+vec23x,y3=y2+vec23y;
	int x4=x3+vec34x,y4=y3+vec34y;
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}


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

using namespace std;

int A, B, C;

int main()
{
	scanf("%d %d %d", &A, &B, &C);
	if(A == B)
	{
		printf("%d\n", C);
	}
	else if(A == C)
	{
		printf("%d\n", B);
	}
	else
	{
		printf("%d\n", A);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), q = scanner.nextInt();
			long[] s = IntStream.range(0, a).mapToLong(i -> scanner.nextLong()).toArray();
			long[] t = IntStream.range(0, b).mapToLong(i -> scanner.nextLong()).toArray();
			IntStream.range(0, q).mapToLong(i -> {
				long x = scanner.nextLong();
				return nearest(x, s, t);
			}).forEach(System.out::println);
		}
	}

	/**
	 * @param x
	 * @param s
	 * @param t
	 * @return xとsの要素の一つ、tの要素の一つの最短距離
	 */
	private static long nearest(long x, long[] s, long[] t) {
		long s1, s2, t1, t2;
		int sIndex = Arrays.binarySearch(s, x);
		int tIndex = Arrays.binarySearch(t, x);
		if (sIndex >= 0) {
			s1 = s2 = s[sIndex];
		} else {
			if (sIndex == -1) {
				s1 = s2 = s[0];
			} else if (sIndex == -s.length - 1) {
				s1 = s2 = s[s.length - 1];
			} else {
				s1 = s[~sIndex - 1];
				s2 = s[~sIndex];
			}
		}
		if (tIndex >= 0) {
			t1 = t2 = t[tIndex];
		} else {
			if (tIndex == -1) {
				t1 = t2 = t[0];
			} else if (tIndex == -t.length - 1) {
				t1 = t2 = t[t.length - 1];
			} else {
				t1 = t[~tIndex - 1];
				t2 = t[~tIndex];
			}
		}
		return min(distance(x, s1, t1), distance(x, s1, t2), distance(x, s2, t1), distance(x, s2, t2));
	}

	/**
	 * @param x
	 * @param s
	 * @param t
	 * @return xとs、tとの最短距離
	 */
	private static long distance(long x, long s, long t) {
		return Math.abs(s - t) + min(Math.abs(s - x), Math.abs(t - x));
	}

	/**
	 * @param x 配列
	 * @return 配列の最小値
	 */
	private static long min(long... x) {
		return Arrays.stream(x).min().getAsLong();
	}
}


Measured memory_bytes: 67132