akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    public static int n;
    public static int S[];
    public static int q;
    public static int T[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        S=new int[n];
        for(int i=0;i<n;i++) S[i]=sc.nextInt();
        q=sc.nextInt();
        T=new int[q];
        for(int i=0;i<q;i++) T[i]=sc.nextInt();
        int count=0;
        for(int i=0;i<q;i++){
            if(binary_search(T[i])){
            count++;
            }
        }
        System.out.println (count);
        sc.close();
    }
    private static boolean binary_search(int key){
        int left=0;
        int right=n-1;
        while(right>=left){
            int mid=(left+right)/2;
            if(S[mid]==key) return true;
            else if (S[mid] > key) right = mid - 1;
            else if (S[mid] < key) left = mid + 1;
        }
        return false;
    }
}


Measured memory_bytes: 68180
def ColorfulTransceivers():
    
    def checker(number):
        return (number<1 or number>100)
    
    raw = input()
    input_list = raw.split(" ")
    try :
        [a,b,c,d] = [int(i) for i in input_list]
    except ValueError:
        return("Oops!  There is no int input.")
    if (sum([checker(i) for i in [a,b,c,d]])): 
        return("Oops!  There is no validate data.")
    elif abs(c-a)<=d:
        print("Yes")
    elif abs(b-a)<=d and abs(c-b)<=d:
        print("Yes")
    else:
        print("No")

ColorfulTransceivers()

Measured memory_bytes: 3064
def main():
    n, s = int(input()), input()
    l = [chr(i) for i in range(65, 65+26)]
    sl = []
    for si in s:
        sl.append(l.index(si))
    l = l+l
    sl = list(map(lambda x: x+n, sl))
    o = [l[i] for i in sl]
    print("".join(o))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N, X;
    cin >> N >> X;
    int m[N];
    int ans = 0, best = 0;
    REP(i, N) {
        cin >> m[i];
        X -= m[i];
        ans += 1;
        if (m[best] > m[i]) { best = i; }
    }
    ans += X / m[best];
    printAns(ans);
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int i;
    int a, b, c, d, r;
    r = 0;
    for(i = A; i < B+1; i++){
        a = i / 10000;
        b = (i - a * 10000) / 1000;
        c = i % 10;
        d = (i - c) % 100 / 10;
        if(a == c && b == d){
            r++;
        }
    }
    cout << r << endl;
}

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

int main() {
	int N,M ; cin >> N>>M;
	vector<int> X(N+1),Y(M+1);
	cin >> X[N] >> Y[M];
	for(int i = 0 ; i < N ; i++){
		cin >> X[i];
	}
	for(int i = 0 ; i < M ; i++){
		cin >> Y[i];
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	if(Y[0] - X[N] >= 1){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
h,w = map(int,input().split())
space = []
for _ in range(h):
    space.append(list(input()))

light_space = [[1 for i in range(w)] for j in range(h)]
max_light = 0
for i in range(w):
    light = -1
    light_right = -1
    for j in range(h):
        low_point = len(space)-j-1

        if space[j][i] == "#":
            light = -1
            light_space[j][i] = 0
        else:
            light += 1
            light_space[j][i] += light

        if space[low_point][i] == "#":
            light_right = -1
            light_space[low_point][i] = 0
        else:
            light_right += 1
            light_space[low_point][i] += light_right

for j in range(h):
    light = -1
    light_right = -1
    for i in range(w):
        right_point = len(space[j])-i-1

        if space[j][i] == "#":
            light = -1
            light_space[j][i] = 0
        else:
            light += 1
            light_space[j][i] += light
        
        if space[j][right_point] == "#":
            light_right = -1
            light_space[j][right_point] = 0
        else:
            light_right += 1
            light_space[j][right_point] += light_right

        max_light = max(max_light,light_space[j][right_point],light_space[j][i])


print(max_light)


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

int main(int argc, char *argv[]) {
  int N, M, X, Y;
  int x[100], y[100];
  int max_x, min_y;
  int war;
  // read input
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  for (int i = 0; i < N; i++)
    scanf("%d", &x[i]);
  for (int i = 0; i < M; i++)
    scanf("%d", &y[i]);
  // find max_x and min_y
  max_x = -100;
  for (int i = 0; i < N; i++)
    if (x[i] > max_x)
      max_x = x[i];
  min_y = 100;
  for (int i = 0; i < M; i++)
    if (y[i] < min_y)
      min_y = y[i];
  // decide
  war = 1;
  for (int Z = X + 1; Z <= Y; Z++)
    if (Z > max_x && Z <= min_y) {
      war = 0;
      break;
    }
  if (!war)
    printf("No War\n");
  else
    printf("War\n");
  return 0;
}


Measured memory_bytes: 128
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int t;
	cin>>t;
	string st=to_string(t);
	if(st[st.size()-1]=='2'||st[st.size()-1]=='4'||st[st.size()-1]=='5'||st[st.size()-1]=='7'||st[st.size()-1]=='9')
			{
				cout<<"hon";
				return 0;
			}
	else if(st[st.size()-1]=='0'||st[st.size()-1]=='1'||st[st.size()-1]=='6'||st[st.size()-1]=='8')
	{
		cout<<"pon";
		return 0;
	}
	else
	{
		cout<<"bon";
		return 0;
	}
	
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

const int MAX = 2010000000;

int main() {
    string s;
    cin >> s;
    if (s[0] == 'S') {
        if (s[1] == 'A') cout << 1 << endl;
        else cout << 7 << endl;
    } else if (s[0] == 'M') cout << 6 << endl;
    else if (s[0] == 'T') {
        if (s[1] == 'U') cout << 5 << endl;
        else cout << 3 << endl;
    } else if (s[0] == 'W') cout << 4 << endl;
    else if (s[0] == 'F') cout << 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000005;
int n;
int a[2*maxn];
int b[2*maxn];
bool check(int x){
	memset(b,0,sizeof(b));
	for(int i=1;i<=2*n-1;i++)
		if(a[i]>x)b[i]=1;
	int tmp1=1,tmp2=2*n-1;
	for(int i=n-1;i>=1;i--)
		if(b[i]==b[i+1]){tmp1=i+1;break;}
	for(int i=n+1;i<=2*n-1;i++)
		if(b[i]==b[i-1]){tmp2=i-1;break;}
	if(n-tmp1<tmp2-n)return b[tmp1];
	return b[tmp2];
}
void search(){
	int l=0,r=2*n;
	while(l+1<r){
		int mid=l+((r-l)>>1);
		if(check(mid))
			l=mid;
		else
			r=mid;
	}
	printf("%d",r);
}
int main(){
    //freopen("pyramid.in","r",stdin);
    //freopen("pyramid.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
		scanf("%d",&a[i]);
	search();
    return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int m, n;
  while(cin >> m>>n,m||n) {
    int t[n];
    REP(i,n) cin >> t[i];

    queue<int> Q;
    Q.push(0);
    int time = 0;
    int rest[m][2];
    int id[m][2];
    memset(rest, 0, sizeof(rest));
    memset(id, 0, sizeof(id));
    vector<int> ans;
    while(1) {
      int now;
      int mi = INF;
      int p = 0;

      bool f = 0;
      REP(i, m)
        if (id[i][0])
          f=1;
      if (!f && Q.empty() && time/10 >= n)
        break;
      if (Q.empty()) goto label;
      now = Q.front();
      // Ô
      REP(i, m) {
        if (id[i][0]==0) {
          id[i][0] = now+1;
          rest[i][0] = t[now];
          Q.pop();
          goto label;
        }
      }
      REP(i,m) {
        if (id[i][1]==0) {
          if (rest[i][0] >= t[now]) {
            if (mi > rest[i][0] - t[now]) {
              mi = rest[i][0] - t[now];
              p = i;
            }
          }
        }
      }
      if (mi != INF) {
        id[p][1] = id[p][0];
        id[p][0] = now+1;
        rest[p][1] = rest[p][0];
        rest[p][0] = t[now];
        Q.pop();
        goto label;
      }
      REP(i,m) {
        if (id[i][1]==0) {
          if (mi > t[now] - rest[i][0]) {
            mi = t[now] - rest[i][0];
            p = i;
          }
        }
      }
      if (mi != INF) {
        id[p][1] = id[p][0];
        id[p][0] = now+1;
        rest[p][1] = rest[p][0];
        rest[p][0] = t[now];
        Q.pop();
      }
      
    label:
      // Ôoß
      time++;
      REP(i,m) {
        REP(j,2)
          if (rest[i][j])
            rest[i][j]--;
      }
      // REP(i, m) {
      //   printf("%d %d  ", id[i][0], id[i][1]);
      // }cout << endl;
      // REP(i, m) {
      //   printf("%d %d  ", rest[i][0], rest[i][1]);
      // }cout << endl;
      // oÉ
      REP(i,m) {
        if (id[i][0] && rest[i][0] == 0) {
          ans.push_back(id[i][0]);
          id[i][0] = id[i][1];
          id[i][1] = 0;
          rest[i][0] = rest[i][1];
          rest[i][1] = 0;
          if (id[i][0] && rest[i][0] == 0) {
            ans.push_back(id[i][0]);
            id[i][0] = 0;
          }
        }
      }

      // Vµ¢Ô
      if (time%10==0 && time/10 < n)
        Q.push(time/10);
    }
    REP(i, ans.size()) {
      if (i)cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>

using namespace std;

int dp[500][20];

int check(int sum,int i)
{
  //cout<<sum<<" "<<i<<endl;
  if(sum==0)
   return 1;   
  if(sum-(i*i)<0)
    return 0;
  if(i>17)
    return 0;
  int ans=0;
  if(dp[sum][i]!=-1)
    return dp[sum][i];

  ans+=check(sum-(i*i),i);
  ans+=check(sum,i+1); 

  dp[sum][i]=ans;
  return ans;
}

int main()
{
  int n;
  memset(dp,-1,sizeof(dp));
  for(;cin>>n,n;)
    {
      cout<<check(n,1)<<endl;
    }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  set<int> ds;
  rep(i,0,n) {
    int d;
    cin >> d;
    ds.emplace(d);
  }
  cout << len(ds) << endl;
  return 0;
}

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

#define FOR(a, b, c) for (int a = (b), _for = (c); a < _for; ++a)
#define REP(a, n) FOR(a, 0, n)
#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;

inline int ADD(int a,int b){ return a+b>=MOD?a+b-MOD:a+b;}
inline int MUL(int a,int b){ return (ll)a*b%MOD;}

int n;
ll p[MAX];
int ans;

int main(){
	scanf ("%d",&n);
	REP(i,n){
		scanf ("%lld",p+i);
	}
	
	int ans=0;
	int coef=1;
	REP(b,60){
		int c1=0,c2=0;
		REP(i,n){
			if (p[i]&(1ll<<b)) c1++;
			else c2++;
		}
		int x=MUL(c1,c2);
		ans=ADD(ans,MUL(x,coef));
//		printf ("%d\n",coef);
		coef=MUL(coef,2);
	}
	printf ("%d\n",ans);
	
	
	return 0;
}


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

int dp[105];

int main() {
  int n;
  cin >> n;
  dp[0] = 1;
  for (int i = 1; i < 105; i++) {
    if (i - 4 >= 0)
      dp[i] |= dp[i - 4];
    if (i - 7 >= 0)
      dp[i] |= dp[i - 7];
  }
  cout << (dp[n] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    int n; cin>>n;
    vector<string> s(n);
    vector<int> ans(n),p(n);
    rep(i,n)cin>>s[i]>>p[i];

    iota(all(ans),0);
    sort(all(ans),[&](int x, int y){
        if(s[x]==s[y])return p[x]>p[y];
        return s[x]<s[y];
    });
    for(auto x:ans)cout<<x+1<<endl;

}

Measured memory_bytes: 256
// 12.02.2017

/*

Problem Statement

You are given an image A composed of N rows and N columns of pixels, and
a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1?1.
Also, the given images are binary images, and the color of each pixel is either white or black.
In the input, every pixel is represented by a character:
 . corresponds to a white pixel, and # corresponds to a black pixel.
The image A is given as N strings A1,…,AN.
The j-th character in the string Ai corresponds to the pixel at the i-th row and j-th column
of the image A (1 <= i,j <= N).
Similarly, the template image B is given as M strings B1,…,BM.
The j-th character in the string Bi corresponds to the pixel at the i-th row and j-th column
of the template image B (1 <= i,j <= M).
Determine whether the template image B is contained in the image A
when only parallel shifts can be applied to the images.
Constraints
    1 <= M <= N <= 50
    Ai is a string of length N consisting of # and ..
    Bi is a string of length M consisting of # and ..
Input
The input is given from Standard Input in the following format:
N M
A1
A2
:  
AN
B1
B2
:  
BM
Output
Print Yes if the template image B is contained in the image A. Print No otherwise.
Sample Input 1
Copy
3 2
#.#
.#.
#.#
#.
.#
Sample Output 1
Yes
The template image B is identical to the upper-left 2*2 subimage and the lower-right 2*2 subimage of A.
Thus, the output should be Yes.
Sample Input 2
4 1
....
....
....
....
#
Sample Output 2
No
The template image B, composed of a black pixel, is not contained in the image A composed of white pixels.

*/

# include <stdio.h>

//*

//# define __TRR__

//*

//# include <iostream>
//# include <cstdio>
//# include <conio.h>

//using namespace std;

const int N = 51;

int n, m;
char s [N][N], t [N][N];
bool ok;

int main ()
{
# ifdef __TRR__
   freopen ("B.TXT", "r", stdin);
   freopen ("B.OUT", "w", stdout);
# endif

   scanf ("%d %d", &n, &m);
   for ( int i=0; i < n; i++ )
      scanf ("%s", s [i]);
   
   for ( int i=0; i < m; i++ )
      scanf ("%s", t [i]);

# ifdef __TRR__
   printf ("n=%d m=%d\n", n, m);
   for ( int i=0; i < n; i++ )
      printf ("%s\n", s [i]);
   printf ("\n");
   for ( int i=0; i < m; i++ )
      printf ("%s\n", t [i]);
   printf ("\n");
# endif
   
   for ( int i=0; i <= n-m; i++ )
   {
      for ( int j=0; j <= n-m; j++ )
      {
         if ( s [i][j] == t [0][0] )
         {
            ok = true;
            for ( int ii=0; ii < m; ii++ )
            {
               for ( int jj=0; jj < m; jj++ )
                  if ( s [i+ii][j+jj] != t [ii][jj] )
                  {
                     ok = false; break;
                  }
               if ( ! ok )
                  break;
            }

            if ( ok )
               break;
         }

# ifdef __TRR__
   printf ("i=%d j=%d ok=%d s=%c t=%c\n", i, j, ok, s [i][j], t [0][0]);
# endif
            
      }
      if ( ok )
         break;
   }

   if ( ok )
      printf ("Yes");
   else
      printf ("No");

//getch();
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
string s;
int a[3], mn, mx;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	for(char c: s) a[c-'a']++;
	mn = min({a[0], a[1], a[2]});
	mx = max({a[0], a[1], a[2]});
	puts(mx-mn > 1 ? "NO" : "YES");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long max=-32767;
	long long temp;
	long long sum=0,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>temp;
		sum+=temp;
		if(temp>max) max=temp;
	}
	cout<<sum-max/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 998244353
#define MAX 100005
using namespace std;

typedef long double ld;
const ld inf = 2e18;

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

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);

    ll n;
    cin >> n;
    ll m[n]={0};
    ll x[n];
    rep(i,0,n){
    	 cin >> x[i];
    	 m[x[i]]++;
    }
    if(x[0] != 0 or m[0] > 1){
    	cout << "0";
    	return 0;
    }
    ll ans = 1LL;
    rep(i,1,n){
    	ans *= m[x[i]-1];
    	ans %= mod;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 1792
def C(S):
    return S[1:] + S[0]


def J(S):
    return S[-1] + S[:-1]


def E(S):
    temp = len(S) // 2
    if len(S) % 2 == 0:
        S = S[temp:] + S[:temp]
    else:
        S = S[temp + 1:] + S[temp] + S[:temp]

    return S


def A(S):
    return S[::-1]


def M(S):
    temp = []
    for s in S:
        if s.isdecimal():
            temp.append("0" if s == "9" else str(int(s) + 1))
        else:
            temp.append(s)
    return "".join(temp)


def P(S):
    temp = []
    for s in S:
        if s.isdecimal():
            temp.append("9" if s == "0" else str(int(s) - 1))
        else:
            temp.append(s)
    return "".join(temp)


ans = []

n = int(input())

for i in range(n):
    messenger = input()
    messenger = messenger[::-1]
    S = input()
    for m in messenger:
        if m == "J":
            S = J(S)
        elif m == "C":
            S = C(S)
        elif m == "E":
            S = E(S)
        elif m == "A":
            S = A(S)
        elif m == "P":
            S = P(S)
        elif m == "M":
            S = M(S)

    ans.append(S)

for s in ans:
    print(s)


Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];

char grid[2005][2005];
int64_t wc[2000][2000];
int64_t hc[2000][2000];

/* yoko */
void updatewc(int i, int j)
{
    if (wc[i][j])
        return;

    int k = 0;
    while (grid[i + k][j] == '.') {
        k++;
    }

    for (int l = 0; l < k; l++) {
        wc[i + l][j] = k;
    }
}

/* tate */
void updatehc(int i, int j)
{
    if (hc[i][j])
        return;

    int k = 0;
    while (grid[i][j + k] == '.') {
        k++;
    }

    for (int l = 0; l < k; l++) {
        hc[i][j + l] = k;
    }
}

int main()
{
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '.')
                grid[j][i] = '.';
        }
    }

    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (grid[i][j] == '.') {
                updatewc(i, j);
                updatehc(i, j);
            }
        }
    }

    long cnt = 0;
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            cnt = max(wc[i][j] + hc[i][j] - 1, cnt);
        }
    }

    cout << cnt << endl;
}


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

using namespace std;

#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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> S(N+1, 0);
    rep(i, N) {
        int w; cin >> w;
        S[i+1] = S[i] + w;
    }

    int ans = INF;
    rep(i, N) {
        ans = min(ans, abs(S[N] - 2 * S[i]));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n;
    set<int> s;
    FOR(i,0,n){
        cin >> m;
        s.insert(m);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b, sum int
	fmt.Scan(&n, &a, &b)

	for i := 0; i <= n; i++ {
		var c int
		var tmpi = i
		if tmpi >= 10000 {
			c += tmpi / 10000; tmpi %= 10000
		}
		if tmpi >= 1000 {
			c += tmpi / 1000; tmpi %= 1000
		}
		if tmpi >= 100 {
			c += tmpi / 100; tmpi %= 100
		}
		if tmpi >= 10 {
			c += tmpi / 10; tmpi %= 10
		}
		c += tmpi
		if c >= a && c <= b {
			sum += i
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		
		//文字数
		int N=sc.nextInt();
		String nyuryoku=sc.next();
		
		String[] slimOrder=nyuryoku.split("");
		int elementsCnt=slimOrder.length;
	
		for(int i=1;i<slimOrder.length;i++) {
			if(slimOrder[i-1].equals(slimOrder[i])) {
				elementsCnt=elementsCnt-1;
			}
		}
		
		System.out.println(elementsCnt);
	}

}


Measured memory_bytes: 34396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
ll getint(){
    re ll num;
    re char c;
    re bool f=0;
    while(!isdigit(c=gc()))f^=c=='-';num=c^48;
    while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48);
    return f?-num:num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=a-a/10*10,a/10;
	while(ch[0])pc(ch[ch[0]--]^48);
}

int n;
cs int N=100005;
int cnt[2][N];
int maxn[2],num[2],submaxn[2],subnum[2];
signed main(){
	n=getint();
	for(int re i=2;i<=n+1;++i){
		int a=getint();
		++cnt[i&1][a];
		if(maxn[i&1]<cnt[i&1][a]){
			if(num[i&1]==a){
				maxn[i&1]=cnt[i&1][a];
			}
			else {
				subnum[i&1]=num[i&1];
				submaxn[i&1]=maxn[i&1];
				maxn[i&1]=cnt[i&1][a];
				num[i&1]=a;
			}
		}
		else if((cnt[i&1][a]==maxn[i&1]&&num[i&1]!=a)||cnt[i&1][a]>submaxn[i&1]){
			submaxn[i&1]=cnt[i&1][a];
			subnum[i&1]=a;
		}
	}
	int ans;
	if(num[0]!=num[1])ans=n-maxn[0]-maxn[1];
	else ans=n-max(maxn[0]+submaxn[1],maxn[1]+submaxn[0]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int bil[4][3][10]={0};
    int n,i,j,l;
    int b,r,f,v;
    scanf("%d",&n);
    for(;n;n--)
    {
        scanf("%d%d%d%d",&b,&f,&r,&v);
        bil[b-1][f-1][r-1] +=v;
    }
    for(i=0;i<4;i++)
    {
        for(j=0;j<3;j++)
        {
            for(l=0;l<10;l++)
            {
                printf(" %d",bil[i][j][l]);
            }
//             if(!(i==3 && j==2))
            printf("\n");
        }
        if(i!=3)
        printf("####################\n");
//         printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2036
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if( n<=100 ){
			int a[] = new int[n];
			for( int i=0; i<n; i++ ){
				a[i] = sc.nextInt();
			}
			for( int i=n-1; i>=0; i-- ){
				System.out.print( a[i] );
				if( i!=0 ){
					System.out.print( " " );
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 19648
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
//

     signed main(){
       int x,y,a,b,c;
       cin>>x>>y>>a>>b>>c;
       int p[a],q[b],r[c];
       for(int i=0;i<a;i++)cin>>p[i];
       for(int i=0;i<b;i++)cin>>q[i];
       for(int i=0;i<c;i++)cin>>r[i];
       sort(p,p+a);sort(q,q+b);sort(r,r+c);int d[x+y];
       priority_queue<int,vector<int>,greater<int>> que;
       for(int i=a-1;i>=a-x;i--){
            d[a-1-i]=p[i];
           
       }
       for(int i=b-1;i>=b-y;i--){
            d[x+b-1-i]=q[i];
       }sort(d,d+x+y);
       for(int i=x+y-1;i>0;i--)d[i-1]+=d[i];
       int t=0,ans=d[0],o=0;
       for(int i=1;i<min(x+y,c+1);i++){
            t+=r[c-i];
            ans=max(ans,d[i]+t);
         

       }
       cout<<ans<<endl;

       

   }
         


        


Measured memory_bytes: 3968
#include<stdio.h>

int main () {
long long int t, sum =1;
scanf("%lld",&t);

long long int n[t];
for(int i=0;i<t;i++){
    scanf("%lld",&n[i]);
}
for(int i=0; i<t; i++){
  if (n[i] ==0 ){
    printf("0");
    return 0;
  }

}
for (int i=0; i<t;i++){
  if(n[i] <=1000000000000000000 /sum){
    sum *= n[i];
  }
  else{
    printf("-1");
    return 0;
  }
}
printf("%lld",sum);
return 0;
}


Measured memory_bytes: 2508
n = int(input())
a = list(map(lambda x: int(x), input().split()))

max = a[0]
min = a[0]
sum = 0

i = 0
while i < n:
    if a[i] > max:
        max = a[i]
    if a[i] < min:
        min = a[i]
    sum += a[i]
    i += 1
    
print (str(min) + " " + str(max) + " " + str(sum))



Measured memory_bytes: 6600
A, B, C, X, Y = map(lambda x: int(x), input().split())
price = A * X + B * Y
for Z in range(2, X * 2 + 1 if X > Y else Y * 2 + 1, 2):
    x, y = int(X - Z / 2), int(Y - Z / 2)
    x, y = 0 if x < 0 else x, 0 if y < 0 else y
    next_price = A * x + B * y + C * Z
    if next_price >= price:
        break
    price = next_price
print(price)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int acc=0,ans=0;
  rep(i,N) {
    if(s[i]=='I') {
      acc++;
    } else {
      acc--;
    }
    chmax(ans,acc);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if (A >=K ){
    cout << K << endl;
  }
  else if (A+B>=K){
    cout << A << endl;
  }
  else {
    cout << A-(K-A-B) << endl;
  }
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int zyo,suu,ri,ei;
	int zyo2,suu2,ri2,ei2;
	int s,t;
	s=0;
	t=0;
	
	scanf("%d %d %d %d",&zyo,&suu,&ri,&ei);
	scanf("%d %d %d %d",&zyo2,&suu2,&ri2,&ei2);
	s=zyo+suu+ri+ei;
	t=zyo2+suu2+ri2+ei2;
	if(s<=t){
		printf("%d\n",t);
	}
	else{
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1020
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
rate_dict = defaultdict(int)
for a in A:
    if 1 <= a <= 399:
        rate_dict["gray"] += 1
    elif 400 <= a <= 799:
        rate_dict["brown"] += 1
    elif 800 <= a <= 1199:
        rate_dict["green"] += 1
    elif 1200 <= a <= 1599:
        rate_dict["light_blue"] += 1
    elif 1600 <= a <= 1999:
        rate_dict["blue"] += 1
    elif 2000 <= a <= 2399:
        rate_dict["yellow"] += 1
    elif 2400 <= a <= 2799:
        rate_dict["orange"] += 1
    elif 2800 <= a <= 3199:
        rate_dict["red"] += 1
    elif 3200 <= a:
        rate_dict["free"] += 1
ans = sum([1 if x in rate_dict else 0
           for x in ["gray", "brown", "green", "light_blue", "blue", "yellow", "orange", "red"]])
min_ans = ans
if "free" in rate_dict:
    if len(set(list(rate_dict.keys()))) == 1:
        min_ans = 1
    max_ans = ans + rate_dict["free"]
else:
    max_ans = min_ans
print("{} {}".format(min_ans, max_ans))


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll a, b, c, d;

int main() {
    cin >> a >> b >> c >> d;
    ll ans = LLONG_MIN;
    ans = max(ans, a * c);
    ans = max(ans, b * d);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int h[N] = {};
  for(int i=1; i<N+1; i++)
    cin >> h[i];
  int cost[N] = {};
  for(int i=0; i<N+1; i++)
    cost[i] = -1;
  cost[1] = 0;
  cost[2] = abs(h[2]-h[1]);
  for(int i=3; i<N+1; i++)
    cost[i] = min(cost[i-2] + abs(h[i]-h[i-2]),
                  cost[i-1] + abs(h[i]-h[i-1]));
  cout << cost[N] << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 10;
const int mod = 1e9 + 7;
typedef long long ll;

int n;
ll gt[maxN], igt[maxN];
int a[maxN], vis[maxN];

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

void init() {
  const int maxp = 1e5 + 1;
  gt[0] = 1;
  for (int i = 1; i <= maxp; ++i) {
    gt[i] = (gt[i-1] * i) % mod;
  }
  igt[maxp] = Pow(gt[maxp], mod - 2);
  for (int i = maxp - 1; i >= 0; --i) {
    igt[i] = (igt[i+1] * (i+1)) % mod;
  }
}

int mul(int x, int y) {
  return (1ll * x * y) % mod;
}

int comb(int k, int n) {
  if (k > n) return 0;
  return mul(mul(gt[n], igt[k]), igt[n-k]);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  init();
  cin >> n;
  int vt1 = -1, vt2 = -1;
  for (int i = 1; i <= n + 1; ++i) {
    int x; cin >> x;
    if (vis[x]){
      vt1 = vis[x]; vt2 = i;
    }
    vis[x] = i;
  }
  for (int k = 1; k <= n + 1; ++k) {
    cout << (0ll + comb(k, n + 1) - comb(k-1, n-vt2+vt1) + mod) % mod << '\n';
  }
  return 0;
}


Measured memory_bytes: 5576
#include "bits/stdc++.h"
using namespace std;
long long N,M,K,L,R,s,m;
int main(){cin>>N>>K>>M;vector<int>v(N);for(auto &i:v)cin>>i;L=-1,R=N;while(R-L>1){m=(R+L)/2;vector<int>w(1);for(auto i:v)w.push_back(i<=m);for(int i=1;i<=N;i++)w[i]+=w[i-1];w.push_back(1e8);s=0;for(int i=0;i<N;i++)s+=w.end()-lower_bound(w.begin(),w.end(),w[i]+K)-1;if(s>=M)R=m;else L=m;}cout<<R<<endl;}


Measured memory_bytes: 5416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		long x = kb.nextLong();
		long y = 100;
		int count = 0;
		while (true) {
			y = (long) (1.01 * y);
			count += 1;
			if (y >= x) {
				System.out.println(count);
				break;
			}

		}
		kb.close();
	}

}


Measured memory_bytes: 27064
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n, r;
    cin >> n >> r;

    if (n >= 10)
        print(r);
    else
        print(r + 100 * (10 - n));

    return 0;
}



Measured memory_bytes: 256
A, B, C = map(int, raw_input().split())

if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print '0'
elif A == B and B == C:
    print '-1'
else:
    i = 0
    while True:
        _A = (B + C)/2
        _B = (C + A)/2
        _C = (A + B)/2

        A = _A
        B = _B
        C = _C

        i += 1
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            print '%d' % i
            break


Measured memory_bytes: 2568
n, k = map(int, input().split())
MOD =10**9+7

memo = [[{} for j in  range(n+1)] for i in range(n+1)]

def fdp(cur_N, remain, min_k, MOD=10**9+7):
    if cur_N <= 1:
        if remain == 0 and min_k == 0:
            return 1
        if remain == 1 and min_k == 2:
            return 1
        else:
            return 0
    if min_k in memo[cur_N][remain]:
        ret = memo[cur_N][remain][min_k]
        return ret
    
    temp1 = fdp(cur_N-1, remain, min_k - 2*remain) %MOD
    temp2 = fdp(cur_N-1, remain+1, min_k -2*remain) %MOD
    temp3 = fdp(cur_N-1, remain-1, min_k-2*remain) % MOD
    score = (temp1*(2*remain+1))%MOD +(temp2*(remain+1)*(remain+1))%MOD+temp3
    score = score % MOD
    memo[cur_N][remain][min_k] = score
    return score
ret = fdp(n, 0, k)
print(ret)

Measured memory_bytes: 80504
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define int long long int
#define inf 1000000000
int32_t main()
{
	int n,m;
	cin>>n>>m;
	vector<int> dist(n+1,1000000000);
	vector<int> adj[n+1];
	int j;
	for(j=0;j<m;j++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	bool visited[n+1]={false};
	q.push(1);
	visited[1]=true;
	vector<int> parent(n+1,-1);
	parent[1]=-1;
	dist[1]=0;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int y:adj[x])
		{
			if(!visited[y])
			{
				visited[y]=true;
				q.push(y);
				dist[y]=1+dist[x];
				parent[y]=x;
			}
		}
	}
	for(j=1;j<=n;j++)
	{
		if(dist[j]>=inf)
		{
			cout<<"No"<<endl;
			exit(0);
		}
	}
	cout<<"Yes"<<endl;
	for(j=2;j<=n;j++)
	{
		cout<<parent[j]<<endl;
	}
}


Measured memory_bytes: 13732
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s;
    cin >> s;
    if(s[0]==s[1]||s[2]==s[1]||s[2]==s[3])pr("Bad");
    else pr("Good");
}

Measured memory_bytes: 256
#include<stdio.h>
     
    int main(){
     int N,D;
      scanf("%d %d",&N,&D);
      int i;
      i=2*D+1;
      if(N%i==0){printf("%d\n",N/i);}
      else{printf("%d\n",N/i+1);}
      return 0;
    }

Measured memory_bytes: 128
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()

if n*2 >= m:
    print(m//2)
else:
    ret = m-(n*2)
    print(n+ret//4)

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

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x,v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<ll,ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector <vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 3005;

int len1, len2;
string a, b, ans;
int dp[N][N], m[N][N];
int lcs(int n, int m) {
    if(n < 0 or m < 0) return 0;
    if(~dp[n][m]) return dp[n][m];
    if(a[n] == b[m]) return dp[n][m] = 1 + lcs(n-1, m-1);
    else return dp[n][m] = max(lcs(n-1, m), lcs(n, m-1));
}

int lcs2() {
    for (int i = 1; i <= len1; i++)
        for (int j = 1; j <= len2; j++)
            if (a[i-1] == b[j-1])
                m[i][j] = 1 + m[i-1][j-1];
        else
            m[i][j] = max(m[i][j-1], m[i-1][j]);
    return m[len1][len2];
}
void rec(int i, int j){
    int now = dp[i][j];
    int top, left, diag;
    if(i!=0) top = dp[i-1][j];
    else top = -1;
    if(j!=0) left = dp[i][j-1];
    else left = -1;
    if(i!=0 and j!=0) diag = dp[i-1][j-1];
    else diag = -1;
    if(~left and a[i]==b[j]){
        rec(i,j-1);
        return;
    }
    if(~top and a[i] == b[j]){
        rec(i-1,j);
        return;
    }
    if(~diag){
        if(diag < now and a[i]==b[j]) ans += a[i];
        rec(i-1,j-1);
        return;
    }
}

void rec2(int i, int j){
    //cout << " i: " << i << " j: " << j;
    if(!i or !j) return;
    int left = m[i][j-1], top = m[i-1][j], diag = m[i-1][j-1], now = m[i][j];
    if(now - diag == 0){
        rec2(i-1, j-1);
    }
    else if(now - left == 0){
        rec2(i, j-1);
    }
    else if(now - top == 0){
        rec2(i-1, j);
    }
    else if(now - diag == 1){
    //    cout << " a[i]: " << a[i-1] << "\n";
        ans += a[i-1];
        rec2(i-1, j-1);
    }
    /*if(now - left == 1 and a[i]==b[j]){
        rec2(i, j-1);
    }
    else if(now - top == 1){
        rec2(i, j-1);
    }
    else if(now - diag == 1 and a[i]==b[j]){
        ans += a[i];
        rec2(i, j-1);
    }*/
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin >> a >> b;
    len1 = a.size(), len2 = b.size();
    //lcs(len1-1, len2-1);
    //lcs(len1-1,len2-1);
    lcs2();
    /*for(int i=0;i<=len1;i++){
        for(int j=0;j<=len2;j++){
            cout << m[i][j] << "\t";
        }
        cout << "\n";
    }*/
    int aux = 0;
    rec2(len1,len2);
    for(int i=ans.size()-1;i>=0;i--) cout << ans[i];
    cout << "\n";
    return 0;
}
// arada

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

int main()
{
    int x,y;
    cin >> x >> y;

    int sum = 0;
    if(x == 3) sum+=100000;
    if(y == 3) sum+=100000;
    if(x == 2) sum+=200000;
    if(y == 2) sum+=200000;
    if(x == 1) sum+=300000;
    if(y == 1) sum+=300000;

    if(x==1 && y==1) sum += 400000;

    cout << sum << endl;

    return 0;
}

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

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

  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> cnt(N, 0);
  for (ll i = 0; i < K; i++) {
    ll d; cin >> d;
    for (ll j = 0; j < d; j++) {
      ll a; cin >> a;
      a--;
      cnt[a]++;
    }
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    if (cnt[i] == 0) ans++;
  }

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

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) FOR(i,0,n)

int main(){
	int n;
	while(cin>>n,n){
		int ret=0;
		FOR(i,1,n){
			int sum=0;
			for(int j=i;j<n;j++){
				sum+=j;
				if(sum==n)ret++;
			}
		}
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 0