akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n;
    cin>>n;
    if(n%2==1)
    {
        cout<<n/2+1;
    }
    else
    {
        cout<<n/2;
    }
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}

int main(){
	string st;cin>>st;
	if(st=="SSS"){write(0);}
	else if(st=="RSS"||st=="SRS"||st=="SSR"||st=="RSR"){write(1);}
	else if(st=="RRS"||st=="SRR"){write(2);}
	else{write(3);}
	return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    set<string> st;
    vector<string> s(n);
    rep(i,n) {
        string ss;
        cin >> ss;
        s[i] = ss;
        st.insert(ss);
    }
    if (s.size() != st.size()) {
        cout << "No" << "\n";
        return 0;
    }
    for(int i=1; i<n; ++i) {
            if (s[i-1][s[i-1].size()-1] != s[i][0]) {
                cout << "No" << "\n";
                return 0;
            }
    }
    cout << "Yes" << "\n";

 }



Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

for i in range(1, len(S)-1):
    if (len(S) - i) % 2 > 0:
        continue
    l = (len(S)-i) // 2
    if S[:l] == S[l:2*l]:
        print(len(S)-i)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


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

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}


inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}


using namespace std;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

const int MAXN = (int) 1e5;

int fact[MAXN + 1], invfact[MAXN + 1];

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;

    fact[0] = invfact[0] = 1;
    for(i = 1; i <= MAXN; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
        invfact[i] = lgput(fact[i], MOD - 2);
    }

    cout << n - k + 1 << "\n";

    for(i = 2; i <= k; i++) {
        int ans = 0;
        for(j = 0; j <= n - k; j++) {
            int cur = j + 1;
            mul(cur, (1LL * comb(k - 1, i - 1) * comb(n - k - j - 1, i - 2)) % MOD);
            add(ans, cur);
        }
        cout << ans << "\n";
    }

    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int a,b;
  cin >> a >> b;
  if(a%2==0 || b%2==0)cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)


int w,h;

char dat[1005][1005];


int gs(int y,int x){
	int res=0;
	reg(dy,-1,1){
		reg(dx,-1,1){
			res += (dat[y+dy][x+dx]=='.'?1:0);
		}
	}
	return res;
}

int main(void){
	scanf("%d%d",&h,&w);
	rep(y,h)scanf("%s",dat[y]);

	int ans=0;
	vector<mp> v[2];
	rep(y,h){
		rep(x,w){
			char c = dat[y][x];
			if(c=='.')continue;
			if(gs(y,x)>=(c-'0'))v[0].push_back(mp(y,x));
		}
	}
	
	for(;;){
		bool bd=false;
		
		rep(i,v[0].size()){
			mp pa=v[0][i];
			int y=pa.fir,x=pa.sec;
			if(dat[y][x]=='.')continue;
			dat[y][x]='.';
			bd=true;
			
			reg(dy,-1,1){
				reg(dx,-1,1){
					char c = dat[y+dy][x+dx];
					if(gs(y+dy,x+dx)>=(c-'0'))v[1].push_back(mp(y+dy,x+dx));
				}
			}
		}
		
		swap(v[0],v[1]);
		v[1].clear();
		if(!bd)break;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2292
/**
*   @Author : MeGaCrazy
*   @InitTime : Sun Dec 30 15:35:50 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N];
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
         int c;
         scanf("%d",&c);
         a[c]++;
    }
    int st=((n%2==0)?1:2);
    int ans=1;
    for(int i=st;i<n;i+=2){
    	if(a[i]!=2){
    	  printf("0");
    	  return 0;	
    	}
       ans=(2ll*ans)%(long long)(1e9+7);	
    }
    printf("%d",ans);



}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int L, R;
    cin >> L >> R;
    R = min(R, L+2019);
    int64_t ans = 2019*2019;
    for(int64_t i=L; i<R; i++) {
        for(int64_t j=i+1; j<=R; j++) {
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	a = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

queue<P> q;
int h,w,d[1010][1010];
string s[1010];

bool check(int x, int y){
	return (0<=x && x<h && 0<=y && y<w);
}

int main(void){
	int i,j,ans=-INF;
	P p;
	fill(d[0],d[1010],INF);
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> s[i];
		for(j=0; j<w; ++j){
			if(s[i][j]=='#'){
				d[i][j] = 0;
				q.push(P(i,j));
			}
		}
	}
	while(!q.empty()){
		p = q.front();
		q.pop();
		i = p.first;
		j = p.second;
		if(check(i-1,j) && d[i-1][j]>d[i][j]+1){
			d[i-1][j] = d[i][j] + 1;
			q.push(P(i-1,j));
		}
		if(check(i+1,j) && d[i+1][j]>d[i][j]+1){
			d[i+1][j] = d[i][j] + 1;
			q.push(P(i+1,j));
		}
		if(check(i,j-1) && d[i][j-1]>d[i][j]+1){
			d[i][j-1] = d[i][j] + 1;
			q.push(P(i,j-1));
		}
		if(check(i,j+1) && d[i][j+1]>d[i][j]+1){
			d[i][j+1] = d[i][j] + 1;
			q.push(P(i,j+1));
		}
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			ans = max(ans,d[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define dbg(x) cerr << #x"=" << x << endl;


int main(){
    //freopen("in.txt", "r", stdin);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0]+a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

void st(string s){
    vector<int> v(s.size(),0);
    rep(i,s.size()){
        v[s[i]-'0']++;
    }
    rep(i,10)cout<<v[i]<<endl;
}
signed main(){
    string s; cin >> s;
    int ans=0;
    rep(i,3){
        if(s[i]=='o') ans+=100;
    }
    cout  << 700+ans<< endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    
    static int howmany(int K,int t){
        int count=0;
        while(t<K){
            t=t*2;
            count++;
        }
        return count;
    }
        
     public static void main(String []args){
         
       Scanner sc=new Scanner(System.in);
       int N=sc.nextInt();
       int K=sc.nextInt();
       int i=0;
       double prob=0;
       
       for(int j=1; j<=N; j++){
           double temp=1/(double)N * (double)1/Math.pow(2,howmany(K,j));
           prob=temp+prob;
           
       }
     System.out.println(prob);   
     }
     
}

Measured memory_bytes: 22868
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var N = Console.ReadLine().ToInt32();
        var an = Console.ReadLine().SplittedStringToInt32List();
        var dic = new Dictionary<Typesofnum, int>();
        dic.Add(Typesofnum.Fours, 0);
        dic.Add(Typesofnum.Odds, 0);
        dic.Add(Typesofnum.Twos, 0);
        foreach (var item in an)
        {
            if (item % 4 == 0)
                dic[Typesofnum.Fours]++;
            else if (item % 2 == 0)
                dic[Typesofnum.Twos]++;
            else
                dic[Typesofnum.Odds]++;
        }
        if (dic[Typesofnum.Fours] + 1 < dic[Typesofnum.Odds])
        {
            Console.WriteLine("No");
        }
        else
        {
            var amari = dic[Typesofnum.Fours] - dic[Typesofnum.Odds] + 1;
            if (dic[Typesofnum.Twos] % 2 == 0)
                Console.WriteLine("Yes");
            else
            {
                if (amari != 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                    Console.WriteLine("No");
            }
        }
        Console.ReadLine();
    }

    enum Typesofnum
    {
        Fours,
        Twos,
        Odds
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
}


Measured memory_bytes: 21600
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace cc
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long ans = 0;

            List<long> posList = new List<long>();
            List<long> negList = new List<long>();

            string[] strs = Console.ReadLine().Split(' ');

            for(int i=0;i<N;i++)
            {
                long inVal = long.Parse(strs[i]);

                if (inVal > 0 )
                {
                    posList.Add(inVal);
                }
                else
                {
                    negList.Add(-inVal);
                }
            }

            if (negList.Count % 2 == 0 || negList.Count == 0)
            {
                foreach(long a in negList)
                {
                    ans += a;
                }
                foreach(long a in posList)
                {
                    ans += a;
                }
            }
            else if (posList.Count == 0)
            {
                negList.Sort();

                for (int i = 1; i < negList.Count; i++)
                {
                    ans += negList[i];
                }

                ans -= negList[0];
            }
            else
            {
                negList.Sort();
                posList.Sort();

                if (negList[0] < posList[0])
                {
                    foreach (long a in posList)
                    {
                        ans += a;
                    }
                    for(int i=1;i<negList.Count;i++)
                    {
                        ans += negList[i];
                    }

                    ans -= negList[0];
                }
                else
                {
                    foreach (long a in negList)
                    {
                        ans += a;
                    }
                    for (int i = 1; i < posList.Count; i++)
                    {
                        ans += posList[i];
                    }

                    ans -= posList[0];

                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 32604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int n,c[510],s[510],f[510];
	cin>>n;
	lol(i,n-1)cin>>c[i]>>s[i]>>f[i];
	lol(i,n){
		int now=0;
		for(int j=i;j<n-1;j++){
			int nex=now/f[j]+(now%f[j]>0);
			nex*=f[j];
			if(nex<s[j])nex=s[j];
			now=nex+c[j];
		}
		cout<<now<<endl;
	}
	return 0;
}


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

ll com(ll a,ll b)
{
	ll res = 1;
	for(int i = 1;i<=b;i++)
	{
		res*=a--;
		res/=i;
	}
	return res;
}

int main()
{
	ll n,p;
	cin >> n >> p;
	ll cnt[2] = {};
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		int x;
		cin >> x;
		cnt[x%2]++;
	}
	if(p==1)
	{
		for(ll i = 1;i<=cnt[1];i+=2)
		{
			ans+= com(cnt[1],i);
		}
	}
	else
	{
		for(ll i=0;i<=cnt[1];i+=2)
		{
			ans+= com(cnt[1],i);
		}
	}
	ans*=(1LL<<cnt[0]);
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)

    let ans = 0
    let sp = 0
    let d = A[sp]
    let xor = A[sp]
    let m = 1
    let count = 0
    while (sp < N) {
        m = Math.max(m, sp)
        for (let i = m; i <= N; i++) {
            if (d === xor) {
                count++
                d = d + A[i]
                xor = xor ^ A[i]
                m++
            } else {
                break
            }
        }
        ans += count
        xor = xor ^ A[sp]
        d = d - A[sp]
        sp++
        count--
    }
 
    console.log(ans)

})(input)


Measured memory_bytes: 43688
n = int(input())
w = list(map(int, input().split()))
dif = []
for t in range(n):
    up = 0
    down = 0
    for i in range(t+1):
        down += w[i]
    for i in range(t+1, n):
        up += w[i]
    dif.append(abs(up-down))
print(min(dif))



Measured memory_bytes: 38640
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    int solve(int a[],int dp[],int n,int i){
        if(i==n-1) return 0;
        else if(i==n-2) return abs(a[i]-a[i+1]);
        if(dp[i]!=-1) return dp[i];
        return dp[i]=min(abs(a[i]-a[i+1])+solve(a,dp,n,i+1),abs(a[i]-a[i+2])+solve(a,dp,n,i+2));
    }

    int main(){
                    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int n;
            cin>>n;
            int a[n];
            rep(i,0,n) cin>>a[i];
            int dp[n];
            memset(dp,-1,sizeof(dp));
            cout<<solve(a,dp,n,0);
        } 
        return 0;   
    }       


    // First, solve the problem. Then, write the code. 


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

struct Room {
	vector<int> to;
	int dir;
	int dist;
	Room() :dir(-1), dist(100000000) {}
};

vector<pair<int, int>> FindRoute(vector<Room>& rooms, const vector<pair<int, int>>& candidates, int dist)
{
	vector<pair<int, int>> next;
	for (const auto& ft : candidates) {
		Room& room = rooms[ft.second];
		if (dist < room.dist) {
			room.dir = ft.first;
			room.dist = dist;
			for (const auto& to : room.to)
				next.emplace_back(pair<int, int>(ft.second, to));
		}
	}
	return next;
}

int main()
{
	auto& in = cin;

	int N, M;
	in >> N >> M;
	vector<Room> rooms(N);
	for (int i = 0; i < M; ++i) {
		int A, B;
		in >> A >> B;
		rooms[A - 1].to.emplace_back(B - 1);
		rooms[B - 1].to.emplace_back(A - 1);
	}

	vector<pair<int, int>> candidates = { pair<int,int>(-1, 0) };
	int dist = 0;
	do {
		candidates = FindRoute(rooms, candidates, dist++);
	} while (!candidates.empty());

	for (int i = 1; i < N; ++i) {
		if (rooms[i].dir < 0) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < N; ++i) {
		cout << rooms[i].dir + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 15052
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

int N,M,k[10],s[10][10],p[10];

int main(){
	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];
			s[i][j]--;
		}
	}
	for(int i=0; i<M; i++) cin >> p[i];

	int ans = 0;
	for(int i=0; i<(1<<N); i++){
		bool flg = true;
		for(int j=0; j<M; j++){
			int c = 0;
			for(int l=0; l<k[j]; l++){
				if(((1<<s[j][l])&i) > 0){
					c++;
				}
			}
			if(c%2 != p[j]) flg = false;
		}
		if(flg) ans++;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int S = 0;
		if(A * B >= C * D){
			S = A * B;
		}else if(A * B < C * D){
			S = C * D;
		}
		System.out.print(S);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;

    int lose = 0, win = 0, r = 1, p = 0;
    if (s[0] == 'p') lose++;
    REP(i, 1, s.size()) {
        if (s[i] == 'p') {
            if (p < r) {
                p++;
            } else {
                r++;
                lose++;
            }
        } else {
            if (p < r) {
                p++;
                win++;
            } else {
                r++;
            }
        }
    }
    cout << win - lose << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
ll qpow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
int main() {
    ll h, ans = 0, a = 1, i;
    cin >> h;
    for (i = 0;; ++i) {
        if (qpow(2, i) > h) break;
    }
    cout << qpow(2, i) - 1 << endl;
    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;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll a,b;
	cin>>a>>b;
	REP(i,0,2501){
		if((i*8)/100 == a && (i)/10 == b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}



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

int count_hug(string S){
    int size = S.size();
    int count = 0;
    for(int i = 0; i < size/2; i++){
        if(S.at(i) != S.at(size-i-1)){
            count++;
        }
    }

    return count;
}

int main() {
    string S;
    cin >> S;

    int hug = count_hug(S);

    cout << hug << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>


using namespace std;


int main(){
    int A,B;
    cin >> A >> B;

    int outlet = 1;
    int ans = 0;
    while(outlet < B){
        --outlet;
        outlet += A;
        ++ans;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 100000000000;
int main(){
  while (1){
    long long a, b, d;
    cin >> a >> b >> d;
    if (a == 0 && b == 0 && d == 0){
      break;
    }
    long long x, y, total, sum;
    total = INF;
    sum = INF;
    for (int i = -100000; i <= 100000; i++){
      if ((d - a * i) % b == 0){
        int j = (d - a * i) / b;
        int x2 = abs(i);
        int y2 = abs(j);
        if (total > x2 + y2 || total == x2 + y2 && sum > a * x2 + b * y2){
          x = x2;
          y = y2;
          total = x2 + y2;
          sum = a * x2 + b * y2;
        }
      }
    }
    cout << x << ' ' << y << endl;
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(ALL(v));
    ll m = n/2;
    ll a = v[m-1];
    ll b = v[m];
    ll ans=0;
//    dbg(a)
//    dbg(b)
    if(a!=b){
        ans = b-a;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);                                            
      
      long a = sc.nextLong();
      long b = sc.nextLong();
      
      if(a <= 0 && b >= 0 || a <=0 && b >= 0){
          System.out.println("Zero");
      }else if(a < 0 && b < 0){
          System.out.println(((b-a+1)%2 == 0)?"Positive":"Negative");
      }else if(a > 0 && b > 0){
          System.out.println("Positive");          
      }

      
   }   
        
 }

Measured memory_bytes: 22996
K,A,B  = map(int, input().split())
n = (K-A+1)//2
if B-A < 2:
    print(1+K)
else:
    if (K-A+1)%2 == 0:
        print(A+(B-A)*n)
    else:
        print(A+(B-A)*n+1)

Measured memory_bytes: 38256
/* Volume0-0009 Prime Number */

#include <stdio.h>

#define MAX_SIZE 1000001
#define in(x) scanf("%d", &x)

int primes[MAX_SIZE];

void prime(void)
{
	int i, j;
	
	for (i = 0; i < MAX_SIZE; i++){
		primes[i] = 1;
	}
	
	primes[0] = primes[1] = 0;
	for (i = 2; (i * i) < MAX_SIZE; i++){
		if (primes[i] == 1){
			for (j = i * i; j < MAX_SIZE; j += i){
				primes[j] = 0;
			}
		}
	}
}

int main(void)
{
	int n, count, i;
	
	prime();
	while (in(n) != EOF){
		count = 0;
		for (i = 2; i <= n; i++){
			if (primes[i] == 1){
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 4500
a = gets.chomp.split("").map(&:to_i)

ans = 0
max = 0
for bit in 0..2**(a.length-1)-1 do
moj = Array.new
  for i in 0..a.length do
        if (bit >> i) & 1 == 1 then
          moj = moj.push(a[i])
        else
          moj = moj.push(a[i])
          suu = moj.join.to_i
          ans = ans + suu
          moj = Array.new
        end
  end
end
  
p ans

Measured memory_bytes: 1916
from sys import exit
from itertools import accumulate,chain
n,*s=open(0).read().split()
t=[2*(i.count("("))-len(i) for i in s]
if sum(t)!=0:
    print("No");exit()
#pypyではinitialだめ
st=[[t_,min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0))] for s_,t_ in zip(s,t)]

now=0
v=list(filter(lambda x:x[0]>=0,st))
w=list(filter(lambda x:x[0]<0,st))
v.sort(reverse=True,key=lambda z:z[1])
w.sort(key=lambda z:z[0]-z[1],reverse=True)

for sub in chain(v,w):
    if now+sub[1]<0:
        print("No");exit()
    now+=sub[0]
print("Yes")


Measured memory_bytes: 123156
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	int a, b;
	cin >> a >> b;
	char c[110][110];
	for (int i = 0;i < 100;i++) {
		for (int j = 0;j < 100;j++) {
			if (i < 50)c[i][j] = '.';
			else c[i][j] = '#';
		}
	}
	int p = 1, q = 1;
	for (int i = 0;i < 50;i+=2) {
		for (int j = 0;j < 100;j += 2) {
			if (q == b)break;
			c[i][j] = '#', q++;
		}
	}
	for (int i = 99;i >= 50;i -= 2) {
		for (int j = 0;j < 100;j += 2) {
			if (p == a)break;
			c[i][j] = '.', p++;
		}
	}
	cout << 100 << ' ' << 100 << endl;
	for (int i = 0;i < 100;i++) {
		for (int j = 0;j < 100;j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
}

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


int main(){
	int d;
	int sum;
	while(cin >> d){
		sum = 0;
		for(int i = 1 ; d*i <= 600-d ;i++){
			sum  += (d*i)*(d*i)*d;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n,k;
	cin>>n>>k;
	fill(int,h,n);

	vector<int> dp(n,INF);

	dp[0]=0;
	rep(i,1,n){
		int r=min(i+1,k+1);
		rep(j,1,r){
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout<<dp[n-1];
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 4736
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
rec = "abcdefghijklmnopqrstuvwxyz"
for i in range(n):
    tmp = defaultdict(int)
    s = input()
    for j in range(len(s)):
        tmp[s[j]] += 1
    for k in range(len(rec)):
        if i == 0:
            dic[rec[k]] = tmp[rec[k]]
        else:
            dic[rec[k]] = min(dic[rec[k]], tmp[rec[k]])

t = ""
for k, v in dic.items():
    t += k * v

print("".join(sorted(list(t))))

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX_N 105
int N;
vector<int> G[MAX_N];
bool visited[MAX_N];
int ans,cnt;

void rec(int pos){
  ans=max(ans,++cnt);
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int w=G[pos][i];
    if(visited[w])continue;
    rec(w);
  }
  visited[pos]=false;
  cnt--;
}

void init(){
  for(int i=0;i<MAX_N;i++){
    G[i].clear();
  }
}

int main(){
  while(cin>>N&&N){
    init();
    for(int i=0;i<N;i++){
      int a,b;
      cin>>a>>b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    ans=0;
    for(int i=1;i<=100;i++){
      for(int j=1;j<=100;j++)visited[j]=false;
      cnt=0;
      rec(i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int i,n,mid,ans;
	scanf("%d",&n);
	vector<int> d(n);
	for ( i=0 ; i<=n ; i++){
		cin >> d[i];
	}
	sort(d.begin(),d.end());
	mid=int(n/2);
	if (d[mid-1]==d[mid]){
		ans=0;
	}
	else{
		ans=d[mid]-d[mid-1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int ans[100000],flag[100000];
int main(int argc, const char * argv[])
{
    int n,q,l,r;
    string s;
    cin>>n>>q>>s;
    int len=s.size(), cnt=0;
    for(int i=0;i<len;i++)
    {
        if(i>0 && s[i]=='C' && s[i-1]=='A') cnt++;
        flag[i]=cnt;
    }
    for(int i=0;i<q;i++)
    {
        cin>>l>>r;
        ans[i]=flag[r-1]-flag[l-1];
    }
    for(int i=0;i<q;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
	vector<int> nums(0);
	bool isPrime[300001];
	memset(isPrime,0,sizeof(isPrime));
	vector<int> primes(0);
	for(int i = 2; i <= 300000; ++i)
	{
		if(i%7==1||i%7==6)
		{
			nums.push_back(i);
			isPrime[i]=true;
			for(int j = 0; nums[j]*nums[j] <= i; ++j)
			{
				if(i%nums[j]==0)
				{
					isPrime[i]=false;
					break;
				}
			}
			if(isPrime[i]) primes.push_back(i);
		}
	}
	int n;
	while(cin>>n,n!=1) 
	{
		cout<<n<<":";	
		for(int j = 0; j < primes.size(); ++j)
		{
			if(n%primes[j]==0) cout<<" "<<primes[j];
		}
		cout<<endl;
	}
  return 0;
}

Measured memory_bytes: 2160
import fractions
n = int(input())
listA = list(map(int, input().split()))
listA.sort()
if len(listA) < 3:
    print(max(listA))
else:
    minGcd1 = fractions.gcd(listA[0], listA[1])
    minGcd2 = fractions.gcd(listA[1], listA[2])
    minGcd3 = fractions.gcd(listA[0], listA[2])
    ming1 = minGcd1
    maxg1 = 1
    while ming1 > 1:
        count=0
        flag=0
        index1=0
        while index1 < len(listA):
            if listA[index1]%ming1==0:
                pass
            else:
                count+=1
            if count >1:
                flag=1
                break
            index1+=1
        if flag:
            ming1-=1
        else:
            maxg1 = ming1
            break
    ming2 = minGcd2
    maxg2 = 1
    while ming2 > 1:
        count = 0
        flag = 0
        index1 = 0
        while index1 < len(listA):
            if listA[index1] % ming2==0:
                pass
            else:
                count += 1
            if count > 1:
                flag = 1
                break
            index1 += 1
        if flag:
            ming2 -= 1
        else:
            maxg2 = ming2
            break
    ming3 = minGcd3
    maxg3= 1
    while ming3 > 1:
        count = 0
        flag = 0
        index1 = 0
        while index1 < len(listA):
            if listA[index1] % ming3==0:
                pass
            else:
                count += 1
            if count > 1:
                flag = 1
                break
            index1 += 1
        if flag:
            ming3 -= 1
        else:
            maxg3 = ming3

            break
    print(max(maxg1, maxg2, maxg3))

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

int main(){
    int n;  cin >> n;
    vector<ll> h(n);
    for(int i=0; i<n; i++)  cin >> h.at(i);
    vector<ll> dp(n+1, 1e+15);
    dp[0] = 0;

    for(int i=1; i<n; i++){
        dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2])); 
    }
    
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
n, a, b = [int(x) for x in input().split()]
if a * b < n or n < a + b - 1:
    print(-1)
else:
    ans = []
    remaining = n - a
    to_insert = 1
    for i in range(a):
        ans.append(to_insert)
        to_insert += 1
        inserted = 1
        for j in range(min(b - 1, remaining)):
            ans.append(to_insert)
            to_insert += 1
            inserted += 1
            remaining -= 1
        ans[-inserted:] = reversed(ans[-inserted:])
    print(*ans)
        

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

	using namespace std;
	int main()
	{
		int n,a,b,t=0;
		cin >>n;
		while(n--)
		{
			cin >> a >> b;
			if(a==b) 
				t++;
			else 
			{
				if(t>=3)
					t = 3;
				else
					t = 0;
			}
		}
		if(t>=3)
		{
			cout << "Yes" << endl;
		}
        else
        {
        	cout << "No" << endl; 
        }

		
		

		return 0;
	
	}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    while(1) {
        int w,h;
        cin >>w>>h;
        if(w == 0 && h == 0) break;
        VV<int> a(h);
        rep(i,h)rep(j,w) {
            int inn;
            cin >> inn;
            a[i].push_back(inn);
        }
        auto dfs = [&](auto self, int x, int y) {
            if(x<0||y<0||x>=w||y>=h) return;
            if(a[y][x] == 0) return;
            a[y][x] = 0;
            rep(i, 8) {
                self(self, x+dx[i], y+dy[i]);
            }
        };
        int ans = 0;
        rep(i,h)rep(j,w) {
            if(a[i][j] == 1) {
                ans++;
                dfs(dfs, j,i);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String n = scan.next();

        if (n.charAt(0) == '9' || n.charAt(1) == '9') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 23764
import scala.util.control.Breaks
object Main extends App {
  val n = readLine().toInt

  for (i <- 1 to n) {
    var x = i

    if (x % 3 == 0) {
      print(" %d".format(i))
    } else {
      val b = new Breaks()
      b.breakable {
        do {
          if (x % 10 == 3) {
            print(" %d".format(i))
            b.break
          }
          x /= 10
        } while ( x != 0)
      }
    }
  }
  println()
}



Measured memory_bytes: 58776
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b)swap(a, b);
	if (b > c)swap(b, c);
	if (a > b)swap(a, b);
	cout << a * b / 2 << endl;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a [] =new int[3];
        for(int i=0;i<3;i++)
        a[i]=sc.nextInt();
    Arrays.sort(a);
        System.out.println(a[2] - a[1] + a[1] - a[0]);
    }
}


Measured memory_bytes: 21844
N, M = [int(x) for x in input().split()]


correct = 0
penalty = {i: 0 for i in range(1, N+1)}
final = 0

ans = set([])

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if p in ans:
        continue
    elif S == 'WA':
        penalty[p] += 1
    else:
        correct += 1
        ans.add(p)
for i in range(1, N+1):
    if i in ans:
        final += penalty[i]

print(correct, final)

Measured memory_bytes: 56804
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,p;cin>>n>>p;
    ll ans=1;
    for(ll i=2;i*i<=p;i++){
        ll cnt=0;
        ll np=p;
        while(np%i==0){
            np/=i;
            cnt++;
        }
        if(cnt>=n)chmax(ans,i);
    }
    if(n==1)ans=p;
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 256
from collections import deque

K = int(input())
dq = deque([i for i in range(1,10)])

for k in range(K):
  num = dq.popleft()

  if num%10 != 0:
    dq.append(10*num + (num % 10) -1)
  dq.append(10*num + (num%10))
  if num%10 != 9:
    dq.append(10*num + (num % 10) +1)
    
print(num)


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int k;
	cin >> k;
	ll ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			for (int p = 1; p <= k; ++p) {
				ans += gcd(i, gcd(j, p));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
a=[]
for i in range(n):
    A=list(map(int,input().split()))
    a.append(A)
a = sorted(a, key=lambda x: x[0])
b=0
for i in range(n):
    b+=a[i][1]
    if b>=k:
        print(a[i][0])
        exit()

Measured memory_bytes: 29432
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m;
    cin >> n >> m;

    int a, b;
    vector<pii> v;

    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        v.bash({b, a});
    }

    sort(ALL(v));

    int ans = 0, t = 0;

    for(int i = 0; i < m; i++) {
        if(!ans or v[i].second > t) {
            t = v[i].first - 1;
            ans++;
        }
    }

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



Measured memory_bytes: 1400