akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int INF = INT_MAX / 4;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( ui i = (ui)( m ); i < (ui)( n ); i++ )
#define EACH( v, c ) for ( __typeof( c.front() ) &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
	{
		string line;
		getline( cin, line );

		if ( line == "." )
		{
			return 0;
		}

		bool yes = true;
		char c;
		stack<char> st;
		istringstream iss( line );

		while ( iss >> c )
		{
			if ( c == '(' || c == '[' )
			{
				st.push( c );
			}
			else if ( c == ')' || c == ']' )
			{
				int c2 = ( c == ')' ? '(' : '[' );

				if ( !st.empty() && st.top() == c2 )
				{
					st.pop();
				}
				else
				{
					yes = false;
				}
			}
		}

		if ( yes && st.empty() )
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}				

	return 0;
}

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

using namespace std;

int main() {
  string o;
  string e;
  cin >> o >> e;
  string res(o.size() + e.size(), '\0');
  for (int i = 0; i < o.size(); ++i) res[2 * i] = o[i];
  for (int i = 0; i < e.size(); ++i) res[2 * i + 1] = e[i];
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n;

	while (scanf("%d", &n), n){
		int ms[16][16] = {0};
		int x = n / 2, y = n / 2 + 1;
		int count = 0;

		while (count < n * n){
			if (ms[y][x]){
				x = (x + (n - 1)) % n;
			}
			else {
				ms[y][x] = count + 1;
				count++;
				x = (x + 1) % n;
			}
			y = (y + 1) % n;
		}
		for (y = 0; y < n; y++){
			for (x = 0; x < n; x++){
				printf("%4d", ms[y][x]);
			}
			puts("");
		}
	}

	return (0);
}

Measured memory_bytes: 616
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        double arr[] = new double[n+(k-1)];
        double aveArr[] = new double[n+(k-1)];

        int cnt = 0;
        double now = 0.0;
        double max = 0.0;

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            double ki = (p+1.0)/2.0;
            arr[i] = ki;
            cnt++;
            now += ki;
            if (cnt > k) {
                now -= arr[i - k];
            }
            if (now > max) max = now;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 86952
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};



int main(void) {
    Int n,m;
    cin >> n >> m;
    vector<Int> a(n,100);
    REP(m,i){
        Int s, c;
        cin >> s >> c;
        s--;
        if (a.at(s) != 100 && a.at(s) != c) {
            cout << -1 << endl;
            return 0;
        }
        if (n != 1 &&s == 0 && c == 0) {
            cout << -1 << endl;
            return 0;
        }

        a.at(s) =  c;
    }
    string ans = "";
    REP(n,i){
        if (a.at(i)==100) {
            if (i == 0 && n != 1) {
                a.at(i) = 1;
            }else{
                a.at(i) = 0;
            }
        }
        ans += (char)(a.at(i)+'0');
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    double res = 0.0;
    cin >> n;
    vector<double> a(n);
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=0;i<n;i++){
        res += 1.0/a[i];
    }
    res = 1.0/res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int N = s.length();
  s.push_back('R');
  int rcount = 0;
  int lcount = 0;
  vector<int> v(N+1);
  rep(i,s.length()){
    v[i] = 0;
    if(s[i] == 'R'){
      if(lcount != 0){
        v[i-lcount] = (lcount+rcount)/2;
        v[i-lcount-1] = (lcount+rcount)/2;
        if((lcount+rcount)%2 == 1){
          if(lcount>rcount){
            if(lcount%2 == 1)++v[i-lcount];
            else ++v[i-lcount-1];
          } else{
            if(rcount%2 == 1)++v[i-lcount-1];
            else ++v[i-lcount];
          }
        }
        lcount = 0;
        rcount = 0;
      }
      ++rcount;
    }else ++lcount;
  }
  rep(i,N) cout << v[i] SPF;
  cout << endl;
  return 0;
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
#define ll long long
int main()
{
    ll a,b,p;
    cin>>a>>b;
    //p=boost::math::lcm(a,b);
    p=a*500;
    if(p<b)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mx = 1e18;
long long arr[200010];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	long long answer = 1;

	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
	}
	for (int i = 1; i <= n; ++i) {
		if (answer * arr[i] > mx or 1.0L * mx / arr[i] < answer) {
			bool found = false;
			for (int j = i + 1; j <= n; ++j) {
				if (arr[j] == 0) {
					found = true;
					i = j - 1;
					break;
				}
			}
			if (found == false) {
				answer = -1;
				break;
			}
		}
		answer *= arr[i];
	}
	cout << answer;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
 
using namespace std;
 
string s;   
	 
int main() {
	cin >> s;
		if(s == "SUN"){
			cout << 7;
		}
		if(s ==  "MON"){
			cout << 6;
		}
		if(s == "TUE"){
			cout << 5;
		}
		if(s == "WED"){
			cout << 4;
		}
		if(s == "THU"){
			cout << 3;
		}
		if(s == "FRI"){
			cout << 2;
		}
		if(s == "SAT"){
			cout << 1;
		}
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] t = new int[N];
		int[] x = new int[N];
		int[] y = new int[N];
		for(int i = 0; i < N; i++) {
			t[i] = Integer.parseInt(sc.next());
			x[i] = Integer.parseInt(sc.next());
			y[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		boolean flag = true;
		int dt = 0;
		int dx = 0;
		int dy = 0;
		for(int i = 0; i < N; i++) {
			int d = Math.abs(x[i]-dx)+Math.abs(y[i]-dy);
			if(t[i]-dt < d) {
				flag = false;
				break;
			}else if(t[i]-dt == d) {
				dt = t[i];
				dx = x[i];
				dy = y[i];
			}else {
				int h = t[i]-dt-d;
				if(h % 2 == 0) {
					dt = t[i];
					dx = x[i];
					dy = y[i];
				}else {
					flag = false;
					break;
				}
			}
		}

		if(flag) System.out.println("Yes");
		if(!flag) System.out.println("No");
	}

}


Measured memory_bytes: 63268
#include <iostream>
#include <string>
#include <string.h>
#include <strings.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,s,d;
    cin>>a>>s>>d;
int e=s-a;
int q=d-a;
if(s<0){
    s=s*-1;
}
if(d<0){
    d=d*-1;
}
   if(a>s){

       e=a-s;
    }
if(a>d){
    q=a-d;
}
if(e<q){
    cout<<'A';
}
else if(q<e){
    cout<<'B';
}


    return 0;
}


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

int main(void){
   string S;
   cin>>S;
   int N=S.size();
   long long ans=0;
   for(int i=0;i<(1<<N-1);i++){
      long long sum=0;
      long long cur=0;
      for(int j=0;j<N;j++){
         if(j>0&&i&(1<<(j-1))){
            sum+=cur;
            cur=0;
         }
         cur=10*cur+(S[j]-'0');
      }
      sum+=cur;
      ans+=sum;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
def perm(n):
    a=1
    for i in range(1,n+1):
        a*=i*i
        a%=10**9+7
    return a

if n==m:
    print((perm(n)*2)%(10**9+7))
elif abs(n-m)==1:
    print((perm(min(n,m))*max(n,m))%(10**9+7))
else:
    print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a[3]; rep(i,3)cin>>a[i];
    sort(a,a+3);
    o((a[2]*10+a[1]+a[0]));
}


Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

ll power(ll a, ll b){
    if(b==0) return 1;
    if(b%2==0) return power((a*a)%mod, b/2)%mod;
    return (power(a, b-1)*a)%mod;
}

vector<ll> fact(5000007);

ll nCr(ll n, ll r){
    ll num = fact[n];
    ll den = (fact[r]*fact[n-r])%mod;
    return (num*power(den, mod-2))%mod;
}

int main(){
    cpp();
    ll k;
    fact[0]=1;
    for(ll i=1; i<5000007; i++){
        fact[i]=i*fact[i-1]%mod;
    }
    string s;
    cin>>k>>s;
    ll ans = 0;
    for(ll i=0; i<=k; i++){
        ll n = k-i+s.size()-1;
        ll r = k-i;
        ll a = nCr(n, r);
        ll b = power(26, i);
        ll c = power(25, k-i);
        ans+= (((a*b)%mod)*c)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 43364
towns = {1: 0, 2: 0, 3: 0, 4:  0}

for i in range(3):
    a, b = map(int, input().split())

    towns[a] += 1
    towns[b] += 1

result = True

for town in towns.values():
    if town > 2:
        result = False

if result:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int sx = sc.nextInt()-1;
		int sy = sc.nextInt()-1;
		int gx = sc.nextInt()-1;
		int gy = sc.nextInt()-1;
		
		char[][] grid = new char[h][w];
		for(int i = 0; i < h; i++){
		    String s = sc.next();
		    grid[i] = s.toCharArray();
		}
		
		// 計算
		long result = Long.MAX_VALUE;
		int[] dx = {0, -1, 1, 0}; // 4
		int[] dy = {-1, 0, 0, 1}; // 4
		long[] dist = new long[h*w*4];
		long INF = 1001001001001001001L;
		Arrays.fill(dist, INF);
		PriorityQueue<Vertex> pq = new PriorityQueue<Vertex>((s, t) -> Long.compare(s.dist, t.dist));
		for(int i = 0; i < 4; i++){
		    pq.add(new Vertex((sx*w+sy)*4 + i, 0));
		    dist[(sx*w+sy)*4 + i] = 0;
		}
		while(!pq.isEmpty()){
		    Vertex v = pq.poll();
		    int i = v.id/4/w;
		    int j = v.id/4%w;
		    int d = v.id%4;
		    if(v.dist != dist[v.id]) continue;
		    //System.out.println("i:" + i + " j:" + j + " d:" + d + " dist:" + v.dist);
		    for(int p = 0; p < 4; p++){
		        int nid = (i*w+j)*4 + p;
		        if(dist[nid] > (v.dist+(k-1))/k*k){
		            pq.add(new Vertex(nid, (v.dist+(k-1))/k*k));
		            dist[nid] = (v.dist+(k-1))/k*k;
		        }
		    }
		    int ni = i + dx[d];
		    int nj = j + dy[d];
		    if(0 <= ni && ni < h && 0 <= nj && nj < w){
		        if(grid[ni][nj] == '.'){
		            int nid = (ni*w+nj)*4 + d;
		            if(dist[nid] > v.dist+1){
		                pq.add(new Vertex(nid, v.dist+1));
		                dist[nid] = v.dist+1;
		            }
		        }
		    }
		}
		for(int i = 0; i < 4; i++){
		    result = min(result, dist[(gx*w+gy)*4 + i]);
		}
		if(result == INF){
		    result = -1;
		}else{
		    result = (result+(k-1))/k;
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}

class Vertex {
	int id;
	long dist;
	
	Vertex(int id, long dist) {
		this.id = id;
		this.dist = dist;
	}

	public String toString() {
		return "id:" + id + " dist:" + dist;
	}
}



Measured memory_bytes: 101576
s = list(input())
n = int(input())

for i in range(n):
    orders = input().split()
    order, a, b, *moji = orders
    a = int(a)
    b = int(b)
    
    if order == "print":
        print(''.join(s[a:b+1]))
    elif order == 'reverse':
        s[a:b+1] = s[a:b+1][::-1]
    else:
        s[a:b+1] = moji[0]
    


Measured memory_bytes: 5620
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map {
        (0 until sc.next().toInt()).map {
            sc.next().toInt() to sc.next().toInt()
        }
    }
    println(problem147c(n, a))
}

fun problem147c(
    n: Int,
    a: List<List<Pair<Int, Int>>>
): Int {
    fun judge(bit: Int): Boolean {
        for (i in 0 until n) {
            if ((bit and (1 shl i)) == 0) continue
            for (xy in a[i]) {
                val (x, y) = xy
                if (y == 1 && ((bit and (1 shl (x-1))) == 0)) return false
                if (y == 0 && ((bit and (1 shl (x-1))) != 0)) return false
            }
        }
        return true
    }

    var res = 0
    var bit = 0
    while(bit < (1 shl n)) {
        if (judge(bit)) {
            var count = 0
            for (i in 0 until n) {
                if ((bit and (1 shl i)) != 0) count++
            }
            res = Math.max(res, count)
        }
        bit++
    }
    return res
}


Measured memory_bytes: 36440
# ABC133D - Rain Flows into Dams
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(*X)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 14156
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    a = list(input())
    K = int(input())
    for i in range(len(a)):
        if a[i]=='a' and i!=len(a)-1:
            continue
        else:
            val = 123 - ord(a[i])
            if val <= K:
                a[i] = 'a'
                K -= val
            if i == len(a) - 1 and K > 0:
                a[-1] = chr(ord(a[-1]) + K % 26)
    print(''.join(a))


resolve()

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[125];
ll k;

int main(){
  scanf("%s",s);
  scanf("%lld",&k);
  int n = strlen(s);
  REP(i,min((ll)n,k)-1)if(s[i]!='1'){
    printf("%c\n",s[i]);
    return 0;
  }
  printf("%c\n",s[(int)min((ll)n,k)-1]);
  return 0;
}


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

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

Measured memory_bytes: 3600
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, C, D = map(int, list(input()))

for i in ('+', '-'):
    for j in ('+', '-'):
        for k in ('+', '-'):
            val = A
            if i=='+':
                val += B
            else:
                val -= B

            if j=='+':
                val += C
            else:
                val -= C

            if k=='+':
                val += D
            else:
                val -= D
            
            if val==7:
                print('{}{}{}{}{}{}{}=7'.format(A, i, B, j, C, k, D))
                exit()

Measured memory_bytes: 61884
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0 ; i < n; i++) {
        cin >> a[i];
    }
    if(k == n) {
        cout << "1\n";
    }else if(k > n / 2) {
        cout << "2\n";
    }else {
        int ind = -1;
        for(int i = 0; i < n ; i++) {
            if(a[i] == 1) {
                ind = i;
            }
        }
        int ans = INT64_MAX;
        for(int i = max(0ll, ind - k + 1); i <= min(n - 1, ind + k - 1); i++) {
            int tmp = 1;
            if(i > 0) {
                tmp += ceil((i - 1.0) / (k - 1.0));
            }
            if(i < n - k) {
                tmp += ceil((n - i - k + 1.0) / (k - 1.0));
            }
            ans = min(ans, tmp);
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int n;
int dp[44];

int main(){
    cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2;i<=n;i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto& i : p) cin >> i;

    int ans = 0;
    for(int i = 1; i < n - 1; ++i)
    {
        if((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] > p[i + 1] && p[i] < p[i - 1]))
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	ll a,b,n;
	ios::sync_with_stdio(false);
	cin>>a>>b>>n;
	ll ans1,ans2;
	if(n>=b)
	{
		ans1 = floor(a*(b-1)*1.0/b);
		ans2 = a*floor((b-1)*1.0/b);
	}
	else
	{
		ans1 = floor(a*n*1.0/b);
		ans2 = a*floor(n*1.0/b);
	}
	cout<<ans1-ans2;
}


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

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

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll N;
  cin >> N;
  ll L[87];
  L[0] = 2;
  L[1] = 1;
  rep(i,2,87){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[N] << endl;

  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
   
    int N;cin>>N;
    vector<ll> S(N,0);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    int left=0,right=0;
    ll now=0;
    ll ans=0;
    while(left<N){
        if(right!=N){
        bool check=true;
        for(int i=0;i<20;i++){
            if(now&(1<<i)&&S[right]&(1<<i)) check=false;
        }
        if(check){
            now=now^S[right];
            right++;
        }else{
            ans+=(right-left);
            now=now^S[left];
            left++;
        }
        }else{
            ans+=(right-left);
            left++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  char c;
  cin >> c;
  if(c>='A'&&c<='Z') cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}

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

struct LR
{
	long long s;
	long long e;
};

char a[100010];
long long len;
LR b[100010];
long long c;
long long cc[100010];
long long fin[100010];

int main(void)
{
	scanf("%s", a);
	
	len = strlen(a);
	
	b[0].s = 0;
	
	for(long long i = 1 ; i < len ; i++)
	{
		if(a[i] == 'L' && a[i + 1] == 'R')
		{
			b[c++].e = i;
			b[c].s = i + 1;
		}
	}
	
	b[c].e = len - 1;
	
	for(long long i = 0 ; i <= c ; i++)
	{
		if((b[i].e - b[i].s + 1) % 2 == 0)
		{
			cc[i] = 0;
		}
		
		else
		{
			cc[i] = 1;
		}
	}
	
	for(long long i = 0 ; i <= c ; i++)
	{
		long long ss;
		long long ee;
		
		for(long long j = b[i].s ; j < b[i].e ; j++)
		{
			if(a[j] == 'R' && a[j + 1] == 'L')
			{
				ss = j;
				ee = j + 1;
				break;
			}
		}
		
		if(cc[i] == 0)
		{
			fin[ss] = (b[i].e - b[i].s + 1) / 2;
			fin[ee] = (b[i].e - b[i].s + 1) / 2;
		}
		
		else
		{
			long long lef = ss - b[i].s + 1;
			long long rig = b[i].e - ee + 1;
			
			fin[ss] = (b[i].e - b[i].s + 1) / 2;
			fin[ee] = (b[i].e - b[i].s + 1) / 2;
			
			if(lef % 2 == 1)
				fin[ss]++;
			else
				fin[ee]++;
		}
	}
	
	for(long long i = 0 ; i < len ; i++)
	{
		printf("%lld ", fin[i]);
	}
	
	return 0;
}

Measured memory_bytes: 2432
def operator(x):
    if x < 0:
        return '-'
    else:
        return '+'


def main():
    abcd = str(input())
    a = int(abcd[0])
    b = int(abcd[1])
    c = int(abcd[2])
    d = int(abcd[3])

    lst = []
    for op_1 in range(2):
            for op_2 in range(2):
                for op_3 in range(2):

                    b1 = b
                    c1 = c
                    d1 = d
                    if op_1 == 1:
                        b1 = -b
                    if op_2 == 1:
                        c1 = -c
                    if op_3 == 1:
                        d1 = -d

                    if b1 + c1 + d1 == 7 - a:
                        lst.append(b1)
                        lst.append(c1)
                        lst.append(d1)
                        break

    op1 = operator(lst[0])
    op2 = operator(lst[1])
    op3 = operator(lst[2])
    answer = str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=' + '7'
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <stdio.h>
#include <stdlib.h>
#define MEM1 110
#define MEM2 1024

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

int main(void) {

    // 入力

    int N, W;
    scanf("%d %d", &N, &W);

    int
        v_arr[MEM1],
        w_arr[MEM1];

    for (int i = 0; i < N; i++) scanf("%d %d", &v_arr[i], &w_arr[i]);

    // 計算

    int* max_values[MEM1];
    
    for (int i = 0; i < MEM1; i++) {
        max_values[i] = (int *)calloc( W+1, sizeof(int) );
        // max_values[i+1][w] := i番目までの品物から重さがwを超えないように選んだ時の価値の総和の最大値
    }

    // 初期化: 0番目のときの-1番目に関する価値 -> 全て0
    for (int w = 0; w <= W; w++) max_values[0][w] = 0; 

    for (int i = 0; i < N; i++) {
        for (int w = 0; w <= W; w++) {
            if (w >= w_arr[i]) {
                max_values[i+1][w] = max2( max_values[i][w - w_arr[i]] + v_arr[i], max_values[i][w] );
                // この商品を取った時の価値と取らずにwまで取った時の最大値を比べる。
            } else {
                max_values[i+1][w] = max_values[i][w];
                // この商品はもう取れないので取らなかったときの値が最大
            }
        }
    }

    // 出力

    printf("%d\n", max_values[N][W]);

    for (int i = 0; i < MEM1; i++) {
        free(max_values[i]);
    }

    return 0;
}


Measured memory_bytes: 5772
#include <iostream>
#include <algorithm>
using namespace std;
 
void fastin(int &number) {
    bool negative = false;
    int c;
    number = 0;
    c = getchar_unlocked();
    if (c == '-') {
        negative = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) number = number * 10 + c - 48;
    if (negative) number *= -1;
}
 
void fastout(int64_t n) {
    int64_t N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { count++; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar('0');
}
     
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int N; fastin(N);
    int A[N];
    for (int i = 0; i < N; ++i) fastin(A[i]);
    sort(A, A + N, std::greater<int>());
     
    int point1 = -1; int point2 = -1;
    int len1, len2;
    for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]){
           point1 = i; len1 = A[i]; break;
        }
    }
    if (point1 < 0){
        fastout(0); return 0;
    }
    for (int i = point1 + 2; i < N - 1; ++i) {
        if (A[i] == A[i + 1]){
            point2 = i; len2 = A[i]; break;
        }
    }
    if (point2 < 0){
        fastout(0); return 0;
    }    
    int64_t ans = 1LL * len1 * len2;
    fastout(ans);
     
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(K: int, S: str):
    if len(S) > K:
        print(S[:K]+"...")
    else:
        print(S)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61732
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll k,a;
  cin>>k;
  ll arr[50];
  a=k/50;
  fr(i,50){
    arr[i]=a+1+i;
  }
  fr(i,50-k%50){
    --arr[i];
  }
  cout<<50<<"\n";
  fr(i,50){
    cout<<arr[i]<<" ";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

ll n, m= 0;

int main() {

  cin >> n;

  rep(i, n-1) {
    m += i+1;
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define sz(a)           (int)(a).size()
#define all(x)          (x).begin(), (x).end()
#define fore(i,a,b)     for(int i=a; i<b; i+=1)
#define forr(i,a)       for(int i=a; i>=0; i--)
#define F first
#define S second
 
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;


 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    double n,m; cin>>n>>m;
    vector<double> vec(n);
    double ss=0;
    fore(i,0,n){
        cin>>vec[i];
        ss+=vec[i];
    }
    double gg=ss/(4*m);
    int res=0;
    fore(i,0,n){
        if(vec[i]>=gg) res++;
    }    if(res>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void calculate(){

}

int main(int,char**){
    long long N,T,A;
    input(N,T,A);
    A *= 1000;
    std::vector<long long> H(N);
    inputVector(H);
    long long min_diff = 1LL << 60;
    long long min_index;
    rep(i,N)
    {
        long long temprature = 1000 * T - 6 * H[i];
        if(min_diff > abs(temprature - A))
        {
            min_diff = abs(temprature - A);
            min_index = i;
        }
    } 
    std::cout << min_index + 1 << '\n';
}


void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

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

int main() {
  long long num,buy;
  long long kekka = 0;
  long long yen,hon;
  long long index = 0;
  bool chk = true;
  
  cin >> num >> buy;
  
  vector<pair<long long,long long>> p(num);
  
  for(long long i = 0; i < num; i++){
    cin >> yen >> hon;
    p.at(i) = make_pair(yen, hon);    
  }
  
  sort(p.begin(), p.end());
  
  while(chk == true){
    tie(yen, hon) = p.at(index);
    
    if(buy > hon){
      // 継続
      kekka += yen * hon;
      buy -= hon;
      index++;
    }else{
      kekka += yen * buy;
      // 終わり
      buy = 0;
      chk = false;
    }
  }
  
  cout << kekka;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main(){
  string s;
  int w;
  cin >> s >> w;
  int x = w;
  for (int i = 0; i < s.size(); i++) {
    if (i % w == 0) {
      cout << s.at(i);
    }
  }
  cout << endl;
}


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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	if (k == 0)
	{
		cout << "Yes";
		return 0;
	}
	vector<pair<int, int> > v[100001], r[100001];
	for (int i = 0; i < k; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		v[a].push_back(make_pair(b, c));
		r[b].push_back(make_pair(a, c));
	}
	long long used[100001];
	for (int i = 0; i < 100001; ++i)
	{
		used[i] = -1;
	}
	queue<int> q;
	for (int i = 1; i <= n; ++i)
	{
		if (used[i] == -1 && v[i].size() == 0)
		{
			used[i] = 1000000000;
			q.push(i);
			while (!q.empty())
			{
				int cur = q.front(); q.pop();
				for (auto w : r[cur])
				{
					if (used[w.first] == -1)
					{
						used[w.first] = used[cur] - w.second;
						q.push(w.first);
					}
					else
						if (used[w.first] != used[cur] - w.second)
						{
							cout << "No";
							return 0;
						}
				}
				for (auto w : v[cur])
				{
					if (used[w.first] == -1)
					{
						used[w.first] = used[cur] + w.second;
						q.push(w.first);
					}
					else
						if (used[w.first] != used[cur] + w.second)
						{
							cout << "No";
							return 0;
						}
					
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		if (used[i] == -1)
		{
			used[i] = 1000000000;
			q.push(i);
			while (!q.empty())
			{
				int cur = q.front(); q.pop();
				for (auto w : r[cur])
				{
					if (used[w.first] == -1)
					{
						used[w.first] = used[cur] - w.second;
						q.push(w.first);
					}
					else
						if (used[w.first] != used[cur] - w.second)
						{
							cout << "No";
							return 0;
						}
				}
				for (auto w : v[cur])
				{
					if (used[w.first] == -1)
					{
						used[w.first] = used[cur] + w.second;
						q.push(w.first);
					}
					else
						if (used[w.first] != used[cur] + w.second)
						{
							cout << "No";
							return 0;
						}

				}
			}
		}
	}
	cout << "Yes";
	return 0;
}

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);
	
	int N, ans=0;
	cin>>N;
	std::vector<int> P(N), idx(N);

	for(int i=0; i<N; ++i){
		cin>>P[i];
		idx[P[i]-1]=i;
	}

	int ml=0, k, cnt;
	std::vector<bool> b(N, false);
	for(int i=0; i<N; ++i){
		if(!b[i]){
			k=i;
			cnt=0;
			b[i] = true;
			while(P[k]+1 == P[idx[P[k]-1+1]] && k < idx[P[k]-1+1]){
				cnt++;
				k=idx[P[k]-1+1];
				b[k] = true;
			}
			ml = max(ml, cnt);
		}
	}

	cout<<N-ml-1<<endl;

	return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstring>
using namespace std;
bool p[5001][5001];
int main(){
  int n,a;
  while(cin>>n,n){
    int x[3000]={0};
    int y[3000]={0};
    memset(p,0,sizeof(p));
    for(int i=0;i<n;++i){
      cin>>x[i]>>y[i];
      p[y[i]][x[i]]=true;
    }
    a=0;
    for(int i=0;i<n;++i){
      for(int j=0;j<n;++j){
	int dx=x[i]-x[j],dy=y[i]-y[j];
	if(y[i]-dx>=0&&y[i]-dx<=5000&&x[i]+dy>=0&&x[i]+dy<=5000&&y[j]-dx>=0&&y[j]-dx<=5000&&x[j]+dy>=0&&x[j]+dy<=500&&p[y[i]-dx][x[i]+dy]&&p[y[j]-dx][x[j]+dy]) a=max(a,dx*dx+dy*dy);
	else if(y[i]+dx>=0&&y[i]+dx<=5000&&x[i]-dy>=0&&x[i]-dy<=5000&&y[j]+dx>=0&&y[j]+dx<=5000&&x[j]-dy>=0&&x[j]-dy<=5000&&p[y[i]+dx][x[i]-dy]&&p[y[j]+dx][x[j]-dy]) a=max(a,dx*dx+dy*dy);
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 25616
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

vector<long long> memolayer(100, 0);
long long layer(int L)
{
  if (memolayer.at(L) > 0) return memolayer.at(L);
  long long ret = 1;
  if (L > 0) ret = layer(L - 1) * 2 + 3;
  memolayer.at(L) = ret;
  return ret;
}

vector<long long> memopatio(100, 0);
long long patio(int L)
{
  if (memopatio.at(L) > 0) return memopatio.at(L);
  long long ret = 1;
  if (L > 0) ret = patio(L - 1) * 2 + 1;
  memopatio.at(L) = ret;
  return ret;
}

long long ans(int N, long long X)
{
  if (N < 0) return 0;
  if (X < 0) return 0;
  if (N == 0) return min(X, (long long)1);
  if (X <= 1) return 0;
  if (X <= layer(N - 1) + 1) return ans(N - 1, X - 1);
  if (X == layer(N - 1) + 2) return ans(N - 1, X - 1) + 1;
  if (X < layer(N)) return patio(N) - ans(N, layer(N) - X);
  return patio(N);
}

int main()
{
  int N;
  long long X;
  cin >> N >> X;

  cout << ans(N, X) << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(a, b):
    return a * b // gcd(a, b)


N, M = [int(_) for _ in input().split()]
S = input()
T = input()

L = lcm(N, M)
D = lcm(L // M, L // N)

for i in range(0, L, D):
    if S[i // (L // N)] != T[i // (L // M)]:
        print("-1")
        exit()
else:
    print(L)


Measured memory_bytes: 3316
n, m = map(int, raw_input().split())
s = ''
for i in range(n):
	s += raw_input()
c = [s.count(i) % 4 for i in 'abcdefghijklmnopqrstuvwxyz']
d1 = 0
d2 = 0
if n % 2 == 0 and m % 2 == 0:
	pass
if n % 2 == 0 and m % 2 == 1:
	d2 = n / 2
if n % 2 == 1 and m % 2 == 0:
	d2 = m / 2
if n % 2 == 1 and m % 2 == 1:
	d2 = n / 2 + m / 2
	d1 = 1

for i in c:
	while i >= 2 and d2 > 0:
		i -= 2
		d2 -= 1
	while i >= 1 and d1 > 0:
		i -= 1
		d1 -= 1
	if i > 0:
		print 'No'
		exit()

print 'Yes'


Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    vector<ll> sum(n);
    sum[0] = a[0];
    for(int i = 1; i < n; ++i)  sum[i] = sum[i - 1] + a[i];

    ll ans = 1e+17;
    ll cnt = 0;
    ll add = 0;
    for(int i = 0; i < n; ++i){
        ll foo = sum[i] + add;
        if(i % 2 == 0){
            if(foo > 0) continue;
            ll dif = 1 - foo;
            add += dif;
            cnt += dif;
        }
        else{
            if(foo < 0) continue;
            ll dif = foo + 1;
            add -= dif;
            cnt += dif;
        }
    }
    chmin(ans, cnt);

    cnt = 0;
    add = 0;
    for(int i = 0; i < n; ++i){
        ll foo = sum[i] + add;
        if(i % 2 != 0){
            if(foo > 0) continue;
            ll dif = 1 - foo;
            add += dif;
            cnt += dif;
        }
        else{
            if(foo < 0) continue;
            ll dif = foo + 1;
            add -= dif;
            cnt += dif;
        }
    }
    chmin(ans, cnt);

    cout << ans << endl;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)


typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

int N, C;
int D[40][40];
int t[3][31];
void Input() {

    cin >> N >> C;

    for(int i = 0; i < C; i++) {

        for(int j = 0; j < C; j++) {

            cin >> D[i][j];
        }
    }

    for(int i = 0; i < N; i++) {

        for(int j = 0; j < N; j++) {
        int X;
        cin >> X;

        t[(i+j)%3][X-1]++;
    }
    }
}



void Solve() {


    int res = 1 << 30;
    for(int i = 0; i < C; i++) {

        for(int j = 0; j < C; j++) {

            if(i != j) {

                for(int k = 0; k < C; k++) {


                    if(i != k && j != k) {

                        int tt = 0;
                        for(int l = 0; l < C; l++) tt  += D[l][i] * t[0][l];
                        for(int l = 0; l < C; l++) tt  += D[l][j] * t[1][l];
                        for(int l = 0; l < C; l++) tt  += D[l][k] * t[2][l];

                        if(res > tt) res = tt;
                    }


                }
            }
        }
    }

    cout << res << endl;


}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



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

int main() {
  string S, s;
  cin >> S;
  s="abcdefghijklmnopqrstuvwkyz";
  string ans="None";
  
  bool f=false;
  for(int i=0; i<26; i++){
    for(int j=0; j<S.size(); j++){
      if(s.at(i)==S.at(j)){
        break;
      }
      if(j==S.size()-1){
        ans=s.at(i);
        f=true;
        break;
      }
    }
    if(f)break;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3728
from collections import defaultdict

N = int(input())
dic = defaultdict(int)
for i in range(N):
    S = input()
    dic[S] = dic[S] + 1

print("AC x", dic["AC"])
print("WA x", dic["WA"])
print("TLE x", dic["TLE"])
print("RE x", dic["RE"])


Measured memory_bytes: 9452
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=sin()
  let ans=0
  if(a[0]=='1') ans++
  if(a[1]=='1') ans++
  if(a[2]=='1') ans++
  out(ans)
}
main()


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		ll m;cin>>m;
		ll a[1001];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		ll ans=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				//if(a[i]==a[j])continue;
				if(a[i]+a[j]>m)continue;
				ans=max(ans,a[i]+a[j]);
			}
		}
		if(ans==-1)cout<<"NONE";
		else cout<<ans;
		cout<<"\n";
	}
}

Measured memory_bytes: 3076