akhauriyash/Code-Regression huggingface dataset:
// AtCoder Beginner Contest 122 - Problem B: ATCoder (https://atcoder.jp/contests/abc122/tasks/abc122_b)
#include <bits/stdc++.h>

using namespace std;

int solve(const string& s)
{
    int N = s.size(), L = 0, ans = 0;
    const string t { "ACTG" };
    const set<char> valid(t.begin(), t.end());

    while (L < N)
    {
        if (valid.count(s[L]) == 0)
        {
            L++;
            continue;
        }
            
        auto R = L + 1;

        while (R < N and valid.count(s[R]))
            ++R;

        ans = max(ans, R - L);
        L = R;
    }

    return ans;
}

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

    string s;
    cin >> s;

    auto ans = solve(s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

class MutableRange {
	MutableRange(int from, int to) {
		this.from = from;
		this.to = to;
	}

	int from;
	int to;

	int length(){
		return to - from;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int H = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());
		char[][] S = new char[H][W];
		Arrays.setAll(S, $ -> sc.get().toCharArray());

		MutableRange[][] rowCum = new MutableRange[H][W];
		MutableRange[][] columnCum = new MutableRange[H][W];
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (S[i][j] == '#') {
					continue;
				}
				MutableRange vertical = columnCum[i][j] = Optional.ofNullable(i == 0 ? new MutableRange(0, 0) : columnCum[i - 1][j]).orElse(new MutableRange(i, i));
				MutableRange horizontal = rowCum[i][j] = Optional.ofNullable(j == 0 ? new MutableRange(0, 0) : rowCum[i][j - 1]).orElse(new MutableRange(j, j));
				vertical.to++;
				horizontal.to++;
			}
		}

		int max = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				MutableRange row = rowCum[i][j];
				MutableRange column = columnCum[i][j];
				if (row == null || column == null) continue;
				max = Math.max(max, row.length() + column.length() - 1);
			}
		}

		System.out.println(max);

	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

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

int main() {
    int n;
    cin >> n;
    char s[n];
    rep(i, n) cin >> s[i];
    bool f = 0;
    rep(i, n) {
        if(s[i] == 'Y') f = 1;
    }
    cout << (f ? "Four" : "Three") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a ,b;
    cin >> a >> b;
    if ( a >= 13) {cout << b <<endl;  }
    else if (a >= 6 && a <13 ){cout <<b/2<<endl;  }
    else if (a < 6 )  {cout << b*0 << endl; }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int H, W;
vector<string> ts;
vector< vector<bool> > done;

void dfs(int y, int x) {
        if (done[y][x]) return;
        done[y][x] = true;

        for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
                        if (!(!dy ^ !dx)) continue;

                        int nx = x + dx;
                        int ny = y + dy;

                        if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
                        if (ts[y][x] != ts[ny][nx]) continue;

                        dfs(ny, nx);
                }
        }
}

int main(void) {
        while (cin >> H >> W, H) {
                ts = vector<string>(H);
                done = vector< vector<bool> >(H, vector<bool>(W));

                for (int y = 0; y < H; y++) cin >> ts[y];

                int cnt = 0;

                for (int y = 0; y < H; y++) {
                        for (int x = 0; x < W; x++) {
                                if (!done[y][x]) {
                                        dfs(y, x);
                                        cnt++;
                                }
                        }
                }

                cout << cnt << endl;
        }

        return 0;
}

Measured memory_bytes: 2504
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1000007;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		f(i, 1, n)scanf("%d", &a[i]);
		int tmp = 1;
		int ans = 0;
		f(i, 1, n)
		{
			if (a[i] == tmp)ans++, tmp++;
		}
		if (ans == 0)puts("-1");
		else
		cout << n - ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4428
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=[int(input()) for _ in range(n)]
    S.sort()
    res=sum(S)
    if(res%10):
        print(res)
        return
    for s in S:
        if(s%10):
            print(res-s)
            return
    print(0)
resolve()

Measured memory_bytes: 38256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL N;
	LL A,B,C,D;
	cin >>N>>A>>B>>C>>D;
	
	LL diff = B-A;//差だけ必要
	LL diff2 = D-C;//差だけ
	--N;
	for(LL i=0;i<=N;++i){
		LL base = (i*2-(LL)N) * C;
		LL add = i * diff2;
		LL sub = (N-i)*diff2;
		LL L,R;
		L = base-sub;
		R = base+add;
		if(L>R){
			swap(L,R);
		}
		if( L <= diff && diff <= R ){
			cout << "YES" << endl;
			return;
		}		
	}
	cout << "NO" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main() {
    int64_t K, A, B;
    cin >> K >> A >> B;
    int64_t ans = K + 1;
    int64_t C = B - A;
    int64_t n = (K - A + 1) / 2;
    int64_t tmp = C * n + A + (K - A + 1) % 2;
    if(C > 1 && K >= A - 1) ans = max(ans, tmp);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import math

N,M=map(int,input().split())

S=input()
T=input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l=lcm(N,M)

if S[0] != T[0]:
    print(-1)
else:
    a=l//N
    b=l//M
    m=lcm(a,b)
    answer=0
    for n in range(m, l, m):
        c=n//a
        d=n//b
        if S[c]==T[d]:
            continue
        else:
            answer=1
            break
    if answer==0:
        print(l)
    else:
        print(-1)
        

Measured memory_bytes: 64648
#include <stdio.h>
int main(void){
 int a,b,x,y;
 scanf("%d %d",&a,&b);
 x=a*b;
 y=2*a+2*b;
 printf("%d ",x);
 printf("%d\n",y);
 //scanf("%d",&x,&y);
 return 0;
}    



Measured memory_bytes: 2056
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Measured memory_bytes: 19300
#include <bits/stdc++.h>
using namespace std;
 int main(){
     string s;cin>>s;
     string a[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
     int ans=1;
     for(int i=0;i<7;i++){
         if(s==a[i])ans+=i;
     }
     cout<<ans<<endl;

    }
        






Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Mon Mar 23 19:34:20 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c = na()

if c >= a and c <= b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),x=s.nextInt();
        long total=0;
        int arr[] = new int[n];
        for(int i=0;i<n;i++)arr[i]=s.nextInt();
        for(int i=1;i<n;i++){
            int sum = arr[i]+arr[i-1];
            if(sum>x){
                int diff = sum-x;
                total+=diff;

                if(arr[i]-diff>=0){
                    arr[i]-=diff;
                }
                else{
                    arr[i]=0;
                }
            }
        }
        System.out.println(total);
    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

using namespace std;


void solve() {
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i-1]) cnt++;
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int W = scan.nextInt();

		long v[] = new long[n + 1];
		int w[] = new int[n + 1];

		for (int i = 1; i <= n; i++) {
			w[i] = scan.nextInt();
			v[i] = scan.nextInt();
		}

		long dp[][] = new long[n + 1][W + 1];
		
		for(int i=0;i<=n;i++) {
			for(int j=0;j<=W;j++) {
				if(i==0 || j ==0) {
					dp[i][j] = 0;
				} else if(w[i] > j) {
					dp[i][j] = dp[i-1][j];
				} else if((v[i] + dp[i-1][j-w[i]]) > dp[i-1][j]) {
					dp[i][j] =v[i] + dp[i-1][j-w[i]];
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		//System.out.println(Arrays.deepToString(dp));
		System.out.println(dp[n][W]);

	}

	public static long find(int cw, int ci, long[] v, int[] w, long dp[][]) {
		if (cw == 0) {
			return 0;
		}

		if (ci >= v.length) {
			return 0;
		}
		if (cw < w[ci]) {
			return 0;
		}

		if (dp[ci][cw] != 0) {
			return dp[ci][cw];
		}
		long with = v[ci] + find(cw - w[ci], ci + 1, v, w, dp);
		long without = find(cw, ci + 1, v, w, dp);

		dp[ci][cw] = Math.max(with, without);
		return dp[ci][cw];

	}
}


Measured memory_bytes: 140588
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    const int MEM=1114514;
    int dp[MEM],dps[MEM]={};
    cin >> N;
    dp[0]=1;dps[1]=1;
    OREP(i,N){
        if(i==1){dp[1]=1;dps[2]=2;continue;}
        dp[i]=dps[i-2]+dp[i-1];
        dp[i]%=MOD;
        dps[i+1]=dps[i]+dp[i];
        dps[i]%=MOD;
    }
    
    int Ans=0,num=0;
    REP(i,N){
        if(i<=N-3){
            num=N*(N-2);num%=MOD;
            num+=i+3;num%=MOD;
        }else if(i==N-2){
            num=N*(N-1);num%=MOD;
        }else if(i==N-1){
            num=N;num%=MOD;
        }
        
        
        num*=dp[i];num%=MOD;
        Ans+=num;Ans%=MOD;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i;
    scanf("%d",&n);
    while(n--){
		scanf("%d",&i);
		if(!(i&1)&&i%3&&i%5){puts("DENIED");return 0;}
	}
	puts("APPROVED");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;

int main() {

    int ans=100,cnt,c;
    string s;
    cin>>s;
    for(int i=0;i<'z'-'a'+1;i++){
        cnt=c=0;
        for(int j=0;j<s.size();j++){
            if(s[j]==char('a'+i))cnt=max(cnt,c),c=0;
            else c++;
        }
        cnt=max(cnt,c);
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] == '1'){
			cnt++;
		}
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

  int h,w;
  int i,j;

  while(1){

    scanf("%d %d",&h,&w);
    if(h==0&&w==0)break;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1){
	  printf("#");
	}else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
        using namespace std;
        #define el "\n"
        #define ll long long
        #define ull unsigned long long int
        #define pb push_back
        #define mp make_pair
        #define X first
        #define Y second
        #define M 1000000007
        #define all(v) v.begin(), v.end()
        long long pow(long long int a,long long int b,long long int MOD)
        {
            long long x=1,y=a; 
            while(b > 0)
            {
                if(b%2 == 1)
                {
                    x=(x*y);
                    if(x>MOD) x%=MOD;
                }
                y = (y*y);
                if(y>MOD) y%=MOD; 
                b /= 2;
            }
            return x;
        }
        long long modInverse(long long int n, long long int MOD)
        {
            return pow(n,MOD-2,MOD);
        }

        int main() {
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);
          unordered_map<ll,ll> mp;
          ll l,r;
          cin>>l>>r;
          ll tmp;
          tmp=(r-l+1)/2019;
          if(tmp>2){
              cout<<0<<el;
              return 0;
          }
          for(ll i=l;i<=r;i++){
              mp[i%2019]++;
          }
          ll ans=INT_MAX;
          for(auto x:mp){
              if(x.Y>=2){
                  ans=min(ans,(x.X*x.X)%2019);
              }
          }
          vector<ll> v;
          for(auto x:mp)v.pb(x.X);
          sort(all(v));
          int n=v.size();
          for(int i=0;i<n;i++){
              for(int j=i+1;j<n;j++)
              {
                   ans=min(ans,(v[i]*v[j])%2019);
              }
          }
          cout<<ans<<el;
          return 0;
        }


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int M = s.nextInt();
	int K = s.nextInt();
	long[] A = new long[N+1];
	long[] B = new long[M+1];
	for(int i = 1; i <= N; i++){
		A[i] = s.nextInt()+A[i-1];
	}
	for(int i = 1; i <= M; i++){
		B[i] = s.nextInt()+B[i-1];
	}
	long bestCount = 0;
	int bestj = M;
	long Sum = 0;
	int x = 0;
	int y = 0;
	for(int i = 0; i <= N; i++){
		if(A[i] > K) break;
		for(int j = bestj; j >= 0; j--){
			Sum = B[j]+A[i];
			if(K >= Sum){
				bestCount = Math.max(bestCount, j+i);
				bestj = j;
				break;
			}
		}
	}

	System.out.println(bestCount);
    
  }
}

Measured memory_bytes: 63200
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <ctime>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>
#include <memory.h>
#include <bitset>
#include <numeric>

using namespace std;

//#define int long long

signed main() {

    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        ++cnt;
    }
    if (cnt >= k) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
input_n = int(input())
input_items = list(map(int, input().split(' ')))

cnt = 0
for i in range(input_n - 2):
    targets = [input_items[i + j] for j in range(3)]
    if input_items[i + 1] != min(targets) and input_items[i+1] != max(targets):
        cnt += 1
print(cnt)

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

int main() {
	long long int N;
	cin >> N;
	vector<long long int>dp( N + 1, LLONG_MAX / 6 );
	dp[0] = LLONG_MIN;
	for( size_t i = 0; i < N; i++ ) {
		long long int a;
		cin >> a;
		for( size_t j = lower_bound( dp.begin(), dp.end(), a ) - dp.begin() - 1; j < N; j++ ) {
			if( dp[j] < a ) {
				dp[j + 1] = min( dp[j + 1], a );
			} else {
				break;
			}
		}
	}
	long long int ans = 0;
	for( size_t i = 0; i < N + 1; i++ ) {
		if( dp[i] != LLONG_MAX / 6 ) {
			ans = i;
		} else {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <ctype.h>
using namespace std;

int main(void) {
	char s;
	while ((s = getchar()) != '\n' && s != EOF){
		if (isspace(s)) {
			printf(" ");
		}
		else if (isupper(s)) {
			s = tolower(s);
			printf("%c", s);
		}
		else if(islower(s)){
			s = toupper(s);
			printf("%c", s);
		}
		else {
			printf("%c", s);
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 3084
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    a.append([int(j) for j in input().split()])
for i in range(m):
    b.append(int(input()))
for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    print(s)

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

int main()
{
	//合計時間

	int N, M;
	cin >> N >> M;
	int a;
	int A[5000];
	int b = 0;
	int x = 0;
	for (int i = 0; i <  M; i++) {
		cin >> a;
		if (a < N) {
			A[x]=a;
			x++;
		}
		else
		{
			b++;
		} 
		cin >> a;
	}
	int sum = 0;
	if (b < M - 1) {
		sort(A, A+x);
		reverse(A, A+x);
		for (int i = 0; i < M - 1 - b; i++) {
			sum += N - A[i];
		}
	}
	cout << sum << endl;

	/*
	int sum=0, n;
	for (int i = 0; i < 4; i++) {
	cin >> n;
	sum += n;
	}
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	//平均点
	/*
	int P[5];
	int sum=0;
	for (int i = 0; i < 5; i++) {
	cin >> P[i];
	if (P[i] < 40) P[i] = 40;
	sum += P[i];
	}
	cout << sum / 5 << endl;
	*/
	//投票
	/*
	int N, M;
	cin >> N >> M;
	int A[1000], vote[1000];
	for (int i = 0; i < N; i++) {
	cin >> A[i];
	vote[i] = 0;
	}
	int b;
	for (int i = 0; i < M; i++) {
	cin >> b;
	for (int j = 0; j < N; j++) {
	if (A[j] <= b) {
	vote[j]++;
	break;
	}
	}
	}
	int temps = 0, ans;
	for (int i = 0; i < N; i++) {
	if (vote[i] > temps) {
	temps = vote[i];
	ans = i;
	}
	}
	cout << ans + 1 << endl;
	*/

	//2.すごろく	
	/*
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
	cin >> A;
	if (A == 1)
	{
	if (A == _A)
	{
	A_count[k]++;
	}
	else
	{
	k++;
	A_count[k] = 2;
	}
	}
	_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;
	*/

	//タイムカード
	/*
	int t[2][3];
	int x[3][3];
	for (int n=0; n < 3; n++)
	{
	for (int i=0; i < 2; i++)
	for (int k=0; k < 3; k++)
	cin >> t[i][k];

	for (int m = 2; m >= 0; m--)
	{
	x[n][m] = t[1][m] - t[0][m];
	if (t[0][m] > t[1][m])
	{
	x[n][m] += 60;
	t[1][m - 1]--;
	}
	}
	}
	for (int n= 0; n < 3; n++)
	{
	cout << x[n][0] << ' ' << x[n][1] <<' '<< x[n][2] << endl;
	}
	*/



	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)


bool is_prime[200000];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;

  rep(i, 2e5) is_prime[i] = true;
  is_prime[0] = false;
  is_prime[1] = false;
  rep(i, 2e5) {
    if (!is_prime[i])
      continue;
    if (i >= N) {
      cout << i << endl;
      return 0;
    }
    for (ll j = i*i; j < 2e5; j += i) {
      is_prime[j] = false;
    }
  }
  cout << "fuck";

  return 0;
}


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

int main(){
  int D,N,ans = 0;
  cin >> D >> N;
  ans = N;
  int tmp = 1;
  for(int i=0;i<D;i++){
    tmp *= 100;
  }
  if(N == 100) ans = tmp * (N+1);
  else ans = tmp * N;
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>a>>b;
    if(b==1) cout<<0<<endl;
    else if(b<=a) cout<<1<<endl;
    else {
        m=a;
        cnt=1;
        while(a<b)
        {
            a--;
            cnt++;
            a=a+m;
        }
        cout<<cnt<<endl;
    }
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


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

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define ll long long
#define vi vector <int>
#define pb push_back
using namespace std;

#define bs 1000000007

int tests;
map<int,int> mapp;
int n;
vector<int> order;
map<int,int> ::iterator it;

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

    ll n1,n2; 
    cin>>n1>>n2;
    ll sum=0;
    for(int i=0; i<n2; i++){
        ll k; cin>>k; sum+=k;
    }
    if(n1>=sum){cout<<n1-sum<<"\n";}
    else{cout<<"-1\n";}

}



Measured memory_bytes: 3640
#include<iostream>
#include<cmath>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;

const ll MOD=pow(10,9)+7;
ll n,a,b;

ll modpow(ll a,ll n,ll mod){//a^n mod を計算する
    ll res=1;
    while(n>0){
        if(n&1)res=res*a%mod;//bitアンド
        a=a*a%mod;
        n>>=1;//bitを右にシフト
    }
    return res;
}

ll comb(ll n,ll r,ll mod){//nCr
    ll bunsi=1;
    ll bunbo=1;
    rep(i,0,r){
        bunsi=bunsi*(n-i)%mod;
        bunbo=bunbo*(r-i)%mod;
    }
    return bunsi*modpow(bunbo,mod-2,mod)%mod;
}
ll ans;
int main(){
    cin>>n>>a>>b;
    ans=modpow(2,n,MOD)-1;
    ans-=comb(n,a,MOD);
    if(ans<0)ans+=MOD;
    ans-=comb(n,b,MOD);
    if(ans<0)ans+=MOD;
    puts(ans);
}

Measured memory_bytes: 256
a = [int(input()) for i in range(5)]
r = 10
last = 0
for i in range(5):
    if a[i] % 10 != 0 and a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)


b = [int((a[i] + 9) / 10) * 10 for i in range(5)] 
time = 0
for i in range(5):
    if i != last:
        time = time + b[i]
    
time = time + a[last]
print(time)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> ans(h, vector<int>(w));
  int num = 1;
  rep(i, h) rep(j, w) {
    if(s[i][j] == '#') {
      ans[i][j] = num;
      num++;
    }
  }
  rep(ri, 2) {
    rep(i, h) {
    int pre = 0;
      rep(j, w) {
        if(ans[i][j] > 0) pre = ans[i][j];
        ans[i][j] = pre;
      }
      reverse(ans[i].begin(), ans[i].end());
    }
  }


  vector<int> pre = ans[0];
  for (int i = 1; i < h; ++i) {
    if(ans[i][0] == 0) {
      ans[i] = pre;
    }
    pre = ans[i];
  }
  pre = ans[h - 1];
  for(int i = h - 2; i >= 0; --i) {
    if(ans[i][0] == 0) ans[i] = pre;
    pre = ans[i];
  }

  rep(i, h) {
    rep(j, w) printf("%d%c", ans[i][j], (j == w - 1 ? '\n' : ' '));
  }

}

Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>

using namespace std;

struct Element {
	int key = 0;
	Element* next = nullptr;
	Element* prev = nullptr;
};
void print(Element* first) {
	bool isfirst=true;
	while (first != nullptr) {
		if (isfirst) {
			isfirst=false;
		} else {
			printf(" ");
		}
		printf("%d", first -> key);
		first = first -> next;
	}
	printf("\n");
}
int main() {
	Element* first = nullptr;
	char command[6];
	int num = 0;
	int size = 0;
	char c = ' ';

	scanf("%d", &size);
	for (int i = 0; i < size; i++) {
		scanf("%6s%c", &command, &c);
//		printf("\n i is %d, size is %d, command is %s, c is %c\n", i, size, command, c);
		if (strcmp(command, "insert") == 0) {
			Element* n = new Element();
			scanf("%d", &num);
			n -> key = num;
			if (first == nullptr) {
				first = n;
			} else {
				if(first-> prev == nullptr){
					n -> prev = first;
				} else {
					n -> prev = first -> prev;
				}
				n -> next = first;
				first -> prev = n;
				first = n;
			}
		} else {
			switch (c) {
				case (' '): {
					scanf("%d", &num);
				if(first->key ==num){
				                if(first->next==nullptr){first = nullptr; break;}
				            if(first->next==first->prev){
				                                  first=first->next;
				                                  first->prev=nullptr;
				                                  break;;
				                          }

				                first = first->next;
				                first->prev = first->prev->prev;
				                break;
				        }
				                Element* rfirst=first;
				                first=first->next;
				                while (first!=nullptr) {
				                     if(first->key==num){
				                            Element* n=first->next;
				                           if(n==nullptr){
				                               first->prev->next=nullptr;
				                                rfirst->prev=first->prev;
				                             first = rfirst;
				                              break;
				                                }
				                                first=first->prev;
				                first->next=n;
				                n->prev=first;
				                                first = rfirst;
				                                break;
				                        }
				                        first=first->next;
				                }
				                first = rfirst;
					break;
				}
				case ('F'): {
					scanf("%*s");
				 if(first->next==nullptr){first = nullptr; break;}
				        if(first->prev==first->next){
				                first->next->prev=nullptr;
				        }else{
				                first->next->prev=first->prev;
				        }
				        first = first->next;
					break;
				}
				case ('L'): {
					scanf("%*s");
					if (first -> prev == nullptr) {
						first = nullptr;
						break;
					}
					if (first -> prev == first -> next) {
						first -> next = nullptr;
						first -> prev = nullptr;
						break;
					}
					first -> prev = first -> prev -> prev;
					first -> prev -> next = nullptr;
					break;
				}
			}
		}
	}
	print(first);
}



Measured memory_bytes: 36952
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

int main(){
    FASTIO
    string s1, s2;
  cin >> s1 >> s2;
  cout << s2 + s1;
    
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int taro=0, hanako=0, n;
    string tc, hc;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>tc>>hc;
        int judge=tc.compare(hc);
        if(judge<0) hanako+=3;
        else if(judge>0) taro+=3;
        else taro++, hanako++;
    }
    cout<<taro<<' '<<hanako<<'\n';
    return 0;
}

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

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

  int n, x; cin >> n >> x;
  ll d[200];
  d[0] = 0;
  int l[200];
  for ( int i = 1; i <= n; ++i ) {
    cin >> l[i];
  }

  int cnt = 1;
  for ( int i = 1; i <= n; ++i ) {
    d[i] = d[i-1] + l[i];
    if( d[i] <= x ) cnt++;
  }

  cout << cnt << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n, m;
	cin >> m >> n;
	int ans = 0;
	for(int i = 1; i <= m; ++i)
		for(int j = 22; j <= n; ++j) {
			if(j % 10 == 1 || j % 10 == 0) continue;
			int x = j, sum = 1;
			while(x) {
				sum = sum * (x % 10);
				x /= 10;
			}
			if(sum == i) {
				//cout << i << "-" << j << endl;
				ans ++;
			}
		}
	cout << ans << endl;
	return 0;
}

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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

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

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;

const double pi = acos(-1.0);

std::vector<int> g[N];
int sz[N];

void dfs(int u, int p = -1) {
	sz[u] = 1;
	for(int v : g[u]) {
		if(p != v) {
			dfs(v, u);
			sz[u] += sz[v];
		}
	}
}

int solve() {
    int n; Int(n);
    for(int i = 2; i <= n; i++) {
    	int u; Int(u);
    	sz[u]++;
    }
    //dfs(1);
    for(int i = 1; i <= n; i++) {
    	printf("%d\n", sz[i]);
    }
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


Measured memory_bytes: 9120
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (b - a == c - b) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef pair<string, int> P;
bool comp(P &e, P &e2){
    if(e.first != e2.first){
        return e.first < e2.first;
    }
    else return e.second > e2.second;
}
int main(){
  int n;
  cin >> n;
  vector<P> g(n);
  map<P, int> m;
  for(int i = 0; i < n; i++){
    string s;
    int score;
    cin >> s >> score;
    g[i] = P(s, score);
    m[g[i]] = i + 1;
  }
  sort(g.begin(), g.end(), comp);
  for(int i = 0; i < n; i++){
    cout << m[g[i]] << endl;
  }
}

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

int main(int argc, const char * argv[]) {
    int H,W;
    cin >> H>>W;
    
    vector<vector<char>> a(H,vector<char>(W));
    
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            cin >> a[i][j];
        }
    }
    
    vector<bool> h(H),w(W);
    
    for(int i=0;i<H;i++)
    {
        bool del = true;
        
        for(int j=0;j<W;j++)
        {
            if(a[i][j] == '#')
            {
                del = false;
                break;
            }
        }
        
        if(del)
        {
            h[i] = false;
        }
        else
        {
            h[i] = true;
        }
    }
    
    for(int i=0;i<W;i++)
    {
        bool del = true;
        
        for(int j=0;j<H;j++)
        {
            if(a[j][i] == '#')
            {
                del = false;
                break;
            }
        }
        
        if(del)
        {
            w[i] = false;
        }
        else
        {
            w[i] = true;
        }
    }
    
    for(int i=0;i<H;i++)
    {
        if(h[i])
        {
            for(int j=0;j<W;j++)
            {
                if(w[j])
                {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    
    //cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int cnt=0;
    rep(i,n-1){
        if(a[i]==i+1){
            swap(a[i],a[i+1]);
            cnt ++;
        }
    }
    if(a[n-1]==n) cnt ++;
    cout<<cnt<<endl;
}
//./problem.exe

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
string name[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int dayOfWeek(int y, int m, int d) {
    if(m == 1 || m == 2) {
        y--;
        m += 12;
    }
    return(y + y / 4 - y / 100 + y / 400 + (13*m + 8) / 5 + d) % 7;
}

int main(void) {
    int y = 2004, m, d;
    while(scanf("%d %d", &m, &d), m + d != 0) {
        cout << name[dayOfWeek(y, m, d)] << endl;
    }
    return(0);
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    long long a[n];
    long long sum=0;
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    long long x=a[0],y=sum-x,ans=abs(x-y),p;
    for(int i=1;i<n-1;i++){
        x+=a[i];
        y-=a[i];
        p=abs(x-y);
        ans=min(ans,p);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
/**
 * Allocation
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_D
 */

#include<iostream>
#include<vector>
using namespace std;

bool canPackToTrack(vector <int>w, int k, int P) {
  int capacity = 0;

  for (int i = 0; i < w.size(); i++) {
    // 最大積載量より大きい荷物は、そもそも積めない
    if (w.at(i) > P) {
      return false;
    }

    // 積載量を超えたら、トラックの数を減らして積載量をリセットする
    if (capacity + w.at(i) > P) {
      k--;
      capacity = 0;
    }

    // トラックがなくなってしまったら、もう荷物を積めない
    if (k == 0) {
      return false;
    }

    // トラックに荷物を積む
    capacity += w.at(i);
  }

  return true;
}

int main() {
  // 最初の行に荷物の数 n とトラックの数 k が空白区切りで与えられます。
  int n, k;
  cin >> n >> k;

  // 重さがそれぞれwのn個の荷物
  vector <int>w(n);
  for (int i = 0; i < n; i++) {
    cin >> w.at(i);
  }

  /**
   * 線形探索では、制限時間が足りなかった
   * for (int i = 0; 1; i++) {
   *   // cout << "=-" << i << calcV(w, k, i) << endl;
   *   if (calcV(w, k, i) >= n) {
   *     cout << i << endl;
   *     return 0;
   *   }
   * }
   */

   // 2分探索
   // 荷物の最大個数は100,000個で、最大サイズは10,000。これを超える十分に大きい最大積載量Pを最小値とする
   int min = 1, max = 100000 * 10000;
   int answer = 100000 * 10000;
   while (min < max) {
     int center = (min + max) / 2;
     if (canPackToTrack(w, k, center)) {
       // centerより大きい積載量の値は、必ず積載可能なので計算する必要がない
       max = center;
       //if (center < answer) {
         answer = center;
       //}
     } else {
       // centerより小さいサイズで、積載可能になることは起こり得ない
       min = center + 1;
     }
   }

   cout << answer << endl;

   return 0;
}



Measured memory_bytes: 3692
#include<cstdio>
struct Point{double x, y;};

int main(int argc, char const *argv[])
{
    Point p0, p1, p2;
    Point a, b, x;
    int q;
    scanf("%lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y);
    a.x = p2.x - p1.x;
    a.y = p2.y - p1.y;

    scanf("%d", &q);

    for(int i=0; i<q; i++){
        scanf("%lf %lf", &p0.x, &p0.y);
        b.x = p0.x - p1.x;
        b.y = p0.y - p1.y;
        x.x = (a.x*b.x+a.y*b.y)/(a.x*a.x+a.y*a.y) * a.x;
        x.y = (a.x*b.x+a.y*b.y)/(a.x*a.x+a.y*a.y) * a.y;
        printf("%.10lf %.10lf\n", x.x + p1.x, x.y+p1.y);
    }
    return 0;
}



Measured memory_bytes: 2720
mod = 10**9+7
n = int(input())

def get_primes(n):
    if n < 2:
        return []

    primes = [i for i in range(n)]
    primes[1] = 0

    # エラトステネスのふるい
    for prime in primes:
        if prime**2 > n:
            break
        if not prime:
            continue
        for non_prime in range(2 * prime, n, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

d = {}
for p in get_primes(n+1):
    q = p
    while n >= q:
        d[p] = d.get(p, 1) + n//q
        q *= p
ans = 1
for i in d.values():
    ans *= i
    ans %= mod
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for i in range(Q)]
B, C = [list(i) for i in zip(*BC)]
#print(B,C,BC)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1
#print(dic)

ans = sum(A)
for q in range(Q):
  ans = ans + (C[q]-B[q]) * dic.get(B[q],0)
  dic[C[q]] = dic.get(B[q],0) + dic.get(C[q],0)
  dic.pop(B[q],None)
  print(ans)



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

using namespace std;

struct P {
  int64_t x, y;
  P() {}
  P(int64_t x, int64_t y) : x(x), y(y) {}
  P operator+(P p) {
    return P(x + p.x, y + p.y);
  }
  P operator-(P p) {
    return P(x - p.x, y - p.y);
  }
  P operator*(double d) {
    return P(x * d, y * d);
  }
  double dot(P p) {
    return x * p.x + y * p.y;
  }
  double det(P p) {
    return x * p.y - y * p.x;
  }
};

bool compare_x(const P& p, const P& q) {
  if (p.x != q.x) return p.x < q.x;
  return p.y < q.y;
}

vector<P> convex_hull(vector<P> ps) {
  sort(ps.begin(), ps.end(), compare_x);
  int k = 0;
  int N = ps.size();
  vector<P> qs(2 * N);

  for (int i = 0; i < N; i++) {
    while (k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for (int i = N - 2, t = k; i >= 0; i--) {
    while (k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k - 1);
  return qs;
}

int64_t dist(P p, P q) {
  return abs(p.x - q.x) + abs(p.y - q.y);
}

int64_t solve(vector<P>& qs) {
  int n = qs.size();
  if (n == 2) {
    return dist(qs[0], qs[1]);
  }

  int i = 0, j = 0;
  for (int k = 0; k < n; k++) {
    if (!compare_x(qs[i], qs[k])) i = k;
    if (compare_x(qs[j], qs[k])) j = k;
  }

  int64_t answer = 0;
  int si = i, sj = j;
  while (i != sj || j != si) {
    answer = max(answer, dist(qs[i], qs[j]));
    if ((qs[(i + 1) % n] - qs[i]).det(qs[(j + 1) % n] - qs[j]) < 0) {
      i = (i + 1) % n;
    } else {
      j = (j + 1) % n;
    }
  }
  return answer;
}

int main() {
  int N;
  cin >> N;
  vector<P> ps(N);
  for (int i = 0; i < N; i++) cin >> ps[i].x >> ps[i].y;
  vector<P> qs = convex_hull(ps);
  int64_t answer = solve(qs);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 9544
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	
		Scanner scan = new Scanner(System.in);
		
		while( true ){
			int x = scan.nextInt();
			int y = scan.nextInt();
			
			if( x == 0 && y == 0){
				break;
			}
			if( y < x){
				System.out.println(y + " " + x);
			} else {
				System.out.println( x + " " + y);
			}
		}
	}
}

Measured memory_bytes: 34972