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

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define MAX 77

ll mod=1e9+9;

ll H,W,N;
ll B[MAX][MAX];

ll tmp[MAX][MAX];
void mul(ll a[MAX][MAX],ll b[MAX][MAX]){
  for(int i=0;i<W;i++)
    for(int j=0;j<W;j++)
      tmp[i][j]=0;
  

  for(int i=0;i<W;i++){
    for(int k=0;k<W;k++){  
      for(int j=0;j<W;j++){
        tmp[i][j]+=(a[i][k]*b[k][j]);
        tmp[i][j]%=mod;
      }
    }
  }
  for(int i=0;i<W;i++)
    for(int j=0;j<W;j++)
      a[i][j]=tmp[i][j];
}


ll nans[MAX];
ll ans[MAX];
          
ll met[MAX][MAX];
void mpow(ll a[MAX][MAX],ll n){
  while(n){
    if(n&1LL){
      for(int i=0;i<W;i++){
        nans[i]=0;
        for(int j=0;j<W;j++){
          nans[i]+=(a[i][j]*ans[j]);
          nans[i]%=mod;
        }
      }

      for(int i=0;i<W;i++)ans[i]=nans[i];
    }
    mul(a,a);
    n=(n>>1LL);
  }
  for(int i=0;i<W;i++)
    for(int j=0;j<W;j++)
      a[i][j]=met[i][j];
}

int main(){
  for(int tc=1;;tc++){
    scanf("%lld %lld %lld",&W,&H,&N);
    
    if(W==0&&H==0&&N==0)break;
    
    vector<ll> v;
    unordered_map< ll , vector<ll> >G;

    memset(ans,0,sizeof(ans));
    ans[0]=1;

    memset(B,0,sizeof(B));
    for(int i=0;i<W;i++){
      if(i+1<W)B[i][i+1]++;
      B[i][i]++;
      if(i-1>=0)B[i][i-1]++;
    }
    

    for(int i=0;i<N;i++){
      ll x,y;
      scanf("%lld %lld",&x,&y);
      v.push_back(y);
      G[y].push_back(x);
    }

    v.push_back(H);
    sort(v.begin(),v.end());
    v.erase( unique(v.begin(),v.end()) , v.end() );

    ll C[MAX][MAX];

    
    ll last=1;
    for(int I=0;I<(int)v.size();I++){
      ll h=v[I];
      ll dist=h-last;


      for(int i=0;i<W;i++)
        for(int j=0;j<W;j++)
          C[i][j]=B[i][j];

      mpow(C,dist);

      
      last=h;

      if(G.count(h)==0)continue;
      for(int j : G[h] ){
        ans[j-1]=0;
      }
    }
    cout<<"Case "<<tc<<": "<<ans[W-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
  int n;
  cin>>n;
  if(n==0){
    cout<<1<<endl;
  }
  else if(n==1){
    cout<<0<<endl;
    
  }
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int n; cin >> n;
    V<V<int> > f(n, V<int>(10));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    V<V<int> > c(n, V<int>(11));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> c[i][j];
        }
    }

    ll ans = -INF;
    for(int bit = 1; bit < (1 << 10); bit++){
        ll sum = 0;
        for(int i = 0; i < n; i++){
            ll cnt = 0;
            for(int j = 0; j < 10; j++){
                if(bit & (f[i][j] << j)){
                    cnt++;
                }
            }
            sum += c[i][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;

}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ", ";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    bool f = false;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        f = f || (i * 4 + j * 7) == n;
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,Y;
  cin>>N>>Y;
  
  int a1=-1;
  int a2=-1;
  int a3=-1;
  
  for(int x=0;x<=Y/10000;x++){
    for(int y=0;y<=Y/5000;y++){
      if(10000*x+5000*y+1000*(N-x-y)==Y&&N>=x+y){
        a1=x;
        a2=y;
        a3=N-x-y;
      }
    }
  }
  
  cout<<a1<<" "<<a2<<" "<<a3<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int count=N;
    vector<int>vec(N);
    vector<bool>answer(N);
    vector<int>A(M);
    vector<int>B(M);
    for(int i=0; i<N; i++){
    cin>>vec.at(i);
    }
    for(int i=0; i<M; i++){
     cin>>A.at(i);
     cin>>B.at(i);
    }
    for(int i=0; i<M; i++){
    if(vec.at(A.at(i)-1)>=vec.at(B.at(i)-1)){
    answer.at(B.at(i)-1)=true;
    }
    if(vec.at(A.at(i)-1)<=vec.at(B.at(i)-1)){
    answer.at(A.at(i)-1)=true;
    }
    }
    for(int i=0; i<N; i++){
    if(answer.at(i)==true){
    count--;
    }
    
    }
    cout<<count<<endl;
}

Measured memory_bytes: 4576
using System;


namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; 0<i; i++)
            {

                String[] str = Console.ReadLine().Split(' ');
                int W = int.Parse(str[0]);
                int H = int.Parse(str[1]);
                
                string line = "";

                if (W == 0 && H == 0)
                {
                    return;
                }
                for (int j = 0; j < H; j++)
                {

                    line = line + "#";

                }

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

                    Console.WriteLine(line);


                }

                Console.WriteLine();

                


            }
        }
    }
}

Measured memory_bytes: 8908
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
/*typedef long long ll;
ll a[55];

int main(){
    ll n;
    scanf("%I64d",&n);
    for(int i=1;i<=50;i++)
        a[i]=n/50+i-1;
    n%=50;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=50;j++)
            a[j]--;
        a[i]+=51;
    }
    puts("50");
    for(int i=1;i<=50;i++){
        if(i!=1)
            printf(" ");
        printf("%I64d",a[i]);
    }
    printf("\n");
    return 0;
}*/
typedef long long ll;
ll n;
ll a[55];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=50;i++)
    {
        a[i]=n/50+i-1;
    }
    n%=50;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=50;j++)
        {
            a[j]--;
        }
        a[i]+=51;
    }
    printf("50\n");
    for(int i=1;i<=50;i++)
    {
        if(i!=1) printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[][][] directedGraph(int n, int[] from, int[] to, int[] cost) {
		int[] cnt = new int[n];
		for (int i : from) cnt[i]++;

		int[][][] g = new int[n][][];
		for (int i=0; i<n; i++) g[i] = new int[cnt[i]][2];
		for (int i=0; i<from.length; i++) {
			int s = from[i];
			int t = to[i];

			g[s][--cnt[s]][0] = t;
			g[s][cnt[s]][1] = cost[i];
		}

		return g;
	}

	static int[] bellmanFord(int[][][] g, int source) {
		int n = g.length;
		int[] d = new int[n];
		Arrays.fill(d, 1<<30);
		d[source] = 0;

		for (int i=0; i<n; i++) {
			for (int cur=0; cur<n; cur++) {
				for (int[] to : g[cur]) {
					if (d[to[0]] > d[cur] + to[1] && d[cur] != 1<<30) {
						d[to[0]] = d[cur] + to[1];
						if (i == n-1) return null; // negative cycle
					}
				}
			}
		}

		return d;
	}

	static void solve() {
		int v = in.nextInt();
		int e = in.nextInt();
		int r = in.nextInt();
		int[] s = new int[e];
		int[] t = new int[e];
		int[] d = new int[e];
		for (int i=0; i<e; i++) {
			s[i] = in.nextInt();
			t[i] = in.nextInt();
			d[i] = in.nextInt();
		}
		int[][][] g = directedGraph(v, s, t, d);
		int[] ans = bellmanFord(g, r);
		if (ans == null) {
			out.println("NEGATIVE CYCLE");
			return;
		}
		for (int i=0; i<v; i++) {
			out.println(ans[i] == 1<<30 ? "INF" : ans[i]);
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 36248
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  float x;
  cin>>n;
  vector <float> vi;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    vi.emplace_back(x);
  }

  sort(vi.begin(),vi.end());

   float temp = (vi[0]+vi[1])/2;

  for(int i=1;i<n-1;i++)
  {
    temp=(temp+vi[i+1])/2;
  }

  cout<<temp;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>

using namespace std;

typedef long long ll;

int main(void){
    ll n,t;
    cin >> n >> t;
    vector<ll> ti(n);
    for(ll i = 0;i < n;i++){
        cin >> ti[i];
    }
    ll ans = 0;
    ll dif = 0;
    for(ll i = 0;i < n;i++){
        if(i != n - 1 && ti[i + 1] - ti[i] < t){
            dif += t - (ti[i + 1] - ti[i]);
        }
        ans += t;
    }
    cout << ans - dif << endl;
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin

N = int(input())
lst = []
for i in range(N):
    city, score = stdin.readline().split()
    lst.append((city, int(score), i + 1))

lst.sort(key=lambda x: x[1], reverse=True)
lst.sort(key=lambda x: x[0])
for tup in lst:
    c, s, i = tup
    print(i)


Measured memory_bytes: 3060
N,W = map(int,input().split())
item = [list(map(int,input().split())) for _ in range(N)]

dp = [0 for _ in range(W+1)]

for i in range(N):
    v,w = item[i]
    for j in range(W+1)[::-1]:
        if j-w>=0:
            dp[j] = max(dp[j-w]+v,dp[j])

print(dp[W])


Measured memory_bytes: 5976
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
  if A[i] == B[i] == C[i]:
    cnt += 0
  elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
    cnt += 2
  else:
    cnt += 1
print(cnt)

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

int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	vector<vector<ll>> dp(h,vector<ll>(w));
	dp[0][0]=1;
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='.'){
				if(i>0) dp[i][j]+=dp[i-1][j];
				if(j>0) dp[i][j]+=dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, M;
	cin >> N >> M;
	lint ans = 0;
	if (N * 2 <= M) {
		ans = N * 2 + M;
		cout << ans / 4 << endl;
	}
	else {
		ans = M / 2;
		cout << ans << endl;
	}
}

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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数
//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}
//to_char
char to_char(int i){
  if (i == 0) {
    return '0';
  }
  if (i == 1) {
    return '1';
  } 
  if (i == 2) {
    return '2';
  } 
  if (i == 3) {
    return '3';
  }
  if (i == 4) {
    return '4';
  } 
  if (i == 5) {
    return '5';
  } 
  if (i == 6) {
    return '6';
  }
  if (i == 7) {
    return '7';
  } 
  if (i == 8) {
    return '8';
  } 
  if (i == 9) {
    return '9';
  }
  return ' ';  
}
//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  int R = 0;
  int L = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    R = max(R, A.at(i));
  }
  while (R - L > 1) {
    int M = (L + R) / 2;
    int C = 0;
    for (int i = 0; i < N; i++) {
      C += (A.at(i) / M);
      if (A.at(i) % M == 0) {
        C--;
      }
    }
    if (C <= K) {
      R = M;
    }
    else {
      L = M;
    }
  }
  cout << R << endl;
}

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

int main()
{
	int N, buf;
	cin >> N;

	vector<int> arr(100001, 0);
	for (int i = 0; i < N; i++) {
		cin >> buf;
		arr[buf]++;
	}

	int cnt = 0;
	int evenCnt = 0;
	for (int i = 1; i < 100001; i++) {
		if (arr[i]) {
			cnt++;
			if (arr[i] % 2 == 0)
				evenCnt++;
		}
	}
	if (evenCnt % 2 != 0)
		cnt--;

	cout << cnt << endl;

	return 0;
}






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

string S;

int main(){
    cin >> S;
    int A1,Z2;

    for(int i=0;i<S.size();i++){
        if(S.at(i)=='A'){
            A1 = i;
          break;
        }
    }
  //cout << A1 << endl;
    for(int i=S.size()-1;i>=0;i--){
        if(S.at(i)=='Z'){
            Z2 = i;
          break;
        }
    }
    cout << Z2-A1+1 << endl;
    
}

Measured memory_bytes: 640
Imports System
Public Class B200
    Public Shared Sub Main()
        Dim N As Long
        N = Console.ReadLine()
        Dim L(N) As Long
        L(0) = 2
        L(1) = 1
        For i As Integer = 2 To N
            L(i) = L(i - 1) + L(i - 2)
        Next i
        Console.WriteLine(L(N))
    End Sub
End Class


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

int main () {
  int x1 , y1 , x2 , y2 ;
  cin >> x1 >> y1 >> x2 >> y2 ;
  int x3 , y3 , x4 , y4 ;
  x3 = x2 - ( y2 - y1 ) ;
  y3 = y2 + ( x2 - x1 ) ;
  x4 = x1 - ( y2 - y1 ) ;
  y4 = y1 + ( x2 - x1 ) ;
  cout << x3 << ' ' << y3 << ' ' <<  x4 << ' ' << y4 << endl ;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int ans = 0;
        int n = in.nextInt();
        int mx=0;
        String t = in.next();
        for (int i =0;i<n;i++){
            if(t.charAt(i)=='D'){
                ans--;
            }
            else {
                ans++;
                mx = Math.max(mx,ans);
            }
        }
        System.out.println(mx);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long int

ll x;

ll f(ll n){
	if(n!=-1)return n/x+1;
	return 0;
}

int main(void){
	ll a,b,ans=0,i;
	scanf("%lld%lld%lld",&a,&b,&x);
	ans = f(b) - f(a-1);
	printf("%lld",ans);
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    int p[n];
    rep(i, n) cin >> p[i];

    double E[1010] = {};
    for (int i = 1; i <= 1010; i++)
    {
        E[i] = ((double)i + 1) / 2;
    }

    double sum = 0;
    rep(i, k) sum += E[p[i]];

    double ans = sum;
    for (int i = k; i < n; i++)
    {
        sum = sum - E[p[i - k]] + E[p[i]];
        ans = max(ans, sum);
    }

    printf("%.8f\n", ans);

    return 0;
}

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

int search(char *a){
    if(a[0] == '\0') return 1;
    int ans = 0;
    if((strstr(a,"dream") - a) == 0){
        ans += search(&a[5]);
        if(a[5] == 'e' && a[6] == 'r') ans += search(&a[7]);
    }
    if((strstr(a,"erase") - a) == 0){
        ans += search(&a[5]);
        if(a[5] == 'r') ans += search(&a[6]);
    }
    if(ans > 0) return 1;
    else return 0;
}

int main(void){
    char s[100001];
    scanf("%s",&s);
    if(search(s) > 0) printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int k, s, ans = 0;

    cin >> k >> s;

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

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

            if (s-i-j <= k && s-i-j >= 0) ans++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <ratio>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int x;
    cin >> x;

    x -= 400;

    cout << 8 - x / 200 << "\n";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
 
vi sum;
ll dp[402][402];
 
ll fun(ll i,ll j){
  if(i==j)return 0;        // cost will be 0 for single element to form single slime
  if(dp[i][j]!=-1)return dp[i][j];
  ll res = sum[j]-(i>0?sum[i-1]:0);  // computing sum from i to j
  ll mini = 1e18;
 
  for(int r=i;r<=j-1;r++)
    mini=min(mini,fun(i,r)+fun(r+1,j));    // finding minimum cost for combining two slimes into one 
 
  return dp[i][j]= res + mini;
}
 
int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
 
    ll n;
    cin>>n;
    ll a[n];
    fori(0,n)cin>>a[i];
 
    memset(dp,-1,sizeof dp);
 
    sum.resize(n);
    sum[0]=a[0];
    fori(1,n)sum[i]=sum[i-1]+a[i];   //sum precomputation
 
 
    cout<<fun(0,n-1);
 
    
    
 
 
    
    
 
return 0;
}

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

int n,m,x,y,ar[1003],br[1003],i;
bool war;

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

    cin>>n>>m>>x>>y;
    for(i=0;i<n;i++)cin>>ar[i];
    for(i=0;i<m;i++)cin>>br[i];
    sort(ar,ar+n);
    sort(br,br+m);

    war=true;
    for(i=x+1;i<=y;i++){
        if(ar[n-1]<i && br[0]>=i) war=false;
    }

    if(war)cout<<"War\n";
    else cout<<"No War\n";
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class UnionFind{
private:
	std::vector<int_fast32_t> par;
	size_t n;

public:
	UnionFind(){}
	UnionFind(size_t n):n(n){
		par.resize(n, -1);
	}

	uint_fast32_t find(uint_fast32_t x){
		return par[x] < 0 ? x : par[x] = find(par[x]);
	}

	size_t size(uint_fast32_t x){
		return -par[find(x)];
	}

	void unite(uint_fast32_t x, uint_fast32_t y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(size(x) < size(y)) std::swap(x, y);
		par[x] += par[y];
		par[y] = x;
	}

	bool same(uint_fast32_t x, uint_fast32_t y){
		return find(x) == find(y);
	}
};

const int64 mod = 1e9+7;

int32 toint(string s){
	int32 res = 0;
	REP(i, s.size()){
		res = (res*10+s[i]-'0');
	}
	return res;
}

int main(void){
	string s;
	cin >> s;
	int32 res = INF;
	REP(i, s.size()-2){
		res = min(res, abs(toint(s.substr(i, 3))-753));
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	for(int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (n == (i * j)) {
				cerr << "i=" << i << endl;
				cerr << "j=" << j << endl;
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
	return;
}

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
S=input()
K=INT()

s=S[K-1]
T=''
for i in range(N):
    if S[i]==s:
        T+=s
    else:
        T+='*'
print(T)


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

std::vector<int> sp()
{
	std::string temp;
	std::getline(std::cin, temp, '\n');
	std::stringstream ss(temp);
	std::string line;
	std::vector<int> res;
	while (std::getline(ss, line, ' '))
	{
		res.push_back(std::stoi(line));
	}

	return res;
}

int main()
{
	int n, m;
	auto v0 = sp();
	n = v0[0];
	m = v0[1];

	std::vector<std::vector<int> > res;
	for (int nn = 0; nn < n; ++nn)
	{
		res.push_back(sp());
	}

	std::vector<int> vec;
	for (int mm = 0; mm < m; ++mm)
		vec.push_back(sp()[0]);

	for (int nn = 0; nn < n; ++nn)
	{
		for (int mm = 0; mm < m; ++mm)
		{
		    res[nn][mm] *= vec[mm];
		}
	}
	
	for (int nn = 0; nn < n; ++nn)
	{
	    int sum = 0;
	    for (int mm = 0; mm < m; ++mm)
	    {
	        sum += res[nn][mm];
	    }
	    
	    std::cout << sum << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
	class _061A
    {
        static void Main()
        {
            var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
			var ans = "No";
			if(arr[0] <= arr[2] && arr[1] >= arr[2] )
				ans = "Yes";
			
			Console.WriteLine(ans);
        }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,w=0,r=0;
string str;
signed main()
{
    ;;;;;
    cin>>n;
    cin>>str;
    for (int i=0;i<n;i++) if (str[i]=='R') w++;
    for (int i=0;i<w;i++) if (str[i]=='W') r++;
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 3752
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];



		Console.WriteLine("ABC" + int.Parse(Console.ReadLine()));


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

	public class PriQ {
		public int rank { get; set; }
		public string rankstr { get; set; }
		public int num { get; set; }
		public int[] nums { get; set; }
		public Object obj { get; set; }
		public PriQ() { }
	}

	public class PriorityQueue {
		List<PriQ> list = new List<PriQ>();
		public PriorityQueue() { }
		public PriorityQueue(PriQ p) { list.Add(p); }
		public void Enqueue(PriQ item) { list.Insert(Binary_Search(item), item); }
		public PriQ Dequeue() { PriQ r = list[0]; list.RemoveAt(0); return r; }
		public PriQ DequeueLast() { PriQ r = list[list.Count - 1]; list.RemoveAt(list.Count - 1); return r; }
		public PriQ Peek() { return list[0]; }
		public PriQ Get(int n) { return list[n]; }
		public PriQ Last() { return list[list.Count - 1]; }
		public void Remove(int n) { list.RemoveAt(n); }
		public int Count { get { return list.Count; } }

		private int Binary_Search(PriQ pq) {
			int Lower = 0;
			int Upper = list.Count - 1;
			while (Lower <= Upper) {
				int Center = ( Lower + Upper ) >> 1;
				if (pq.rank > list[Center].rank) {
					Lower = Center + 1;
				} else if (pq.rank < list[Center].rank) {
					Upper = Center - 1;
				} else {
					return Center;
				}
			}
			return Lower;
		}
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] n = new int[scan.nextInt()];
		String str = "Yes";
		for (int i = 0; i < n.length; i++) {
			n[i] = scan.nextInt();
		}
		for (int i = n.length - 1; 0 < i; i--) {
			if (n[i - 1] > n[i]) {
				n[i - 1] = n[i - 1] - 1;
			}
		}
		for (int i = 0; i < n.length - 1; i++) {
			if (n[i + 1] < n[i]) {
				str = "No";
			}
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 52160
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            String[] lines = line.split(" ");
            int a = Integer.parseInt(lines[0]);
            String op = lines[1];
            int b = Integer.parseInt(lines[2]);
            if (op.equals("+")) {
                System.out.println(a + b);
            } else if (op.equals("-")) {
                System.out.println(a - b);
            } else if (op.equals("*")) {
                System.out.println(a * b);
            } else if (op.equals("/")) {
                System.out.println(a / b);
            } else {
                break;
            }
        }
    }
}



Measured memory_bytes: 26116
n = int(input())
a_n = list(map(int,input().split()))

even = []
for num in a_n:
	if num%2==0:
		even.append(num)	#　偶数のみリストeven

ans = True
for num in even:
	if num%3!=0 and num%5!=0:
		ans = False
		break

if ans: print('APPROVED')
else: print('DENIED')


Measured memory_bytes: 3060
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
s = sum(v*(v-1)//2 for v in c.values())

for a in A:
    x = c[a]
    ans = s-x*(x-1)//2+(x-1)*(x-2)//2
    print(ans)


Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int c[6];
    for (int i = 0; i < 6; i++) {
        cin >> c[i];
    }
    int k[6] = {1, 5, 10, 50, 100, 500};
    int s = 0;
    for (int i = 0; i < 6; i++) {
        s += k[i] * c[i];
    }
    cout << min(1, s / 1000) << "\n";
    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n) , b(n-1);
    for(int i = 0; i < n-1; i++) cin >> b[i];
    a[0] = b[0];
    a[n-1] = b[n-2];
    long sum = 0;
    for(int i = 1; i < n-1; i++){
        a[i] = min(b[i-1], b[i]);
    }
    for(int i = 0; i < n; i++){
        sum += (long) a[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <vector>
#define pb push_back
#define ms(a) memset(a,0,sizeof(a))
#define ll long long
#define ull unsigned ll
using namespace std;
#define MAXN 60

ll data[MAXN];
int n;

ll maxnum , maxpos;
void getmax(){
	maxnum = -1;
	for( int i = 1 ; i <= n ; i++ )
		if( data[i] > maxnum ){
			maxnum = data[i];
			maxpos = i;
		}
}

int main(){
	//freopen("E.txt","r",stdin);
	
	scanf("%d",&n);
	for( int i = 1 ; i <= n ; i++ )
		scanf("%lld",&data[i]);
	
	ull ans = 0;
	getmax();
	while( maxnum >= n ){
		ull huan = (maxnum-(n-1)) % n;
		ull dec = (maxnum-(n-1)) / n;
		//cout << "[] " << huan << " " << dec << endl;
		if( huan ){
			dec++;
		}
		ans += dec;
		for( int i = 1 ; i <= n ; i++ ){
			if( i == maxpos )
				data[i] -= dec*n;
			else
				data[i] += dec;
		}
		//for( int i = 1 ; i <= n ; i++ )
		//	cout << data[i] << " ";
		//cout << endl;
		//for( ll i = 1 ; i <= 100000000;i++);
		getmax();
	}
	printf("%lld\n",ans);
	return 0;
};

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
m = 1000
b = []
s = []
flag = True
count = 0
while count < n - 1:
    if flag == True:
        if a[count] >= a[count + 1]:
            count += 1
        else:
            b.append(a[count])
            flag = False
    else:
        if a[count] <= a[count + 1]:
            count += 1
        else:
            s.append(a[count])
            flag = True
if len(b) > len(s):
    s.append(a[-1])
k = 0
for i in range(len(b)):
    k += m // b[i]
    m %= b[i]
    m += s[i] * k
    k = 0
print(m)

Measured memory_bytes: 9224
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main(){
 
    int n, k;
    cin >> n >> k;
 
    int a;
    vector<int> tmp(n);
 
    for(int i=0; i<n; i++){
        cin >> a;
        tmp[a]++;
    }
 
    sort(tmp.begin(), tmp.end(), greater<int>());
 
    int ans = n;
 
    for(int i = 0; i<k; i++)
        ans -= tmp[i];
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long l,r;
	cin>>l>>r;
	if ((r-l)==1) {
		cout<<l*r%2019;
		return 0;
	}
	if ((r%2019-l%2019)!=(r-l)) {
		cout<<0;
		return 0;
	}
	int minn=99999999;
	for (int i=l;i<r;i++)
		for (int j=i+1;j<=r;j++) {
			int s=((i%2019)*(j%2019))%2019;
			minn=min(minn,s);
		}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 08 - 12 - 19  |
// KGP MIRROR'19 |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		string s;
		cin >> s;
		int ans = 0;
		for(int i = 0;i < s.size()/2;i++)
			if(s[i] == s[s.size() - 1 - i]);
			else
			ans++;
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int W = stdIn.nextInt();
		int H = stdIn.nextInt();
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int r = stdIn.nextInt();
		int[] dx ={-1,0,1,0};
		int[] dy ={0,-1,0,1};
		int count = 0;
		
		for(int i=0;i<4;i++)
		{
			if(0<=x+dx[i]*r && x+dx[i]*r<=W && 0<=y+dy[i]*r && y+dy[i]*r<=H)
			{
				count++;
			}
		}
		
		if(count==4)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 17320
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c$|Gw%Wi`(5WFMt58Fc(+?WWe9x7D&BPj>l7_e##a$H62*LRHxk5uYj%<hb5XV)}#=s_zkP8VmDX+fxd9IS(0_7~~msPP2x?YhC7MrN7TQZJ;@GSkYLG^^BVSnyUl(J@PrsEljkNYt_c{5(HrJ}MaFD0E6j3TaLu0PqAC^&^KSK{6rhMU*xP0W-8p7jXm_3&bf1C?N~wYp1k?d?xwe2+ocYvX)hY$Q!)87Qn4!pDW_k1X{^6I3g!SP5`ZRU)F%w_|lTq(t5kV_Wn?RJhKX0WX0_!3(!<AZ+Cr0b`5-G)5B2cDKP3MRTLcc4z9{|yMD&I_FD>RzfYUNf<m?V?UJ5sHpEslVb3Y#WWT_FU>uaeLkWDNxLv?I9=y5(eK^!*f6Lwt|6BGh+`c@?AInMq9^q9`Uj`3z8?ru6I-ZrcCyMFGr!<bjKbssL>ko6lRpX?;6zb1Q")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

vector<vector<int>> GetAdjacencyList(int n, int m)
{
	vector<vector<int>> adjacencyList(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adjacencyList[a].push_back(b);
		adjacencyList[b].push_back(a);
	}

	for (int i = 0; i < n; i++) {
		sort(adjacencyList[i].begin(), adjacencyList[i].end());
		adjacencyList[i].erase(unique(adjacencyList[i].begin(), adjacencyList[i].end()), adjacencyList[i].end());
	}
	return adjacencyList;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<vector<int>> adjacencyList = GetAdjacencyList(n, m);

	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool flag = true;
		int len = adjacencyList[i].size();
		for (int j = 0; j < len; j++) {
			if (h[i] <= h[adjacencyList[i][j]]) {
				flag = false;
				break;
			}
		}
		if (flag) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8784
#include<iostream>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a>b && a>c && a==b+c){
    cout<<"Yes"<<endl;
   }
   else if(b>a && b>c && b==a+c){
    cout<<"Yes"<<endl;
   }
   else if(c>a && c>b && c==a+b){
    cout<<"Yes"<<endl;
   }
   else
   cout<<"No"<<endl;


    return 0;
}



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

using namespace std;
using llong = long long;

llong h[100000];
llong N,A,B,dif;

bool iscompleted(llong m){
  llong center_cnt = 0;
  for(llong i=0;i<N;++i){
    llong res = h[i]-B*m;
    if(res>0){
      llong cnt = (res+(dif-1))/dif;
      center_cnt += cnt;
    }
  }
  return center_cnt<=m;
}

int main(){
  cin >> N >> A >> B;
  dif = A-B;

  llong maxh = 0;
  for(llong i=0;i<N;++i){
    cin >> h[i];
    if(maxh<h[i]) maxh = h[i];
  }

  sort(h,h+N);

  llong ml = 0 , mr = (maxh+(B-1))/B+1;
  llong m;

  while(ml+1<mr){
    m = (ml+mr)/2;
  
    bool b = iscompleted(m);
    if(b){
      mr = m;
    }else{
      ml = m;
    }
  }
  
  cout << mr << endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  
  vector<string> st;
  rep(i,0,n){
    string s;
    cin>>s;
    st.push_back(s);
  }
  
  sort(st.begin(),st.end());
  
  int cnt=0;
  int max=0;
  vector <string> ans[200020];
  rep(i,0,n-1){    
    if(st[i]==st[i+1]){cnt++;}
    if(max<cnt){max=cnt;}
    if(st[i]!=st[i+1]){ans[cnt].push_back(st[i]);cnt=0;}
    if(i==n-2&&max<=cnt){ans[cnt].push_back(st[i+1]);cnt=0;}
  }
  
  int len;
  len = ans[max].size();
    
  rep(i,0,len){cout<<ans[max][i]<<endl;}

  return 0;

}


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

int main(){
   ll n;cin>>n;
   if(n%2){
       cout<<0;
       return 0;
   } 
    ll res = 0;
    ll t = 10;
    while(n/t){
        res+=(n/t);
        t*=5;
    } 
    cout<<res;

}


Measured memory_bytes: 256
def main():
    import sys
    readline = sys.stdin.buffer.readline

    n = int(readline())
    a = int(n**(1/2)//1)
    for i in range(a, 0, -1):
        b, m = divmod(n, i)
        if m == 0:
            print(i+b-2)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 9456
#include <iostream>

using namespace std;

int main(){

	int A, B;
	
	cin >> A >> B;
	
	if(A%3 == 0 or B%3 == 0 or (A+B)%3 == 0){
		cout << "Possible";
	}else{
		cout << "Impossible";
	}
	return 0;
}

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


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

	//typedef tree<
			//int,
			//null_type,
			//less<int>,
			//rb_tree_tag,
			//tree_order_statistics_node_update>
	//ordered_set;
	

//#define REP(i,m) for(int i=0;i<(m);++i)
//struct dsu{
	//static const int MAXN=105;
	//int par[MAXN];
	//int size[MAXN];
	//void init(){
		//memset(par,-1,sizeof(par));
		//REP(i,MAXN) size[i]=1;
	//}
	//int root(int a){
		//if(par[a]==-1) return a;
		//return par[a]=root(par[a]);
	//}
	//void unite(int a,int b){
		//a=root(a);b=root(b);
		//if(a==b) return;
		//if(size[a]<size[b]) swap(a,b);
 
		//par[b]=a;
		//size[a]+=size[b];
	//}
	//bool same(int a,int b){
		//return root(a)==root(b);
	//}
//};	

#define ll long long 

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	ll n;cin>>n;
	ll rem= ceil((1.0*n)/1000);
	rem =  rem*1000-n;
	cout<<rem<<endl;
	return 0;
	
}


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


int main() {
    int n,q;
    string s;
    cin>>n>>q>>s;
    vector<int>a(n,0);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')a[i+1]=a[i]+1;
        else a[i+1]=a[i];
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
// https://atcoder.jp/contests/arc069/tasks/arc069_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define int long long

int N;
string s;

int mod(int n) {
    return (n+N)%N;
}

char other(char c) {
    if(c == 'S') {
        return 'W';
    } else {
        return 'S';
    }
}

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

    cin >> N >> s;

    for(string x: vector<string>({"SS", "WW", "WS", "SW"})) {
        char ans[N];
        for(int i = 0; i < N; i++) {
            ans[i] = '?';
        }

        for(int i = 0; i <= 1; i++) {
            ans[i] = x[i];
        }

        for(int i = 2; i < N; i++) {
            if(s[i-1] == 'o') {
                if(ans[i-1] == 'S') {
                    ans[i] = ans[i-2];                    
                } else if(ans[i-1] == 'W') {
                    ans[i] = other(ans[i-2]);
                }
            } else if(s[i-1] == 'x') {
                if(ans[i-1] == 'S') {
                    ans[i] = other(ans[i-2]);
                } else if(ans[i-1] == 'W') {
                    ans[i] = ans[i-2];
                }
            }
        }

        // watch(ans)
        bool ok = true;
        for(int i = 0; i < N; i++) {
            int l = mod(i-1), r = mod(i+1);
            assert(l < N);
            assert(r < N);

            if(s[i] == 'o') {
                if(ans[i] == 'S') {
                    ok &= (ans[l] == ans[r]);
                } else {
                    ok &= (ans[l] != ans[r]);
                }
            } else if(s[i]=='x') {
                if(ans[i] == 'S') {
                    ok &= (ans[l] != ans[r]);
                } else {
                    ok &= (ans[l] == ans[r]);
                }
            }

            // if(!ok) {
            //     cerr << "failed on " << i << endl;
            //     break;
            // }
        }

        if(ok) {
            // cout << ans << endl;
            for(int i = 0; i < N; i++) {
                cout << ans[i];
            }
            cout << endl;
            exit(0);
            // cerr << "hiiii" << endl;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3832
f=lambda:[*map(int,input().split())]
h,w=f()
g=[f() for _ in range(h)]
tx=ty=0
a=[]
for y in range(h):
  for x in range(w):
    if y%2:
      if tx: nx,ny=tx-1,ty
      else: nx,ny=tx,ty+1
    else:
      if tx<w-1: nx,ny=tx+1,ty
      else: nx,ny=tx,ty+1
    if ny==h: break
    if g[ty][tx]%2:
      g[ty][tx]-=1
      g[ny][nx]+=1
      a+=[[ty+1,tx+1,ny+1,nx+1]]
    ty,tx=ny,nx
  if ny==h: break
print(len(a))
for l in a: print(*l)

Measured memory_bytes: 32516
#include <bits/stdc++.h>
#define int long long int
using namespace std;

const int INF = 1e18L + 5;

signed main() {
	int n, w;
	
	cin>>n>>w;

	vector<int> v(n), wt(n);

	int lim_v = 0;
	for(int i=0; i<n; i++) {
		cin>>wt[i]>>v[i];
		lim_v += v[i];
	}

	vector<int> dp(lim_v+1,INF);
	// dp[i] -> min. wt required to reach value of exactly i
	dp[0] = 0;

	for(int i=0;i<n;i++) {
		for(int j=lim_v-v[i]; j>=0; j--) {
			dp[j+v[i]] = min(dp[j+v[i]], dp[j]+wt[i]);
		}
	}

	int ans=0;

	for(int i=0;i<=lim_v;i++) {
		if(dp[i]<=w) {
			ans = max(ans,i);
		}
	}

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

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

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

    vector< pair<int, int> > G[N];
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++){
            int x, y;
            cin >> x >> y; x--;
            G[i].emplace_back(x, y);
        }
    }

    int ans = 0;

    for(int i=0; i<(1<<N); i++){
        int temp = 0;
        bool ok = true;
        for(int j=0; j<N; j++){
            
            if((i>>j & 1) == 1){
                temp++;
                
                
                for(auto g : G[j]){
                    if(g.second != ((i>>g.first) & 1)){
                        ok = false;
                        break;
                    } 

                }
                
            
            }
            
        }
        if(ok) ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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


ll x[101];
int main() {
	int N;
	cin >> N;
	REP(i, N) {
		cin >> x[i];
	}
	ll ans = 0;
	REP(i, N) {
		FOR(j, i + 1, N) {
			ans = max(ans, abs(x[i] - x[j]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
while 1:
    a, op, b = input().split()
    a = int( a )
    b = int( b )
    if op == "?":
        break
    elif op == "+":
        print( int( a + b ) )
    elif op == "-":
        print( int( a - b ) )
    elif op == "*":
        print( int( a * b ) )
    elif op == "/":
        print( int( a / b ) )



Measured memory_bytes: 5596
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Q = sc.nextInt();
    int[] T = new int[Q];
    int[] F = new int[Q];
    char[] C = new char[Q];
    for (int i = 0; i < Q; i++) {
      T[i] = sc.nextInt();
      if (T[i] == 2) {
        F[i] = sc.nextInt();
        C[i] = sc.next().charAt(0);
      }
    }
    sc.close();

    char[] pre = new char[Q];
    char[] suf = new char[Q];
    int preB = Q - 1;
    int sufE = 0;

    boolean rev = false;
    for (int i = 0; i < Q; i++) {
      if (T[i] == 1) {
        rev = !rev;
      } else {
        if (rev ^ F[i] == 1) {
          pre[preB--] = C[i];
        } else {
          suf[sufE++] = C[i];
        }
      }
    }

    StringBuilder ans = new StringBuilder()
        .append(pre, preB + 1, pre.length - (preB + 1))
        .append(S)
        .append(suf, 0, sufE);
    if (rev) ans.reverse();
    System.out.println(ans);
  }
}


Measured memory_bytes: 148044