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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1500+5;
char a[N][N];
int dp[N][N];
int cl[N][N],cr[N][N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	rep(i,1,n)scanf("%s",a[i]+1);
	s64 ans=0;
	per(j,n,1)
	if(isdigit(a[n][j]))
	{
		cl[j][n]=cr[j][n]=j;
		if(isdigit(a[n][j+1]))
		{
			cr[j][n]=cr[j+1][n];
			dp[n][j]=dp[n][j+1];
		}
		ans+=(a[n][j]-'0')*dp[n][j];
		dp[n][j]+=a[n][j]-'0';
	}
	per(i,n-1,1)
	per(j,n,1)
	if(isdigit(a[i][j]))
	{
		bool b1=isdigit(a[i][j+1]),b2=isdigit(a[i+1][j]);
		if(!b1&&!b2)
		{
			cl[j][i]=cr[j][i]=j;
			rep(k,i+1,n){cl[j][k]=n+1;cr[j][k]=0;}
		}else
		if(!b1&&b2)
		{
			dp[i][j]=dp[i+1][j];
			cl[j][i]=cr[j][i]=j;
		}else
		if(b1&&!b2)
		{
			dp[i][j]=dp[i][j+1];
			cl[j][i]=j;cr[j][i]=cr[j+1][i];
			rep(k,i+1,n){cl[j][k]=cl[j+1][k];cr[j][k]=cr[j+1][k];}
		}else
		{
			if(i==1&&j==2)
				int yyx=1;
			int ndp=dp[i+1][j]+dp[i][j+1];
			int last=0;
			cl[j][i]=j;cr[j][i]=cr[j+1][i];
			rep(k,i+1,n)
			{
				if(cr[j][k]>=cl[j+1][k]&&last<cl[j+1][k])
					ndp-=dp[k][cl[j+1][k]];
				last=cr[j][k];
				chmin(cl[j][k],cl[j+1][k]);
				chmax(cr[j][k],cr[j+1][k]);
			}
			dp[i][j]=ndp;
		}
		ans+=(a[i][j]-'0')*dp[i][j];
		dp[i][j]+=a[i][j]-'0';
	}
//	rep(i,1,n)
//rep(j,1,n)printf("%d%c",dp[i][j]," \n"[j==n]);
	cout<<ans;	
}


Measured memory_bytes: 29056
import java.util.*;
import java.io.*;
class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int que = Integer.parseInt(br.readLine());
        int odds = (que/2) + (que%2);
        double dd = ((double)odds/(double)que);
        System.out.println(dd);
   }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x = c/b,y = a/d;
	if(c%b!=0)
	x++;
	if(a%d!=0)
	y++;
	 if(x<=y)
	 cout<<"Yes\n";
	 else 
	 cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3556
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();  
    if(a%3==0){
      System.out.println("Possible");
    }else if(b%3==0){
      System.out.println("Possible");
    }else if((a+b)%3==0){
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    } 
  } 
}

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

int main(){
  int n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;
  rep(i,n){
   string s;
    cin >> s;
    if(s == "AC") ac++; 
    else if (s == "WA") wa++;
    else if( s == "TLE") tle++;
    else re++;
  }
  cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    rep(i,(b-a)){
        ans += i;
    }
    cout << ans - a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1]) cout << a[2];
    else cout << a[0];
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w, n;
    int lots[31];
    cin>>w>>n;
    for(int i=0; i<=w; i++) lots[i]=i;
    for(int i=0; i<n; i++){
        int a, b;
        cin>>a;
        cin.ignore();
        cin>>b;
        swap(lots[a], lots[b]);
    }
    for(int i=1; i<=w; i++) cout<<lots[i]<<'\n';
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 

int h,w;
string b[51];

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


vector<string> ans;

bool inboard(int a,int b){
    if(a>=0&&a<h&&b>=0&&b<w)return true;
    else return false;
}
signed main(){
    cin>>h>>w;

    rep(i,h){
        cin>>b[i];
    }

    rep(i,h){
        string s="";

        rep(j,w){
            int cnt=0;
            if(b[i][j]=='.'){
                rep(k,8){
                    if(inboard(i+dy[k],j+dx[k])){
                        if(b[i+dy[k]][j+dx[k]]=='#')cnt++;
                    }
                }
                s+=cnt+'0';
            }else{
                s+='#';
            }



            
        }
        ans.push_back(s);


        //cout<<"created s="<<s<<endl;
    }

    rep(i,h){
        cout<<ans[i]<<endl;
    }


    
}

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

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  vector<vector<int>> g(n, vector<int>(n, -1));
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) {
      int x, y; cin >> x >> y; x--;
      g[i][x] = y;
    }
  }
  int ans = 0;
  for (int bits=0; bits<1<<n; bits++) {
    bool flg = true;
    rep(i, n) {
      if (!(bits>>i&1)) continue;
      for (int j=0; j<n; j++) {
        if (i == j) continue;
        if (g[i][j] == -1) continue;
        if ((bits>>j&1) != g[i][j]) flg = false;
      }
    }
    if (flg) ans = max(ans, __builtin_popcountll(bits));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s;
int n, br1, br2;

int main(){
cin >> n;
cin >> s;
for(int i = 0 ; i < n ; ++i){
	if(s[i] == 'R'){
		br1++;
	}
	else{
		br2++;
	}
}
if(br1 > br2){
	cout << "Yes" << endl;
}
else{
	cout << "No" << endl;
}

return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[100+1]={0};
  scanf("%s",s);
  int cnt=0, len=strlen(s);
  for(int i=0; i<len/2; i++){
    if( s[i] != s[len-1-i] ){ cnt++; }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int x = fs.nextInt();
		
		System.out.println(10-x/200);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 32704
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

void Solution()
{
    int n;
    
    while (cin>>n, n)
    {
        vector<int> waitingTime(n);
        
        for (int i = 0; i < n; i++)
        {
            cin >> waitingTime[i];
        }
        
        sort(waitingTime.begin(), waitingTime.end());
        
        long long sum = 0;
        long long ans = 0;
        
        for (int i = 0; i < n; i++)  // 1 + 1+2 + 1+2+3 + 1+2+3+4
        {
            ans += sum;
            sum += waitingTime[i];
        }
        
        cout<<ans<<endl;
    }
}

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

Measured memory_bytes: 1244
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n; cin>>n; int h[n];
     for(int i=0;i<n;i++) cin>>h[i];

     int f[n];
     for(int i=0;i<n;i++) f[i]=0;

     f[0]=0; f[1]=abs(h[1]-h[0]);
     for(int i=2;i<n;i++)
     {
         f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
     }
     cout<<f[n-1]<<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n, k; cin >> n >> k;
    mint sum_max = 0;
    mint sum_min = 0;
    combination cm(100000);
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    rep(i,n) {
        sum_max += cm(i,k-1) * a[i];
        sum_min += cm(n-1-i,k-1) * a[i];
    }
    cout << sum_max - sum_min << endl;
}

Measured memory_bytes: 2176
import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        int[] c = new int[n+1];
        int[][] dp = new int[n+1][4];
        for(int i =1; i<= n; i++){
          a[i] = in.nextInt();
          b[i] = in.nextInt();
          c[i] = in.nextInt();
        }
        dp[1][1] = a[1];
        dp[1][2] = b[1];
        dp[1][3] = c[1];

        for(int i =2; i<=n; i++){
           for(int  j =1; j<=3; j++){
              if(j==1){
                dp[i][j] =a[i]+ Math.max(dp[i-1][2],dp[i-1][3]);
              }else if (j == 2) {
                dp[i][j] = b[i] + Math.max(dp[i -1][1], dp[i -1][3]);
              } else {
                dp[i][j] = c[i] + Math.max(dp[i -1][1], dp[i -1][2]);
              }
            }
        }   
      System.out.println(Math.max(dp[n][1], Math.max(dp[n][2], dp[n][3])));
    }
}

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

e = []
w = []
ek = 0
wk = 0
for i in range(n):
    if s[i] == "E":
        ek += 1
        e.append(ek)
        w.append(wk)
    if s[i] == "W":
        wk += 1
        e.append(ek)
        w.append(wk)

ma = e[n-1]-e[0]
for i in range(n):
    if i != n-1:
        cos = e[n-1]-e[i] + w[i]
    else:
        cos = w[n-2]
    ma = min(cos,ma)

print(ma)


Measured memory_bytes: 17836
#include<iostream>
using namespace std;
#define For(i,m,n) for(int i=m;i<=n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int gcd(int x,int y)
{
     if (x == 0) 
       return y; 
    if (y == 0) 
       return x; 
   
    if(x==y)
    return x;
    else
    {
        if(x>y)
        return gcd(x-y,y);
        else
        return gcd(x,y-x);
    }
}
int main()
{ ll sum=0;
int k;
cin>>k;
For(i,1,k)
{
    For(j,1,k)
    {
        For(g,1,k)
        {
            int y=gcd(i,j);
            int u=gcd(y,g);
            sum+=u;
            
        }
    }
}
cout<<sum;
return 0;
}










Measured memory_bytes: 3192
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (n--) {
		string s;
		scans(s);
		if (s == "AC")++ac;
		else if (s == "WA")++wa;
		else if (s == "TLE")++tle;
		else ++re;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);

	Please AC;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   double X,G,R;
  
 	cin>>R>>G;	//R:現在のレーティング
				//G:目標のレーティング
  	X=2*G-R;	//目標達成に必要な点数
	cout<<X;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k,q = LI()
    a = LI()
    b = [[a[i],i] for i in range(n)]
    b.sort()
    ans = b[q-1][0]-b[0][0]
    l = [-1,n]
    for i in range(1,n):
        l.append(b[i-1][1])
        l.sort()
        if b[i-1][0] == b[i][0]:
            continue
        s = [a[l[i]+1:l[i+1]] for i in range(i+1)]
        c = []
        for si in s:
            si.sort()
            for j in range(len(si)-k+1):
                c.append(si[j])
        if len(c) < q:
            continue
        c.sort()
        m = c[q-1]-c[0]
        if m < ans:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 50524
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

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

bool bits[1111111];
void sieve(){
	REP(i, 1111111)bits[i] = true;
	bits[0] = bits[1] = false;
	FOR(i, 2, 1055){
		if(bits[i]){
			for(int j=i*i; j<1111111; j+=i){
				bits[j] = false;
			}
		}
	}
}

int main(){
	sieve();
	while(1){
		int a, d, n;
		cin >>a>>d>>n;
		if(d==0)return 0;
		int x = a;
		while(1){
			if(bits[x])n--;
			if(n == 0){
				cout << x << endl;
				break;
			}
			x+=d;
		}
	}
}

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

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

    int N, K;
    string S;
    cin >> N >> S >> K;
    char ch = S[K - 1];
    string res;
    for (auto s: S) {
        if (s == ch) {
            cout << s;
        } else {
            cout << '*';
        }
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N, W;
    cin >> N >> W;

    vll w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    //dp[i][j] := i番目までの品物で重さをj以下とするときの価値の最大値
    vvll dp(N + 1, vll(W + 1, 0));

    //もらうdp
    rep(i, N)
    {
        reple(j, 0, W)
        {
            chmax(dp[i + 1][j], dp[i][j]);

            if(j - w[i] >= 0) chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n, k; sii(n, k);
        map<int, int> mp;

        FOR(i, 0, n){
            int x; si(x);
            mp[x]++;
        }
        int ans = n;

        while(true){
            int tmp = ans, flg = 0;
            while(tmp > 0){
                if(mp[tmp % 10]) flg = 1;
                tmp /= 10;
            }
            if(flg == 0) break;
            else ++ans;
        }
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S, T;
    cin >> S >> T;
    i32 min_v = T.size() + 1;
    if (S.size() )
    for (i32 i = 0; i <= S.size() - T.size(); i++) {
        i32 m = 0;
        for (i32 j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j]) m++;
        }
        if (m < min_v) min_v = m;
    }
    cout << min_v << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <set>

const int MAX = 100005;

int A[MAX];
int B[MAX];

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n,m;
    std::string s;
    std::cin >> n >> m;
    std::cin >> s;

    std::multiset<std::pair<int, int>> M;
    M.insert({0, n});
    for (int i=n-1;i>=0;--i)
    {
        // std::clog << "## " << i << std::endl;
        if (s[i] == '1') continue;
        while (!M.empty()) {
            auto it = M.begin();
            if (it->second - i > m) M.erase(it);
            else {
                A[i] = A[it->second]+1;
                B[i] = it->second-i;
                M.insert({A[i], i});
                // std::clog << "# " << A[i] << " / " << B[i] << std::endl;
                break;
            }
        }
    }
    int x = 0;
    if (B[0] == 0) std::cout << "-1" << std::endl;
    else
        while (x < n)
        {
            std::cout << " " << B[x];
            x += B[x];
        }
    return 0;
}

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

int INF=0x3f3f3f3f;


int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i+=2){
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  for(int i = 1; i < b; i++) {
    int d = a * i;
    if(d % b == c){
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int k;
    cin >> k;

    int ans = 0;
    for (int a = 1; a <= k; a ++)
        for (int b = 1; b <= k; b ++)
            for (int c = 1; c <= k; c ++)
                ans += __gcd(a, __gcd(b, c));

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

#define N 100001

class CGeTAC {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		int sum[N], n, q;
		memset(sum, 0, sizeof(sum));
		in >> n >> q >> s;
		for(int i = 1; i < s.size(); ++i){
			if (s[i] == 'C' && s[i-1] == 'A')
				sum[i+1] = 1;
		}
		for(int i = 1; i <= s.size(); i++)
			sum[i] += sum[i-1];
		int a, b;
		REP(i,q){
			in >> a >> b;
			out << sum[b] - sum[a] << "\n";
		}

	}
};

int main() {
	CGeTAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B == C+D) cout << "Balanced";
    else if(A+B > C+D) cout << "Left";
    else cout << "Right";
    cout << endl;
    
    return 0;
}

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

int c[33], s[444][33];
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    stringstream ss[5555];
    int M = -1e9, tt;
    for(int a = 0; a < 50; a++) {
        for(int b = 0; b < 10; b++) {
            for(int z = 5; z < 16; z++) {
                int r = 0, l[33] = {};
                for(int i = 0; i < d; i++) {
                    auto m = 0.;
                    int t = 0;
                    for(int j = 0; j < 26; j++) {
                        double p = s[i][j];
                        p += c[j] * (i + 1 - l[j]) * .02 * a;
                        for(int k = 1; k < z; k++)
                            if(i + k < d)
                                p -= s[i + k][j] * (z - k) * .05 / z * b;
                        if(p > m)
                            m = p, t = j;
                    }
                    ss[a * 10 * 11 + b * 11 + z - 5] << t + 1 << '\n';
                    l[t] = i + 1;
                    r += s[i][t];
                    for(int j = 0; j < 26; j++)
                        r -= c[j] * (i + 1 - l[j]);
                }
                if(r > M)
                    M = r, tt = a * 10 * 11 + b * 11 + z - 5;
            }
        }
    }
    cout << ss[tt].str();
    cerr << M << endl;
    return 0;
}


Measured memory_bytes: 11392
import sys
N,Y = list(map(int,input().split()))

for x in range(N+1):
  for y in range(N+1):
    if 10000*x + 5000*y + 1000*(N-x-y) == Y and (N-x-y)>=0:
      print(x,y,(N-x-y),sep=' ')
      sys.exit()

print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn=1e4+10;
const int maxw=2e4+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
int n;
struct node {
	ll w,s,v,tw;
}t[maxn];
bool cmp(node a,node b){
	return a.tw<b.tw;
}
ll f[maxw],ans;
int main(){
	read(n);
	for(re int i=1;i<=n;i++){
		read(t[i].w);read(t[i].s);read(t[i].v);                                                                                                                                 
		t[i].tw=t[i].w+t[i].s;
	}
	sort(t+1,t+n+1,cmp);
	for(re int i=1;i<=n;i++){
		for(re int j=maxw-5;j>=t[i].w;j--){
			if(t[i].tw>=j){
				f[j]=max(f[j],f[j-t[i].w]+t[i].v);
			}
		}
	}
	for(re int i=0;i<=maxw-5;i++){
		ans=max(ans,f[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  int ret;
  ret = a-2*b;
  if (ret<0) ret =0;
  cout << ret << endl;
}
     

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int noir[2333][2333],blanc[2333][2333];
#define gmax(a,b) (a>b?a:b)
int main()
{
	int n,i,j,k,x,y,res=0,now;
	char c;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %c",&x,&y,&c);
		if(c=='W')blanc[x%(2*k)+1][y%(2*k)+1]++;
		else noir[x%(2*k)+1][y%(2*k)+1]++;
	}
	for(i=1;i<=2*k;i++)for(j=1;j<=2*k;j++)
	{
		noir[i][j]+=noir[i-1][j]+noir[i][j-1]-noir[i-1][j-1];
		blanc[i][j]+=blanc[i-1][j]+blanc[i][j-1]-blanc[i-1][j-1];
	}
	for(i=1;i<=k;i++)
	{
		for(j=1;j<=k;j++)
		{
			now=noir[i-1][j-1]
				+noir[i-1][2*k]-noir[i-1][j+k-1]
				+noir[2*k][j-1]-noir[i+k-1][j-1]
				+noir[2*k][2*k]-noir[i+k-1][2*k]-noir[2*k][j+k-1]+noir[i+k-1][j+k-1]
				+noir[i+k-1][j+k-1]-noir[i+k-1][j-1]-noir[i-1][j+k-1]+noir[i-1][j-1]
				+blanc[i+k-1][j-1]-blanc[i-1][j-1]
				+blanc[i-1][j+k-1]-blanc[i-1][j-1]
				+blanc[i+k-1][2*k]-blanc[i-1][2*k]-blanc[i+k-1][j+k-1]+blanc[i-1][j+k-1]
				+blanc[2*k][j+k-1]-blanc[2*k][j-1]-blanc[i+k-1][j+k-1]+blanc[i+k-1][j-1];
			res=gmax(res,now);
			now=blanc[i-1][j-1]
				+blanc[i-1][2*k]-blanc[i-1][j+k-1]
				+blanc[2*k][j-1]-blanc[i+k-1][j-1]
				+blanc[2*k][2*k]-blanc[i+k-1][2*k]-blanc[2*k][j+k-1]+blanc[i+k-1][j+k-1]
				+blanc[i+k-1][j+k-1]-blanc[i+k-1][j-1]-blanc[i-1][j+k-1]+blanc[i-1][j-1]
				+noir[i+k-1][j-1]-noir[i-1][j-1]
				+noir[i-1][j+k-1]-noir[i-1][j-1]
				+noir[i+k-1][2*k]-noir[i-1][2*k]-noir[i+k-1][j+k-1]+noir[i-1][j+k-1]
				+noir[2*k][j+k-1]-noir[2*k][j-1]-noir[i+k-1][j+k-1]+noir[i+k-1][j-1];
			res=gmax(res,now);
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> A(m);
    map<int, bool> mp;
    for(int i = 0; i < m; i++){
        cin >> A[i];
        mp[A[i]] = true;
    }

    int dp[n + 1] = {};
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        if(i >= 2 and !mp[i]) dp[i] = (dp[i] + dp[i - 2]) % MOD;
        if(i >= 1 and !mp[i]) dp[i] = (dp[i] + dp[i - 1]) % MOD;
    }

    cout << dp[n] << endl;

    return 0;
}

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

lint n, m;
vector<lint> a;

//幸福度k以上の握手が何個あるか
lint count(lint k) {
    lint res = 0;
    for (int i = 0; i < n; i++) {
        res += a.end() - lower_bound(a.begin(), a.end(), k - a[i]);
    }
    return res;
}

bool check(lint k) {
    return count(k) < m;
}

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    lint ok = 1e+6, no = 0;
    while (abs(ok - no) > 1) {
        lint mid = (ok + no) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            no = mid;
        }
    }
    lint ans = 0;
    ans += (ok - 1) * (m - count(ok));
    cumulative_sum cum(n);
    for (int i = 0; i < n; i++) {
        cum[i] = a[i];
    }
    cum.build();
    for (int i = 0; i < n; i++) {
        int b = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
        ans += a[i] * (n - b) + cum.query(b, n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
from numpy import*
def main():
  c=zeros((50,50),int_)
  r=0
  for a in[*open(0)][1:]:
    a=round(float(a)*1e9)
    y=0
    while a%5<1:
      a//=5
      y+=1
    x=int(log2(a&-a))
    r+=sum(c[max(0,18-x):,max(0,18-y):])
    c[x][y]+=1
  print(r)
main()

Measured memory_bytes: 42300
// import scala.io.{StdIn => in}
import java.io._
import scala.collection.{mutable => mu}
import scala.annotation.tailrec

object Main extends App {
  val INF = 2L << 40
  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(a, b, q) = in.readLine.split(" ").map(_.toInt)
  val s = Iterator.continually(in.readLine.toLong)
    .take(a)
    .to[mu.ArrayBuffer]
  -INF +=: s
  s += INF

  val t = Iterator.continually(in.readLine.toLong)
    .take(b)
    .to[mu.ArrayBuffer]
  -INF +=: t
  t += INF

  val out = new java.io.PrintWriter(System.out)
  Iterator.continually(in.readLine.toLong)
    .take(q)
    .foreach(x => {
      var dist = Long.MaxValue
      for {
        k <- 0 until 2
        arrA = if(k == 0) s else t
        arrB = if(k == 0) t else s
        i <- 0 until 2
        posA = math.min(binarySearch(arrA, x) + i, arrA.size-1)
        ax = arrA(posA)
        j <- 0 until 2
        posB = math.min(binarySearch(arrB, ax) + j, arrB.size-1)
        bx = arrB(posB)
      } {
        val a = ( x - ax).abs
        val b = (ax - bx).abs
        dist = math.min(dist, a + b)
      }
      out.println(dist)
    })
  out.flush

  def binarySearch(arr:mu.ArrayBuffer[Long], x:Long):Int = {
    var left = 0
    var right = arr.size

    @tailrec
    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if(arr(mid) <= x) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }
}

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

const int maxn = 100005;

int N, M, de[maxn];

bool judge() {
    for(int i=1; i<=N; ++i) if(de[i]&1) return false;
    return true;
}

int main() {
    scanf("%d %d", &N, &M);
    for(int i=1, u, v; i<=M; ++i) {
	scanf("%d %d", &u, &v);
	++de[u], ++de[v];
    }
    puts(judge() ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 512
odd = list(input())
even = list(input())
ans = ''
if len(odd) == len(even):
  for i in range(len(odd)):
    ans += odd[i]
    ans += even[i]
else:
  for i in range(len(even)):
    ans += odd[i]
    ans += even[i]
  ans += odd[len(odd)-1]
print(ans)
  
    

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

using namespace std;

#define ll long long

int main() {
    ll a, b, c, d;

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

    printf("%lld\n", max(a*c, max(a*d, max(b*c, b*d))));

    return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	queue<long long>s;
	for(int i=1;i<=9;i++)
		s.push(i);
	while(!s.empty())
	{
		long long x=s.front();
		s.pop();
		a--;
		if(a==0)
		{
			cout<<x;
			break;
		}
		for(int i=x%10-1;i<=x%10+1;i++)
		{
			if(i<0||i>=10)
				continue;
			s.push(x*10+(long long)i);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
A = [int(sys.stdin.readline()) for _ in range(M)]
MOD = 10 ** 9 + 7

safe = [True for _ in range(N + 1)]
for a in A:
    safe[a] = False

dp = [0 for _ in range(N + 1)]
dp[0] = 1
for i in range(N + 1):
    if not safe[i]:
        continue
    if i + 1 < len(dp):
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
    if i + 2 < len(dp):
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD
print(dp[-1])


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

int main()
{

int k;
cin >> k;
string s;
cin >> s;
int n = s.length();

if(k>= n)
{
  cout << s;
}
else if (k < n)
{
  for(int i=0;i<k;i++)
  {
    cout << s[i];
  }
  cout << "...";

}


return 0;



}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


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

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

    if (a + 2 * sqrt(a) * sqrt(b) + b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	for i, v := range s {
		if i % 2 == 0 {
			if !(v == 'R' || v == 'D' || v == 'U') {
				fmt.Printf("No")
				return
			}
		} else {
			if !(v == 'D' || v == 'L' || v == 'U') {
				fmt.Printf("No")
				return
			}
		}
	}
	fmt.Printf("Yes")
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[100010][3];
int dp[100010][3];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
    	for(int j=0;j<3;j++){
    		if(j==0){
    			dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+a[i][j];
			}
			else if(j==1){
				dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+a[i][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j-2],dp[i-1][j-1])+a[i][j];
			}
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

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

int main(){
  while(1){
    int N,i; cin >> N;
    if( N == 0 ) break;
    int x[201],y[201];
   
    int xMax = 0,xMin = 0,yMax = 0,yMin = 0;
    x[0] = 0,y[0] = 0;
    int n,d;
    for( i = 1; i < N; i++ ){
      cin >> n >> d;
      if( d == 0 ){
	x[i] = x[n]-1;
	y[i] = y[n];
      }else if( d == 2 ){
	x[i] = x[n]+1;
	y[i] = y[n];
      }else if( d == 1 ){
	y[i] = y[n]-1;
	x[i] = x[n];
      }else if( d == 3 ){
	y[i] = y[n]+1;
	x[i] = x[n];
      }
      xMax = max( x[i],xMax );
      yMax = max( y[i],yMax );
      xMin = min( x[i],xMin );
      yMin = min( y[i],yMin );
    }

    cout << xMax - xMin + 1 << " " << yMax - yMin + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys,os,math
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import Queue



# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())


def main():
    n, k = map(int, raw_input().split())
    da = map(int, raw_input().split())
    sm = sum(da)
    mx = max(da)
    ans = 1
    for i in range(1, int(math.sqrt(sm))+1):
        if sm%i==0:
            def check(p):
                l = []
                for num in da:
                    l.append(num%p)
                ssm = n*p - sum(l)
                l.sort()
                ps = 0
                uk = 0
                for num in l:
                    uk += num
                    ssm -= p-num
                    if ssm == uk and uk <= k:
                        return True
                return False
            # print check(7), 7777777
            if check(i):
                ans = max(ans, i)
            if check(sm/i):
                ans = max(ans, sm/i)

    print ans






main()


Measured memory_bytes: 3688
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b>>c>>d;
    Cout(min(a,b)+min(c,d));
    return 0;
}


Measured memory_bytes: 256