akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pp pair<int,int> 
#define v(T) vector<T>
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順
 
int main(){
  int n,k;
  cin >> n >> k;
  v(int) x(n);
  rep(i,n) cin>>x[i];
  int ans=0, X=INF;
  rep(i,n-k+1){
    int m=x[i],M=x[i+k-1];
    if(M<0) ans=abs(m);
    else if(m<0 && M>=0) ans=abs(m)+M+min(abs(m),M);
    else ans=M;
    X=min(ans,X);
  }
  cout<<X<<endl;
}    

Measured memory_bytes: 640
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	string s; sc(s);
	fs(i,s)cout<<"x";
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		String t = sc.next();
		
		if(t.charAt(0) == s.charAt(2) && t.charAt(2) == s.charAt(0) && t.charAt(1) == s.charAt(1)) out.println("YES"); else out.println("NO");
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 25044
import java.util.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
	
	
	
    
    
}

Measured memory_bytes: 51040
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define ll long long int
using namespace std;
int main(){
  ll i,j;
  cin>>j;
  i = (pow(j,2)) + (pow(j,3)) + j;
  cout<<i;
}

Measured memory_bytes: 4064
N=int(input())
h=list(map(int,input().split()))
a=[]
for i in range(N):
  a.append(0)
a[0]=0
a[1]=abs(h[1]-h[0])
for i in range(2,N):
  a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[N-1])


Measured memory_bytes: 14036
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;

int main(){
    ios::sync_with_stdio(false);
    int x,y,w;
    cin>>x;
    int i=1;
    int sum=0;
    for(i=1;;i++){
        sum+=i;
        if(sum>=x) break;
    }
    cout<<i<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// URDL = 0123

ll g(vector<P> a) {
  sort(all(a));
  ll res = INF;
  rep(i, a.size()-1) {
    if (a[i].second == 0 && a[i+1].second != 0) {
      chmin(res, a[i+1].first-a[i].first);
    }
  }
  return res;
}

ll f(map<ll,vector<P>>& mp) {
  ll res = INF;
  for (auto& p : mp) {
    chmin(res, g(p.second));
  }
  return res;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> x(n), y(n), dir(n);
  rep(i,n) {
    char c;
    cin >> x[i] >> y[i] >> c;
    if (c == 'U') dir[i] = 0;
    if (c == 'R') dir[i] = 1;
    if (c == 'D') dir[i] = 2;
    if (c == 'L') dir[i] = 3;
  }

  ll ans = INF;
  rep(ri,4) {
    { // UD
      map<ll,vector<P>> mp;
      rep(i,n) {
        if (dir[i] != 0 && dir[i] != 2) { continue; }
        // Here, dir[i] == 0 || dir[i] == 2
        mp[x[i]].emplace_back(y[i],dir[i]);
      }
      chmin(ans, f(mp)*5);
    }
    { // UR
      map<ll,vector<P>> mp;
      rep(i,n) {
        if (dir[i] != 0 && dir[i] != 1) { continue; }
        // Here, dir[i] == 0 || dir[i] == 1
        mp[x[i]+y[i]].emplace_back(y[i],dir[i]);
      }
      chmin(ans, f(mp)*10);
    }
    // rotate 90 deg. clockwise.
    rep(i,n) {
      ll px = x[i], py = y[i];
      x[i] = py;
      y[i] = -px;
      dir[i] = (dir[i]+1)%4;
    }
  }

  if (ans == INF) { // not hit
    cout << "SAFE" << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 29512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));

    rep(i, N) {
        cin >> C[i];
        rep(j, M) { cin >> A[i][j]; }
    }

    // bit全探索
    ll min_sum = INF;
    for (ll bit = 0; bit < (1 << N); bit++) {
        ll sum = 0;
        vector<ll> rate(M, 0);

        for (ll i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                sum += C[i];
                rep(j, M) { rate[j] += A[i][j]; }
            }
        }

        bool flg = true;
        rep(i, M) {
            if (rate[i] < X) {
                flg = false;
            }
        }

        if (flg) {
            chmin(min_sum, sum);
        }
    }

    if (min_sum == INF) {
        cout << -1 << endl;
    } else {
        cout << min_sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

typedef long long ll;
const int MOD=1e9+7;
const int MAXN=1e5+5;

int n,m;
int a[MAXN];

struct Mat{
    ll a[3][3];
    Mat(){memset(a,0,sizeof a);}
    friend Mat operator * (Mat p,Mat q){
        Mat res;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                for(int k=0;k<3;k++)
                    (res.a[i][j]+=p.a[i][k]*q.a[k][j]%MOD)%=MOD;
        return res;
    }
    friend Mat operator ^ (Mat p,ll y){
        Mat res;
        for(int i=0;i<3;i++) res.a[i][i]=1;
        while(y){
            if(y&1) res=res*p;
            p=p*p;
            y>>=1;
        }
        return res;
    }
}A,B;

ll g[3],d[3];
void work(Mat ans){
	memset(g,0,sizeof(g));
	for(int j=0;j<3;j++)
		for(int k=0;k<3;k++)
			g[j]=(1ll*g[j]+1ll*ans.a[j][k]*d[k]%MOD)%MOD;
	d[0]=g[0],d[1]=g[1],d[2]=g[2];
}

int main(){
    //freopen("placing.in","r",stdin);
    //freopen("placing.out","w",stdout);

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d",&a[i]),a[i]++;
    A.a[0][0]=A.a[1][0]=A.a[1][1]=A.a[2][0]=A.a[2][2]=1;
    A.a[2][1]=2;
    B.a[0][0]=B.a[0][2]=B.a[1][0]=B.a[1][1]=B.a[1][2]=B.a[2][0]=1;
    B.a[2][1]=B.a[2][2]=2;
    int pos=1;
    d[0]=d[1]=d[2]=1;
    Mat ans;
    for(int i=1;i<=m;i++){
        ans=B^(a[i]-pos-1);
        work(ans);
        ans=A;
        work(ans);
        pos=a[i];
    }
    ans=B^(n-pos);
    work(ans);
    printf("%lld",d[2]);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 512
using System;

namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int apples = int.Parse(input[0]);
            int L = int.Parse(input[1]);

            int Lmin = L;
            int Lmax = L + apples -1;
            int result = apples * (Lmin + Lmax) / 2;//数列の和
            if (Lmin >= 0)
            {
                result -= Lmin;
            }
            else if (Lmax <= 0)
            {
                result -= Lmax;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair 
#define x first
#define y second
#define ll long long
using namespace std;

ll h,w,sum,ans,a[405][405],ct,ww,sz;
char s[405][405];
vector <pair<int,int>  > v; 
void clear(int last){
	sz=v.size(); ww+=sz;
	for (int i=last;i<sz;i++){
		a[v[i].x][v[i].y]=0;
	}
}
void dfs (int x,int y,char d){
	if (a[x][y] == 0 && s[x][y] == '.')
	sum+=1;
	else
	if (a[x][y] == 0 && s[x][y] == '#'){
		ct+=1;
		s[x][y]='B';
	}
	
	a[x][y]=1;
	if (y-1 > 0 && s[x][y-1] != d && s[x][y-1] != 'B' && a[x][y-1] == 0)
	dfs(x,y-1,s[x][y-1]);
	if (x-1 > 0 && s[x-1][y] != d && s[x-1][y] != 'B' && a[x-1][y] == 0)
	dfs(x-1,y,s[x-1][y]);
	if (x+1 <= h && s[x+1][y] != d && s[x+1][y] != 'B' && a[x+1][y] == 0)
	dfs(x+1,y,s[x+1][y]);
	if (y+1 <= w && s[x][y+1] != d&& s[x][y+1] != 'B'  && a[x][y+1] == 0)
	dfs(x,y+1,s[x][y+1]);
} 
int main(){
	scanf("%lld%lld\n",&h,&w);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			scanf("%c",&s[i][j]);
		}
		if (i < h)
		scanf("\n");
	}
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			if (s[i][j] == '#'){
				sum=0; ct=0;
				clear(ww);
				dfs(i,j,s[i][j]);
				ans+=sum*ct;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	string s(n, '?');

	int idx;
	char c;
	for (int i = 0; i < m; i++) {
		cin >> idx >> c;
		idx--;
		if (s[idx] == '?' || s[idx] == c) {
			s[idx] = c;
		} else {
			cout << -1 << endl;;
			return 0;
		}
	}
	// cout << s << endl;

	if (s[0] == '0' && n > 1) {
		cout << -1 << endl;
		return 0;
	}

	if (s[0] == '?') {
		s[0] = (n == 1) ? '0' : '1';
	}

	for (int i = 1; i < n; i++) {
		if (s[i] == '?') {
			s[i] = '0';
		}
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 1000000007

ans = (2 ** n - 1) % MOD

def cmb(n, r):
    if n - r > r:
        T = r
    else:
        T = n - r
    res = 1
    cnt = 0
    for i in range(1, T + 1):
        res *= (n - i + 1)
        res //= i
        res %= MOD
    return res

def cmb2(n, r):
    if n<0 or r<0 or r>n:
        return None
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = [0]*r
    denominator = [0]*r
    for k in range(r):
        numerator[k] = n-r+k+1
        denominator[k] = k+1
    for p in range(2, r+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (n-r) % p
            for k in range(p-1, r, p):
                numerator[k-offset] //= pivot
                denominator[k] //= pivot
    res = 1
    for n in numerator:
        if n > 1:
            res *= n
            res %= MOD
    return res


A = cmb2(n, a)
B = cmb2(n, b)

ans -= (A + B) % MOD
print(ans % MOD)

Measured memory_bytes: 283932
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug
#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 500010;
const int MAXC = 30;
const int INF = 1e9;
const int END = 26;
const int MAXLG = 20;

int n;
char s[MAXN];
int nxt[MAXN][MAXC], emp[MAXN];
int pre[MAXN][MAXLG + 5];

void calc() {
  REP(c, 27) nxt[n][c] = INF;
  nxt[n][END] = n;
  for (int i = n - 1; i >= 0; --i) {
    REP(c, 27) nxt[i][c] = INF;

    nxt[i][s[i] - 'a'] = i + 1;
    for (int c = s[i] - 'a' + 1; c <= END; ++c)
      nxt[i][c] = nxt[i][c - 1] == INF ? INF : nxt[nxt[i][c - 1]][c - 1];
    for (int c = 0; c < s[i] - 'a'; ++c)
      nxt[i][c] = nxt[i][END] == INF ? INF : nxt[nxt[i][END]][c];
  }

  for (int i = n; i >= 0; --i) {
    pre[i][0] = nxt[i][END];
    FOR(lg, 1, MAXLG) 
      pre[i][lg] = (pre[i][lg - 1] == INF) ? INF : pre[pre[i][lg - 1]][lg - 1];
  }
}

bool check(int lo, int hi) {
  // for (int x = nxt[lo][END]; x <= hi + 1; x = nxt[x][END]) {
  //   if (x == hi + 1)
  //     return true;
  // }
  // return false;

  for (int lg = MAXLG - 1; lg >= 0 && lo < INF; --lg) {
    if (pre[lo][lg] <= hi + 1)
      lo = pre[lo][lg];
    if (lo == hi + 1)
      return true;
  }

  return false;
}

int main(void) {
  scanf("%s",s);
  n = strlen(s);

  calc();

  int q, lo, hi;
  scanf("%d",&q);
  REP(i, q) {
    scanf("%d %d",&lo,&hi);
    --lo;
    --hi;
    printf(check(lo, hi) ? "Yes\n" : "No\n");
  }
  
  return 0;
}


Measured memory_bytes: 110592
# A Dynamic Programming based Python Program for 0-1 Knapsack problem 
# Returns the maximum value that can be put in a knapsack of capacity W
# ty geekforgeeks
def knapSack(W, wt, val, n): 
    K = [[0 for x in range(W+1)] for x in range(n+1)] 
  
    # Build table K[][] in bottom up manner 
    for i in range(n+1): 
        for w in range(W+1):
            if i==0 or w==0: 
                K[i][w] = 0
            elif wt[i-1] <= w: 
                K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]) 
            else: 
                K[i][w] = K[i-1][w] 
        res = K[n][W] 
      
    w = W
    used = [False for i in range(N)]
    for i in range(n, 0, -1): 
        if res <= 0: 
            break
        # either the result comes from the 
        # top (K[i-1][w]) or from (val[i-1] 
        # + K[i-1] [w-wt[i-1]]) as in Knapsack 
        # table. If it comes from the latter 
        # one/ it means the item is included. 
        if res == K[i - 1][w]: 
            continue
        else: 
            # This item is included. 
            used[i - 1] = True
              
            # Since this weight is included 
            # its value is deducted 
            res = res - val[i - 1] 
            w = w - wt[i - 1] 
    return K[n][W], used

N, T = map(int, input().split())
wts = [None for i in range(N)]
val = [None for i in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    wts[i] = a
    val[i] = b

best, _ = knapSack(T, wts, val, N)
other, used = knapSack(T - 1, wts, val, N)
add = 0
for i, wasUsed in enumerate(used):
    if not wasUsed: add = max(add, val[i])
print(max(best, other + add))



Measured memory_bytes: 180612
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int h = inp.nextInt();
        int ans = (a + b) * h / 2;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

bool isPrime(ll n) {
    if (n < 2)return false;
    for (ll i = 2; i * i <= n; i++)if (!(n % i))return false;
    return true;
}

int main() {
    init();

    int n;
    cin >> n;

    int i = 2;
    while (n) {
        if (isPrime(i) && i % 5 == 1) {
            cout << i << (n == 1 ? "\n" : " ");
            n--;
        }
        i++;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    string s ,t;
    cin >> s >> t;
    int n=0;
    for(int i=0; i <s.size(); i++){
        if(s[i] != t[i]){
            n++;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 3920
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int r = 0, n = *max_element(A.begin(), A.end());
	int half = n/2;
	int mindiff = INT_MAX;
	rep(i, N){
		if(A[i] == n) continue;
		int diff = abs(half - A[i]);// |n/2 - ai|
		if(mindiff > diff){ mindiff = diff; r = A[i]; }
	}
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1e7
void solve()
{   
    int t;
    cin>>t;
    for(int i =0;i<t;i++)   cout<<"ACL";
    cout<<'\n';

}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    int i = 1;
    while(tt--){
        // cout<<"tc "<<i<<" ";
        solve();
        i++;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	//<<<ここにプログラムを書く>>>
	int c;
	vector<int>b(1000);
	cin >> c;
	for (int t = 0; t < c; t++)
	{
		cin >> b[t];
	}
	for (int t = c; t > 0; t--)
	{	
		if (t != c)
		{
		cout<<" ";
		}
		cout << b[t-1];
	}
	cout<<endl;
	return 0;
}


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

ll f(ll b, ll n){
    if(n<b) return n;
    else return f(b, n/b)+n%b;
}

int main(){
    ll n,s;cin>>n>>s;
    
    ll d = n-s;
    if(d < 0){
        cout<<-1<<endl;
        return 0;
    }
    
    if(d == 0){
        cout<<n+1;
        return 0;
    }

    ll res = LLONG_MAX;

    for(ll i = 1; i*i<=d; i++){
        if(d%i == 0){
            if(f(i+1,n)==s) res = min(res,i+1);
            if(f(d/i+1,n) == s) res=min(res, d/i+1);
        }
    }
    if(res == LLONG_MAX) cout<<-1<<endl;
    else cout<<res<<endl;

}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  string str;
  cin >> str;

  bool c = false;
  bool f = false;
  rep(i,str.length()){
    if(str[i] == 'C') c = true;
    if(c && str[i] == 'F') f = true;
  }

  if(c && f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) ans += S[i] == T[i];
  cout << ans << '\n';
}


Measured memory_bytes: 3596
'use strict'
function Main(input) {
  let arr = input.split("\n")[0].split(" ");
  let W = arr[0],H= arr[1],x=arr[2]*1,y=arr[3]*1;
  let ans = [];
  let area = 0;
  let dotNum = 0;
  area = (arr[0]*1 * arr[1]*1)/2;
  if( (W/2 == x) && (H/2 == y)){
  	dotNum = 1;
  }
  console.log(`${area} ${dotNum}`);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8260
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}
void DBG() {cerr << "]" << endl;}
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h);
if(sizeof...(t)) cerr << ", ";
DBG(t...);}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n,k;
 //int a[]={1,7,5,6,8,2,6,5};
 cin>>n>>k;
 int a[n];
 rep(i,0,n)cin>>a[i];
 int s=0;
 for(int i=0;i<n;i++)s+=a[i];
// DBG(s);
 VI d;
 for(int i=1;i*i<=s;i++){
    if(s%i==0){
	  d.pb(i);
	  d.pb(s/i);
	}
 }
// for(int x:d)DBG(x);
 // 8 7
 // 1 7 5 6 8 2 6 5
 // we factorize sum of all elements f array
 int res=1;
 for(int x:d){
    VI b(n);
	for(int i=0;i<n;i++){
	   b[i] = a[i]%x;
	}
	sort(all(b));
	int i=0;
	int j=n-1;
	ll c=0;
	//for(int u:b)DBG(u);
	while(i<j){
	  if(b[i]==0)i++;
	  else if(b[j]==x)j--;
	  else{
	    int q = min(b[i],x-b[j]);
		b[i]-=q;
		b[j]+=q;
		c+=q;
	  }
	}
	if(c<=k){
	 res = max(res,x);
	}
 }
 cout<<res<<"\n";
 return 0;

}




Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    ll n;
    cin >> n;
    ll m = (ll)sqrt((double)n);

    while (m > 0) {
        if (n % m == 0) {
            break;
        }
        m--;
    }

    ll l = n / m;
    int ans = 0;
    while (l > 0) {
        l /= 10;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

x,y,z=0,0,0
for a,b,c in ABC:
  x,y,z=max(y,z)+a,max(x,z)+b,max(x,y)+c
print(max(x,y,z))

Measured memory_bytes: 30580
import sys
sys.setrecursionlimit(10**9)

N = int(input())
T = [[] for i in range(N+1)]

for i in range(N-1) :
    a,b,c = map(int,input().split())
    T[a].append([b,c])
    T[b].append([a,c])

Q,K = map(int,input().split())

dist = [None]*(N+1)

def dfs(now,d) :
    dist[now] = d
    for to,c in T[now] :
        if dist[to] is not None :
            continue
        dfs(to,d+c)

dfs(K,0)

ans = []

for i in range(Q) :
    u,v = map(int,input().split())
    ans.append(dist[u]+dist[v])

print(*ans,sep="\n")



Measured memory_bytes: 140592
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a * n >= b) System.out.println(b);
        else System.out.println(a * n);
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
	int x,y,z,t;
	cin >> x >> y >> z;
	t=x; x=y; y=t;
    t=x; x=z; z=t;
  
    cout << x << " " << y <<" "<< z << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll INF = 1e12;






int main(){
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll sum  = INF;
  REP(i,x+1){
    ll res = i*a;
    if(x-i >= y){
      res += 2*c*(x-i);
    }
    else{
      res += 2*c*(x-i);
      int r = y;
      r -= (x-i);
      if(b <= 2*c){
	res += b*r;
      }
      else
	res += r*2*c;
      
    }
    sum = min(sum,res);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <climits>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int K;
const int N = 50;

signed main()
{
	cin >> K;
	vector<int> A(N, N - 1);

	rep(i, N) A[i] += K / N;

	K %= N;

	for (int i = 0; i < N; ++i) {
		if (i < K) {
			A[i] += N - K;
		} else {
			A[i] -= K;
		}
	}

	cout << N << endl;
	rep(i, N) printf("%lld%c", A[i], i==N-1?'\n':' ');
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int N,K;
LL dp[2][26][6001];
int main(){
    R(N,K);
    {
        int v=0;
        FOR(i,1,N){
            v+=abs(N+1-i-i);
        }
        if(K>v){
            W(0);
            return 0;
        }
    }
    int now=0,nxt=1;
    dp[now][0][0]=1;
    for(int i=N;i>0;i--){
        MS0(dp[nxt]);
        REP(j,26)REP(k,6001){
            if(!dp[now][j][k])continue;
            ADD(dp[nxt][j][k],dp[now][j][k]*(1+j*2));
            if(j)ADD(dp[nxt][j-1][k-2*i],dp[now][j][k]*j*j);
            if(j<25)ADD(dp[nxt][j+1][k+2*i],dp[now][j][k]);
        }
        swap(now,nxt);
    }
    W(dp[now][0][K]);
    return 0;
}


Measured memory_bytes: 2688
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;

 #define rep(i, a, b) for (int i=a; i<(b); i++)
    
 #define sz(x) (int)(x).size()
 #define mp make_pair
 #define pb push_back
 #define f first
 #define s second
 #define lb lower_bound
 #define ub upper_bound
 #define all(x) x.begin(), x.end()
 

 #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
 #define PI 3.14159265358979323846264338327950L
const int MOD = 1000000007;
const char nl = '\n';
 
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;cin>>s;
    int m=INT_MIN,c=0;

    rep(i,0,sz(s))
    {
        c=0;
        if(s[i]=='R')
        {
            while(s[i]=='R')
            {
                c++;
                i++;
            }
            
        }
        m=max(m,c);
    }
    cout<<m;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin>>n;
  vl a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  ll x=a[n-1];
  ll y=(a[n-1]+1)/2;
  ll mini=INF;
  ll z=a[0];
  rep(i,n-1){
    if(abs(a[i]-y)<mini){
      z=a[i];
      mini=abs(a[i]-y);
    }
  }
  cout<<a[n-1]<<" "<<z<<endl;
}


Measured memory_bytes: 4052
from sys import stdin
import math

def main():
    H,A = map(int,stdin.readline().split())
    arr = [int(x) for x in stdin.readline().split()]
    res = 0
    for i in range(A):
        res += arr[i]
    if(res >= H):
        print("Yes")
    else:
        print("No")
        
main()


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

long long int side[1002][1002], ver[1002][1002];

int main() {

  string input, s;

  long long int h, w;

  while( true ) {

    cin >> h >> w;

    if ( h == 0 ) break;

    vector< string > map;
    s = "**";
    for ( long long int i = 0; i < w; i++ ) {
      s += "*";
    }
    map.push_back( s );
    for ( long long int i = 0; i < h; i++ ) {
      cin >> input;
      input = "*" + input + "*";
      map.push_back( input );
    }
    map.push_back( s );
    for ( long long int i = 0; i <= h+1; i++ ) {
      long long int cnt_s = 0;
      for ( long long int j = 0; j <= w+1; j++ ) {
	if ( map[i][j] == '*' ) {
	  cnt_s = 0;
	}else {
	  cnt_s++;
	}
	side[i][j] = cnt_s;
      }
    }
    for ( long long int i = 0; i <= w+1; i++ ) {
      long long int cnt_v = 0;
      for ( long long int j = 0; j <= h+1; j++ ) {
	if ( map[j][i] == '*' ) {
	  cnt_v = 0;
	}else {
	  cnt_v++;
	}
	ver[j][i] = cnt_v;
      }
    }
    long long int ans = 0;
    for ( long long int i = 1; i <= h; i++ ) {
      for ( long long int j = 1; j <= w; j++ ) {
	if ( map[i][j] == '.' ) {
	  long long int cnt_v = h;
	  for ( long long int k = 0; true; k++ ) {
	    if ( map[i][j+k] == '*' ) break;
	    cnt_v = min( cnt_v, ver[i][j+k] );
	    ans = max( ans, (k+1) * cnt_v );
	  }
	}
      }
    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 11820
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int w = sc.nextInt(), h = sc.nextInt(), n = sc.nextInt();
		boolean[][] sq = new boolean[h][w];
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt();
			switch (a) {
				case 1:
					for (int j = 0; j < h; j++) {
						for (int k = 0; k < x; k++) {
							sq[j][k] = true;
						}
					}
					break;
				case 2:
					for (int j = 0; j < h; j++) {
						for (int k = x; k < w; k++) {
							sq[j][k] = true;
						}
					}
					break;
				case 3:
					for (int j = 0; j < y; j++) {
						for (int k = 0; k < w; k++) {
							sq[j][k] = true;
						}
					}
					break;
				case 4:
					for (int j = y; j < h; j++) {
						for (int k = 0; k < w; k++) {
							sq[j][k] = true;
						}
					}
					break;
			}
		}
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (!sq[i][j]) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

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

char horz[5][4+1];
char vert[4][5+1];
int x, y, vx, vy;

void turn_left() {
	int temp = vx;
	vx = vy;
	vy = -temp;
}

void turn_right() {
	int temp = vx;
	vx = -vy;
	vy = temp;
}

inline bool ok(char c) { return (c == '1'); }

bool avail() {
	if (vx == 1) return (x < 4 && ok(horz[y][x]));
	if (vx == -1) return (x > 0 && ok(horz[y][x-1]));
	if (vy == 1) return (y < 4 && ok(vert[y][x]));
	/* if (vy == -1) */ return (y > 0 && ok(vert[y-1][x]));
}

void print() {
	if (vx == 1) cout << "R";
	else if (vx == -1) cout << "L";
	else if (vy == 1) cout << "D";
	else /* if (vy == -1) */ cout << "U";
}

int main() {
	for (int i = 0; i < 4; i++)
		cin >> horz[i] >> vert[i];
	cin >> horz[4];

	x=0, y=0, vx=0, vy=-1;
	do {
		while (!avail()) turn_right();
		print();
		x += vx, y += vy;
		turn_left();
	} while (x != 0 || y != 0);
	cout << endl;
	return 0;
}

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

int main() {
	int N, right=0;
	string S;
	stack<char> kakko;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		kakko.push(S[i]);
	}
	int len = kakko.size();
	for (int i = 0; i < len; i++) {
		char c = kakko.top();
		kakko.pop();
		if (c == ')') {
			right++;
		}
		else {//'('
			if (right != 0) {
				right--;
			}
			else {
				S = S + ")";
			}
		}
	}
	if (right > 0) {
		for (int i = 0; i < right; i++) {
			S = "(" + S;
		}
	}
	cout << S << endl;
	return 0;
}

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

const int MOD = (int)1e9 + 7;

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    std::vector<int> pow(n + 1);
    pow[0] = 1;
    for (int i = 1; i <= n; ++ i) {
        pow[i] = pow[i - 1] * (m + 1LL) % MOD;
    }
    int result = 1LL * n * m * (m + 1) / 2 * pow[n - 1] % MOD;
    std::vector<int> ways { 1 };
    for (int i = n; i >= 1; -- i) {
        int mm = ways.size() - 1 + (ways.size() - 1 + m) / i;
        std::vector<int> new_ways(mm + 1);
        for (int j = 0; j < (int)ways.size(); ++ j) {
            for (int x = 0; x <= m; ++ x) {
                int add = 0;
                if (x <= i) {
                    add = (x + j) / i;
                }
                update(new_ways[j + add], ways[j]);
                update(result, MOD - 1LL * add * ways[j] % MOD * pow[i - 1] % MOD);
            }
        }
        ways.swap(new_ways);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e5 + 7;

int main()
{
    ios::sync_with_stdio(0);
    int a, b, c;
    cin>>a>>b>>c;
    a = a-b;
    c = c>a ? c-a : 0;
    cout<<c<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    bool ok=false;
    REP(i,1,10)REP(j,1,10){
        if(i*j==n) ok=true;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b >> c;


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

    return 0;
}

Measured memory_bytes: 384
while True:
    N, M, Q = map(int, input().split())  # N個のスイッチ, M個のライト, Q個のクエリ
    if N == 0 and M == 0 and Q ==0:
        exit()
    # 全ての配列を繋がっていることを仮定する
    correspondence = [set(list(range(M))) for _ in range(N)]
    # print(correspondence) 全てのスイッチと繋がっていることが確認できた
    switch_status = [0]*N  # スイッチの初期状態
    light_status = [0]*M  # ライトの初期状態
    for _ in range(Q):  # Q個のクエリが飛んでくる
        s, b = map(str, input().split())  # 操作したスイッチの情報と, 現在のライトの状態
        # 1つずつxorを取りたい
        # 操作したスイッチのインデックス (リスト)と、変化したライトのインデックス (set)が欲しい
        switch_index = list(map(int, s))  # 今回操作したスイッチの情報, これで数字に変換できる
        light_index = list(map(int, b))  # 現在のライトの情報, これで数字に変換できる

        changed_switch = []
        for i in range(len(switch_index)):
            if switch_index[i] == 1:
                changed_switch.append(i)
                switch_status[i] = switch_status[i] ^ 1  # 今まで0なら次の状態は1へ, 今まで1なら次の状態は0へ
        # changed_switchを使って色々やる
        # その前にまず、状態が変わったの一覧を手に入れる
        changed_light = []
        for i in range(len(light_index)):
            if light_status[i] ^ light_index[i]:  # 状態が変わったなら
                changed_light.append(i)  # 状態が変わったライト
        light_status = light_index  # ライトの状態を更新する
        set_changed_light = set(changed_light)
        # print(correspondence)
        for i in range(N):
            if i in changed_switch:
                correspondence[i] &= set_changed_light
            else:
                correspondence[i] -= set_changed_light
        # for c in changed_switch:  # 状態が変わったスイッチ, その他のスイッチからはライトを削除する必要ありそう
        #     correspondence[c] &= set_changed_light
    # print(correspondence)
    ans = [[] for _ in range(M)]  # M個のライトの状態
    for i, lights in enumerate(correspondence):
        for l in lights:
            ans[l].append(i)
    true_ans = ""
    co_dict = {0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "A", 11: "B", \
    12: "C", 13: "D", 14: "E", 15: "F", 16: "G", 17: "H", 18: "I", 19: "J", 20: "K", 21: "L", 22: "M", 23: "N", 24: "O", \
    25: "P", 26: "Q", 27: "R", 28: "S", 29: "T", 30: "U", 31: "V", 32: "W", 33: "X", 34: "Y", 35: "Z"}
    for i in range(M):
        if len(ans[i]) > 1:
            true_ans += "?"
        else:
            true_ans += co_dict[ans[i][0]]

    print(true_ans)

# [{8, 9}, {6, 7}, {0, 1, 2, 3, 4, 5}]
# 2222221100



Measured memory_bytes: 8060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if ((A + B) % 2 == 0)

			System.out.println((A + B) / 2);

		else
			System.out.println("IMPOSSIBLE");

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<stack>
#include<cstdlib>
using namespace std;

int main(){
    stack<int> st;
    string op;
    int a,b;
    while(cin>>op){
        if(op[0]=='+'){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(b+a);
        }
        else if(op[0]=='-'){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(b-a);
        }
        else if(op[0]=='*'){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(b*a);
        }
        else{
            st.push(atoi(op.c_str()));
        }
    }
    cout<<st.top()<<endl;
}


Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main()
{
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i + j > n) continue;
            if (i * 10000 + j * 5000 + (n - j - i) * 1000 == y)
            {
                cout << i << " " << j << " " << n - i - j << "\n";
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << "\n";
}


Measured memory_bytes: 384