akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
    int n,m,X,Y,x[100],y[100],i,tmp;
    scanf("%d%d%d%d",&n,&m,&X,&Y);
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        if(x[0]<x[i]){
            tmp=x[0]; x[0]=x[i]; x[i]=tmp;
        }
    for(i=0;i<m;i++)
        scanf("%d",&y[i]);
    for(i=0;i<m;i++)
        if(y[0]>y[i]){
            tmp=y[0]; y[0]=y[i]; y[i]=tmp;
        }
    while(Y>X){
        if((Y>x[0])&&(Y<=y[0]))
            break;
        Y--;
    }
    if(X==Y)
        printf("War\n");
    else 
        printf("No War");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 100005
#define MOD 1000000007

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    string a;
    cin >> a;
    int n=a.size();
    for(int i=0;i<n-1;i++)
    {
    	if(a[i]==a[i+1])
    	{
    		cout << i+1 << " " << i+2 << endl;
    		return 0;
    	}
    }
    for(int i=0;i<n-2;i++)
    {
    	if(a[i]==a[i+2])
    	{
    		cout << i+1 << " " << i+3 << endl;
    		return 0;
    	}
    }
    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ')
                                    .Select(val => int.Parse(val))
                                    .ToArray();
        int q = Partition(ref A, 0, A.Length - 1);
        //Console.WriteLine(string.Join(" ", A));
        for (int i = 0; i < n; i++)
        {
            if(i != 0) Console.Write(" ");
            if(i == q) Console.Write("[");
            Console.Write(A[i]);
            if(i == q) Console.Write("]");
        }
        Console.WriteLine();
    }

    static int Partition(ref int[] A, int p, int r){
        int x = A[r];
        int i = p - 1;
        for (int j = p; j < r; j++)
        {
            if(A[j] <= x){
                i++;
                Swap(ref A, i, j);
            }
        }
        Swap(ref A, i + 1, r);
        return i + 1;
    }

    static void Swap(ref int[] A, int i, int j){
        try{
            int tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
        catch(IndexOutOfRangeException ex){
            Console.Error.WriteLine(ex.Message);
        }
    }
}

Measured memory_bytes: 19108
N = int(input())

A = list(map(int,input().split()))
count = 0

for i in range(N):
    if A[i] < 0:
        count += 1
    A[i] = abs(A[i])
if count%2==0:
    print(sum(A))
else:
    print(sum(A)-min(A)*2)

Measured memory_bytes: 85432
/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1073741824;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////
set<int> adj[200005];
bool vis[200005];
int cnt=0;
void solve(int s){
    vis[s]=1;
    cnt++;
    for(auto i:adj[s]){
        if(vis[i])continue;
        solve(i);
    }
}
int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        memset(vis,0,sizeof(vis));
        int n,m;
        cin>>n>>m;
        rep(i,m){
            int x,y;
            cin>>x>>y;
            adj[x].insert(y);
            adj[y].insert(x);
        }
        int ans=0;
        for1(i,n){
            if(!vis[i]){
                vis[i]=1;
                solve(i);
                ans=max(ans,cnt);
                cnt=0;
            }
        }
        cout<<ans;
    }
    return 0;
}

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

int main() {
  
  int h, w, n;
  cin >> h >> w >> n;
  
  int s;
  
  if (h > w) {
    if (n % h == 0) {
      cout << n / h << endl;
    } else {
      cout << n / h + 1 << endl;
    }
  } else {
    if (n % w== 0) {
      cout << n / w << endl;
    } else {
      cout << n / w + 1 << endl;
    }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

void modulo(LL &n){
    const int MOD = 1000000007;
    if(n >= MOD)n %= MOD;
}

int main(){
    LL N;
    cin >> N;
    vector<int> dp(N+1);
    vector<LL> sum(N+1);
    dp[1] = N;
    sum[1] = dp[1];
    for(int k=2; k<=N; k++){
        LL v = 0;
        // len(?????) is k
        // 1???????...
        v += dp[k-1];
        modulo(v);

        // cdddddd...d(c>1 and d>1)
        v += (N-1) * (N-1);
        modulo(v);

        // c11???... + c111???... + c11...? (c>1)
        // c=2, 3, 4,..., k-2
        if(k-3>=0){
            v += sum[k-3];
            modulo(v);
        }

        // c111...1111 (c>1)
        // c=N, N-1,..., k-1
        v += N - max(k-1, 2) + 1;
        modulo(v);

        // update
        dp[k] = v;
        sum[k] = sum[k-1] + dp[k];
        modulo(sum[k]);
    }
    //REP(i, N)cerr << dp[i] << endl;
    cout << dp[N] << endl;

    return 0;
}


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

int C[2000001];
unsigned short A[2000001], B[2000001];

int main() {
  
  int n; cin >> n;
  
  //初期化
  for ( int i = 0; i <= 10000; i++ ) {
    C[i] = 0;
  }

  //カウント
  for ( int i = 1; i <= n; i++ ) {
    cin >> A[i];
    C[A[i]]++;
  }

  //累積和を求める
  for ( int i = 1; i <= 10000; i++ ) {
    C[i] = C[i] + C[i-1];
  }

  //後ろから要素をコピー
  for ( int j = n; j >= 1; j-- ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }


  int i;
  for ( i = 1; i < n; i++ ) {
    cout << B[i] << " ";
  }
  cout << B[i] << endl;
  return 0;
}

Measured memory_bytes: 9348
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	vector<int> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end());
	//cout<<a[0]<<endl;
	int x=a[2]-a[0],y=a[2]-a[1];
	//cout<<x<<endl;
	//cout<<y<<endl;
	if((x+y)%2==0){
		cout<<(x+y)/2<<endl;
	}else{
		cout<<(x+y+3)/2<<endl;
	}
}


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

int main() {
  int N;
  cin >> N;
  string s;
  int p;
  vector<tuple<string, int, int>> guide(N);
  for (int i = 0; i < N; i++) {
    cin >> s >> p;
    guide.at(i) = make_tuple(s, -p, i + 1);
  }
  
  int ans;
  sort(guide.begin(), guide.end());
  for (auto e : guide) {
    tie(ignore, ignore, ans) = e;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long s = 0, i, n,a[200000];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (i = 1; i < n; i++)
	{
		if (a[i] < a[i - 1])
		{
			s += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << s;
}

Measured memory_bytes: 5168
s = gets.chomp.split('')
n = s.length

cnt1 = {'0'=> 0, '1'=> 0}
cnt2 = {'0'=> 0, '1'=> 0}
o = true
s.each_with_index do |c, i|
  if o
    cnt1[c] += 1
  else
    cnt2[c] += 1
  end
  o = !o
end

puts [n - (cnt1['0'] + cnt2['1']), n - (cnt1['1'] + cnt2['0'])].min


Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int H1, M1, H2, M2, K;

int main() {
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int wake = (H2 - H1) * 60 + (M2  - M1);

    cout << wake - K << endl;
    
    return 0; 
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int h, w;
    int ans=0;
    char s[109][109];
    int a[109][109]={};
    int x=0;
    int y=0;
    
    cin >> h >> w;
    
    for(int i=1; i<=h; i++){
        
        for(int j=1; j<=w; j++){
            
            cin >> s[i][j];
            
        }
        
    }
    
    if(s[1][1]=='#'){
        
        a[1][1] = 1;
        
    } else {
        
        a[1][1] = 0;
        
    }
    
    for(int i=2; i<=h; i++){
        
        if(s[i-1][1]=='.'&&s[i][1]=='#'){
            
            a[i][1] = a[i-1][1] + 1;
            
        } else {
            
            a[i][1] = a[i-1][1];
            
        }
        
    }
    
    for(int j=2; j<=w; j++){
        
        if(s[1][j-1]=='.'&&s[1][j]=='#'){
            
            a[1][j] = a[1][j-1] + 1;
            
        } else {
            
            a[1][j] = a[1][j-1];
            
        }
        
    }
    
    for(int i=2; i<=h; i++){
        
        for(int j=2; j<=w; j++){
            
            if(s[i-1][j]=='.'&&s[i][j]=='#'){
                
                x = a[i-1][j] + 1;
                
            } else {
                
                x = a[i-1][j];
                
            }
            
            if(s[i][j-1]=='.'&&s[i][j]=='#'){
                
                y = a[i][j-1] + 1;
                
            } else {
                
                y = a[i][j-1];
                
            }
            
            a[i][j] = min(x, y);
            
        }
        
    }
    
    /*
    
    for(int i=1; i<=h; i++){
        
        if(i<=1){
            
            if(s[1][1]=='#'){
                
                a[1][1] = 1;
                
            } else {
                
                a[1][1] = 0;
                
            }
            
        } else {
            
            if(s[i-1][1]=='.'&&s[i][1]=='#'){
                
                a[i][1] = a[i-1][1] + 1;
                
            } else {
                
                a[i][1] = a[i-1][1];
                
            }
            
        }
        
        for(int j=2; j<=w; j++){
            
            if(s[i][j-1]=='.'&&s[i][j]=='#'){
                
                a[i][j] = a[i][j-1] + 1;
                
            } else {
                
                a[i][j] = a[i][j-1];
                
            }
            
        }
        
    }
    
    */
    
    ans = a[h][w];
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef long long ll;
typedef long double ld;

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(int i = x-1 ; i >= 0 ; i --)
#define rrep1(i,x) for(int i = x ; i > 0 ; i --)
#define fr first
#define sc second
#define pb push_back

const int INF = 1000000000;

int cnt_bit(int n){
	int ret = 0;
	while(n > 0){
		n -= n&-n;
		ret ++;
	}
	return ret;
}

int solver(int s,int t){
	if(s == t)return 0;
	int d = s&-s;
	while(s+d > t)d >>= 1;
	return solver(s+d,t)+1;
}

int main(){
	int n;
	scanf("%d",&n);
	rep(pppp,n){
		int s,d;
		scanf("%d%d",&s,&d);
		if(s <= 0 && d >= 0)printf("%d\n",cnt_bit(-s)+cnt_bit(d));
		else if(s <= 0 && d < 0)printf("%d\n",solver(-d,-s));
		else if(s > 0)printf("%d\n",solver(s,d));
	}
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int X=x2-x1,Y=y2-y1;

    cout<<x2-Y<<" "<<y2+X<<" "
       <<x1-Y<<" "<<y1+X<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
 
using namespace std;
 
constexpr int_least64_t dif(int_least64_t a, int_least64_t b)
{
	return a > b ? a - b : b - a;
}
 
int main()
{
	int_least64_t n, m;
	cin >> n >> m;
 
	m /= 2;
	int_least64_t d{ dif(n, m) };
	if(n < m ) {
		cout << n + d / 2 << endl;
	}
	else {
		cout << m << endl;
	}
}

Measured memory_bytes: 256
n,a,b,c,d=map(int,input().split());s=input()
if c<=d:
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[max(0,b-2):d+1]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")


Measured memory_bytes: 3572
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

typedef complex<double> P;

bool comp_x(const P &a, const P &b) {
    return a.real() < b.real();
}

bool comp_y(const P &a, const P &b) {
    return a.imag() < b.imag();
}

double getClosePair(vector<P> &a, int l, int r) {
    if (r - l <= 1) return 1e20;
    int mid = (l + r) / 2;
    double X = a[mid].real();
    double d = min(getClosePair(a, l, mid), getClosePair(a, mid, r));
    inplace_merge(a.begin() + l, a.begin() + mid, a.begin() + r, comp_y);

    vector<P> b;
    for (int i = l; i < r; i++) {
        if (abs(a[i].real() - X) >= d) continue;
        for (int j = b.size() - 1; j >= 0; j--) {
            if (abs((a[i] - b[j]).imag()) >= d) break;
            d = min(d, abs(a[i] - b[j]));
        }
        b.push_back(a[i]);
    }
    return d;
}

int main() {

    int N;
    cin >> N;

    vector<P> p(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    sort(p.begin(), p.end(), comp_x);

    double ans = getClosePair(p, 0, N);
    cout << fixed << setprecision(20) << ans << endl;

}














































Measured memory_bytes: 7904
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 1e2+20;
const ll bits = 30;
const ll mod = 1e9+7;


int main(){

string s;
cin>>s;

ll count = 0;

for(int i=0;i<(s.size())/2;i++){
    if(s[i]!=s[s.size()-1-i]) count++;
}

cout<<count<<"\n";


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }

struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




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

  bool dp[110][10010];
  int s[N];
  rep(i,N){
      cin >> s[i];
  }

  Fill(dp,false);
  dp[0][0]= true;
  
  //作れる得点を作っていく
  rep(i,N){
      for(int j =0; j<=10010;j++){
          if(dp[i][j]){
             dp[i+1][j+s[i]] =true;

             dp[i+1][j]=true;//得点を加えない
          }
      }
  }

  int ans=0;
  rep(j,10010){
      //作った特典の中で10で割り切れる奴を探していく
      if(dp[N][j]&& j%10){
          chmax(ans,j);
      }
  }

  fin(ans);
}

Measured memory_bytes: 1280
A,B,C = map(int,input().split())
D = []
D.append(A)
D.append(B)
D.append(C)
D = sorted(D,reverse=True)
E = max(int(str(D[0])+str(D[1]))+D[2],int(str(D[1])+str(D[2]))+D[0])
print(E)

Measured memory_bytes: 3060
($l,$r)=glob<>;
$d=$r-$l;
$l%=2019;
$r%=2019;
$r=$r<=$l?$r+2019:$r;
$r=$d>=2019?r+2019:$r;
$min=2019;
for$i($l..$r-1){
    for$j($i+1..$r){
        $min=$min<($t=$i*$j%2019)?$min:$t;
    }
}
print $min

Measured memory_bytes: 768
'use strict';
function main(input) {
    const args = input.split(' ');
    const n = parseInt(args[0], 10);
    const x = parseInt(args[1], 10);
    const y = parseInt(args[2], 10);
    let d_obj = {};
    for (let i = 1; i < n; i++) {
        d_obj[i] = 0;
    }
    
    for (let i = 1; i < n; i++) {
        for (let j = i + 1; j < n + 1; j++) {
            if (j <= x || y <= i) {
                d_obj[j - i] += 1;
            } else if (i <= x && j <= y) {
                d_obj[Math.min(j - i, x - i + y - j + 1)] += 1;
            } else if (i <= x && j > y) {
                d_obj[x - i + j - y + 1] += 1;
            } else if (x < i < y && j < y) {
                d_obj[Math.min(j - i, i - x + y - j + 1)] += 1;
            } else if (x < i < y && j >= y) {
                d_obj[Math.min(j - i, i - x + j - y + 1)] += 1;
            }
        }
    }

    for (let i = 1; i < n; i++) {
        console.log(d_obj[i]);
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include<stdio.h>

int v[22];

int main()
{
    int n;
    scanf("%d",&n);

    int ans=0,i;

    for(i=0;i<n;i++){
        //int v;
        scanf("%d",&v[i]);
    }

    for( i=0;i<n;i++){
        int c;
        scanf("%d",&c);

        if(v[i]>c) ans+=(v[i]-c);
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################
        // 1行 文字 1文字 ---------------------------------------------------------------------------
        String b = scanner.nextLine();

        // ##### メイン処理 #######################################################################
        char[] words = b.toCharArray();
        if (words[2] == words[3] && words[4] == words[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0 || vis[x] > (num+1))
      dfs2(x, curr, num+1);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code
int one[N];

int main()
{
  int n, m;
  cin>>n>>m;
  rep(i, 0, m)
  {
    int a, b;
    cin>>a>>b;
    if(a == 1) one[b]++;
    if(b == 1) one[a]++;
    if(a == n) one[b]++;
    if(b == n) one[a]++;
    if(one[a] == 2 || one[b] == 2) {puts("POSSIBLE"); return 0;}
  }
  puts("IMPOSSIBLE");
}


Measured memory_bytes: 16768
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
ans=10**10
if h>=3:
    if h%3==0:
        ans=0
    else:
        ans=min(w,ans)
if w>=3:
    if w%3==0:
        ans=0
    else:
        ans=min(h,ans)
for i in range(1,w):
    a=h*i
    if h%2==0:
        b=(w-i)*h//2
        c=b
    else:
        b=(w-i)*((h+1)//2)
        c=(w-i)*h-b
    temp=max(a,b,c)-min(a,b,c)
    ans=min(ans,temp)
for i in range(1,h):
    a=w*i
    if w%2==0:
        b=(h-i)*w//2
        c=b
    else:
        b=(h-i)*((w+1)//2)
        c=(h-i)*h-b
    temp=max(a,b,c)-min(a,b,c)
    ans=min(ans,temp)
print(ans)










Measured memory_bytes: 40816
#include<stdio.h>

int main(){

    int a,b,c,x;
    int cnt = 0;

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

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if((50 * k + 100 * j + 500 * i) == x){
                    cnt++;
                }
            }
        }
    }

    printf("%d\n",cnt);

    return 0;
}


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

int w, h, ans, tmp;
vector<vector<int>> c(60, vector<int>(60,0));

void ume(int x, int y){
	if(c[x][y]==0) return;
	c[x][y]=0;
	ume(x-1,y);
	ume(x+1,y);
	ume(x-1,y-1);
	ume(x,y-1);
	ume(x+1,y-1);
	ume(x-1,y+1);
	ume(x,y+1);
	ume(x+1,y+1);
	return;
}

bool hantei(int x, int y){
	if(c[x][y]==1){
		ume(x,y);
		return 1;
	}
	else return 0;
}

int main(){
	while(cin >> w >> h){
		if(w == 0&&h==0) break;
		ans = 0;
		for(int i = 1;i<=h;i++){
			for(int j = 1;j<=w;j++){
				cin >> c[i][j];
			}
		}
		for(int i = 1;i<=h;i++){
			for(int j = 1;j<=w;j++){
				ans+=hantei(i,j);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint n, m, k;
    cin >> n >> m >> k;

    vector<llint> asum(n+1);
    vector<llint> bsum(m+1);
    llint atmp, btmp;
    for(int in=0;in<n;in++) {
        cin >> atmp;
        asum.at(in+1) = asum.at(in) + atmp;
    }
    for(int im=0;im<m;im++) {
        cin >> btmp;
        bsum.at(im+1) = bsum.at(im) + btmp;
    }

    llint ans = 0, anstmp, bmax = m;
    for(llint in=0;in<=n;in++) {
        for(llint ib=bmax;ib>=0;ib--) {
            if(asum.at(in)+bsum.at(ib)<=k) {
                bmax = ib;
                anstmp = in + ib;
                if(ans<anstmp) ans = anstmp;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6372
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - 1 - i])
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
while True:
    n=int(input())
    if n==0:
        break
    else:
        S=input().split( )
        
        sum=0
        for i in range(n):
            sum = sum+int(S[i])
        ave= sum/n
        val_sum=0
        for i in range(n):
            val_sum = val_sum+(int(S[i])-ave)**2
        val = val_sum/n
        devi= math.sqrt(val)
        print(devi)


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])
    a = [int(e) for e in lines[1].split(' ')]

    return (n, a)


def solve(n, a):
    
    b = set()
    for e in a:
        b.add(e)

    result = 'NO'
    if len(a) == len(b):
        result = 'YES'

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 28504
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

int N,L[10],A,B,C;

int dfs(int k,int a,int b,int c){
  if(k==N){
    if(a==0 || b==0 || c==0){
      return MOD;
    }
    return abs(a-A)+abs(b-B)+abs(c-C);
  }
  int ans=MOD;
  ans = min(ans,dfs(k+1,a+L[k],b,c)+(a>0 ? 10 : 0));
  ans = min(ans,dfs(k+1,a,b+L[k],c)+(b>0 ? 10 : 0));
  ans = min(ans,dfs(k+1,a,b,c+L[k])+(c>0 ? 10 : 0));
  ans = min(ans,dfs(k+1,a,b,c));
  return ans;
}

int main(){
  cin >> N >> A >> B >> C;
  rep(i,N){
    cin >> L[i];
  }
  cout << dfs(0,0,0,0) << endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int Maxn = 100010;
int a[Maxn];

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    for (int i = 1; i < n; ++i) {
        a[i] = a[i - 1];
        if (s[i - 1] == 'A' && s[i] == 'C') a[i]++;
    }

    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << a[r - 1] - a[l - 1] << endl;
    }
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int n,p,d1,d2,i,m,a;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		m=0;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&p,&d1,&d2);
			if(d1+d2>m){
				a=p;
				m=d1+d2;
			}
		}
		printf("%d %d\n",a,m);
	}
	return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll>v;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        v.push_back(a);
    }
    for(int i=1;i<n;i++)
    {
         sum+=min((v[i]-v[i-1])*a,b);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
double get_e(int n, vector<vector<int>>& adj, vector<double>& e, int block_s, int block_t) {
    fill(e.begin(), e.end(), 0);
    for(int u = n - 1; u >= 1; u--) {
        int denom = adj[u].size();
        for(int v : adj[u]) {
            if(block_s == u and block_t == v) {
                denom--;
            } else {
                e[u] += (1 + e[v]);
            }
        }
        e[u] /= denom;
    }
    return e[1];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n + 1);
    vector<int> s(m), t(m);
    for(int i = 0; i < m; i++) {
        cin >> s[i] >> t[i];
        adj[s[i]].push_back(t[i]);
    }
    vector<double> e(n + 1);
    double ans = get_e(n, adj, e, 0, 0);
    vector<int> max_neighbor(n + 1);
    for(int u = 1; u <= n; u++) {
        for(int v : adj[u]) {
            if(e[max_neighbor[u]] < e[v]) {
                max_neighbor[u] = v;
            }
        }
    }
    for(int i = 0; i < m; i++) {
        if(adj[s[i]].size() > 1 and max_neighbor[s[i]] == t[i]) {
            ans = min(ans, get_e(n, adj, e, s[i], t[i]));
        }
    }
    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    int L;
    while ( cin >> L && L ) {
        int answer = -1;
        int sum = 0;
        for ( int i = 1; i <= 12; ++ i ) {
            int M, N;
            cin >> M >> N;
            sum += M - N;
            if ( sum >= L && answer == -1 ) {
                answer = i;
            }
        }
        if ( answer == -1 ) {
            cout << "NA" << endl;
        } else {
            cout << answer << endl;
        }
    }
    return 0;
}

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

int main(int argc, char** argv){
  string S;
  cin >> S;
  int k0 = 0;
  int k1 = 0;
  for(int cnt0=0; cnt0<S.size(); cnt0++){
    if(S[cnt0] == '0'){
      k0++;
    }else{
      k1++;
    }
  }
  int ret = min(k0,k1);
  ret = ret*2;
  printf("%d", ret);
  return 0; 
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;


int main(){
   int n,m;
   cin>>n>>m;
   long long ans;
   if(n>2 && m>2)ans=(long long)(n-2)*(long long)(m-2);
   else  if(n==1 || m==1)ans=(long long)max(max(n,m)-2,0);
   else ans=0;

   if(n==1 && m==1)ans=1;
   cout<<ans<<endl;

}

   


Measured memory_bytes: 256
card_with_mark = {}
mark = 'S'
4.times do |i|
    case i
    when 1
        mark = 'H'
    when 2
        mark = 'C'
    when 3
        mark = 'D'
    end
    13.times do |j|
        card_with_mark[[mark, j+1]] = true
    end
end
n = gets.chomp.to_i
n.times do
    mark, num = gets.split(" ")
    card_with_mark[[mark, num.to_i]] = false
end
card_with_mark.each do |key, value|
    if value == true
        print key[0], " ", key[1], "\n"
    end
end


Measured memory_bytes: 6872
A = 3.times.map{gets.split.map(&:to_i)}
N = gets.to_i
b = N.times.map{gets.to_i}

c = A.map{|line| line.map{|j| b.count(j) == 0 ? false : true}}

puts c.any?(&:all?) || c.transpose.any?(&:all?) || [c[0][0], c[1][1], c[2][2]].all? ||
    [c[0][2], c[1][1], c[2][0]].all? ? :Yes : :No

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

using namespace std;
using i64 = int64_t;

int main(){
  int N;
  cin >> N;
  vector<i64> a(N+5), b(N+5), c(N+5);
  for(int i=1;i<=N;i++){
    cin >> a[i] >> b[i] >> c[i]; 
  }
  vector<vector<i64>> dp(3, vector<i64>(N+1));
  for(int i=1;i<=N;i++){
    dp[0][i] = max(dp[1][i-1] + a[i], dp[2][i-1] + a[i]);
    dp[1][i] = max(dp[0][i-1] + b[i], dp[2][i-1] + b[i]);
    dp[2][i] = max(dp[0][i-1] + c[i], dp[1][i-1] + c[i]);
  }
  i64 m = 0LL;
  for(int i=0;i<=2;i++)m = max(m, dp[i][N]);
  cout << m << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void)
{
  int i,j,coin;
  i=j=coin=0;
  scanf("%d",&i);
  scanf("%d",&j);
  if(i>j)
  {
    coin=i+i;
    coin--;
  }
  if(i<j)
  {
    coin=j+j;
    coin--;
  }
  if(i==j)
  {
    coin=i+j;
  }
  printf("%d\n",coin);
  return 0;
}

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

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

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

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

    int n, a, b;
    cin >> n >> a >> b;
    a -= b;
    vector<int> h(n);
    for(int i = 0; i < n; ++i)  cin >> h[i];
    int lb = 0, ub = 1e+9;
    while(ub - lb > 1){
        int mid = (lb + ub) >> 1;
        ll c = 0;
        for(int i = 0; i < n; ++i){
            c += max(0LL, (h[i] - (ll)mid * b + a - 1) / a);
        }
        if(c <= mid)    ub = mid;
        else    lb = mid;
    }
    cout << ub << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
  if(x < y) swap(x, y);
  if(y == 0) return x;
  else return gcd(y, x%y);
}
int main(void){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) cin >> A[i];
  int l[N+1], r[N+1];
  // l[i+1]: A[0]~A[i]の最大公約数
  // r[i]: A[i]~A[N-1]の最大公約数
  l[0] = 0;
  r[N] = 0;
  for(int i=0; i<N; i++){
    l[i+1] = gcd(l[i], A[i]);
  }
  for(int i=N; i>=1; i--){
    r[i-1] = gcd(r[i], A[i-1]);
  }
  int ans = 0;
  ans = max(l[N-1], r[1]);
  for(int i=1; i<N-1; i++){
    ans = max(ans, gcd(l[i], r[i+1]));
  }
              
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
#ABC139 E

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [LI() + [-1] for _ in range(n)]
cnt,day = [0]*n,[0]*n
que = deque([i for i in range(n)])
while que:
    u = que.popleft()
    v = a[u][cnt[u]] - 1
    if a[v][cnt[v]] - 1 == u:
        day[u] = max(day[u],day[v]) + 1
        day[v] = day[u]
        cnt[u] += 1
        cnt[v] += 1
        que.append(u)
        que.append(v)
for i in range(n):
    if cnt[i] != n-1:
        print(-1)
        quit()
print(max(day))


Measured memory_bytes: 63448
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
vector<int> v[1000],vv[1000],ans;
bool bo[1000];
int mutu(int x,bool used[1000]){
	int cnt=0,vz;
	f(i,vv[x].size()){
		if(used[vv[x][i]])cnt++;
	}
	if(cnt>1)return -1;
	cnt=0;
	f(i,v[x].size()){
		if(used[v[x][i]]){
			cnt++;
			vz=v[x][i];
		}
	}
	if(cnt==1){
		ans.push_back(x);
		return vz;
	}
	else if(cnt>=2)return -1;
	f(i,v[x].size()){
		used[v[x][i]]=true;
		int z=mutu(v[x][i],used);
		if(z!=-1){
			if(z!=x&&z!=INF){
				ans.push_back(x);
				return z;
			}
			else if(z==x){
				ans.push_back(x);
				return INF;
			}
			else return z;
		}
		used[v[x][i]]=false;
	}
	return -1;
}
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,b){
		int c,d;
		cin>>c>>d;
		c--,d--;
		v[c].push_back(d);
		vv[d].push_back(c);
	}
	f(i,a){
		f(j,a)bo[j]=false;
		bo[i]=true;
		if(mutu(i,bo)!=-1){
			cout<<(int)ans.size()<<endl;
			f(i,ans.size())cout<<ans[i]+1<<endl;
			return 0;
		}
	}
	puts("-1");
}
 


Measured memory_bytes: 384
/*
    Code by CNH_Tourist
    Date Created: 10/6/2019
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*---------------------Define--------------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const ll mod=1e9+7;
int test=1;
const int N=100100;
/*-----------------------------------------------*/

/*---------------SegmentTree Build---------------
void build(int node, int Start, int End)
{
    if(Start == End)
    {
        // Leaf node will have a single element
        tree[node] = A[start];
    }
    else
    {
        int mid = (Start + End) / 2;
        // Recurse on the left child
        build(2*node, Start, mid);
        // Recurse on the right child
        build(2*node+1, mid+1, End);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
------------------------------------------------*/

int n,m;
vector<int> a[100100];
int cnt[100100];
int maxx=0;

int DFS(int i)
{
    if(cnt[i]) return cnt[i];

    for(int j=0;j<a[i].size();j++)
        cnt[i]=max(cnt[i],DFS(a[i][j])+1);
    return cnt[i];
}

int main()
{
    FAST
    //FileInOut
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
    }
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++)
    {
        if(cnt[i]==0)
            DFS(i);
    }
    for(int i=1;i<=n;i++)
    {
        maxx=max(maxx,cnt[i]);
        //cout<<cnt[i]<<" ";
    }
    //cout<<endl;
    cout<<maxx;
}


Measured memory_bytes: 8192
#! /usr/bin/env ruby
# coding: utf-8
while n = gets.to_i
  break if n == 0
  v = gets.split.map{|e| e.to_i }
  raise "assert" unless v.length == n
  count = {}
  count.default = 0
  v.each do |e|
    count[e] += 1
  end
  ans = "NO COLOR"
  count.each do |k, v|
    ans = k if v > n / 2
  end
  puts ans
end

Measured memory_bytes: 105292
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long MOD = 1000000007;
typedef long long ll;

ll n,k,a,b;
string s,t;

int main() {
  cin >> n >> a >> b;
  ll ans=n/(a+b)*a+min(n%(a+b),a);
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Volume1 */
import java.io.*;

class Main
{
  public static final int NUMBER = 10;

  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      int[] array = new int[NUMBER];
      int[] height = new int[3];

      for(int i = 0; i < NUMBER; i++){
        array[i] = Integer.parseInt(br.readLine());
      }
      for(int i = 0; i < 3 ; i++){
        height[i] = array[i];
        int index = i;
        for(int j = i+1; j < NUMBER; j++){
          if(array[index] < array[j]) index = j;
        }
        int tmp = height[i];
        height[i] = array[index];
        array[index] = tmp;
        sb.append(height[i]).append("\n");
      }

      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

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


int main(){

	int n, q;
	cin >> n;
	int S[n+1];
	for(int i=0; i<n; i++){
		cin >> S[i];
	}
	cin >> q;
	int T[q+1];
	for(int j=0; j<q; j++){
		cin >> T[j];
	}

	int cnt=0;
	// ????????????????£?
	for(int j=0; j<q; j++){
		int i=0;
		S[n] = T[j];
		while(S[i] != T[j])
			i++;
		if(i < n)
			cnt++;
	}

	cout << cnt << endl;

	return 0;

}

Measured memory_bytes: 3084
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if ((b*c)>=a)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    int odd = 0, even = 0;
    REP(i, 1, n + 1)
    {
        if (i % 2 == 0)
            odd++;
        else
            even++;
    }
    cout << odd * even << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		List<Integer> x = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			x.add(scanner.nextInt());
		}

		long ans = 0;
		long[][][] dp = new long[n + 1][n + 1][n * a + 1];
		dp[0][0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				for (int k = 0; k <= n * a; k++) {
					if (j - 1 >= 0 && k - x.get(i - 1) >= 0) {
						dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x.get(i - 1)];
					} else {
						dp[i][j][k] = dp[i - 1][j][k];
					}

				}
			}
		}

		for (int j = 1; j <= n; j++) {
			ans += dp[n][j][a * j];

		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 83992
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,k[15]={},s[15][15]={},p[15]={},ans=0,cnt1=0,cnt2=0;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> k[i];
    for(int j=0; j<k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for(int i=0; i<m; i++) {
    cin >> p[i];
  }
  for(int i=0; i<(1<<n); i++) {
    cnt2=0;
    for(int j=0; j<m; j++) {
      cnt1=0;
      for(int l=0; l<k[j]; l++) {
        if(i&(1<<s[j][l]-1)) {
          cnt1++;
        }
      }
      if(cnt1%2==p[j]) {
        cnt2++;
      }
    }
    if(cnt2==m) {
      ans++;
    }
  }
  cout << ans << endl;
}



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

int main(){
  int N,A,B;
  1<=N<=20;
  1<=A<=100;
  1<=B<=2000;
  cin>>N>>A>>B;
  if(N*A>B){
    cout<<B<<endl;
  }
  else if(N*A==B){
    cout<<B<<endl;
  }
  else {
    cout<<N*A<<endl;
  }
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    A,B = map(int,input().split())

    ans = ['Alice','Bob','Draw']

    if A == B:
        res = 2
    elif A == 1:
        res = 0
    elif B == 1:
        res = 1
    elif A > B:
        res = 0
    elif A < B:
        res = 1

    print(ans[res])



main()


Measured memory_bytes: 2940