akhauriyash/Code-Regression huggingface dataset:
/*input
6
1 3 -4 2 2 -2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn];
map<ll,ll> mp;

int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	ll pre=0;
	mp[pre]++;
	REP(i,n){
		pre+=a[i];
		mp[pre]++;
	}

	ll ans=0;
	for(auto i:mp){
		ans+=i.S*(i.S-1)/2;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 14336
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Walk implements Comparable<Walk> {
		int cost;
		int pos;
		int pass;
		
		public Walk(int cost, int pos, int pass) {
			super();
			this.cost = cost;
			this.pos = pos;
			this.pass = pass;
		}

		@Override
		public int compareTo(Walk o) {
			// TODO Auto-generated method stub
			return this.cost - o.cost;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int c = sc.nextInt();
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			final int s = sc.nextInt() - 1;
			final int d = sc.nextInt() - 1;
			
			if(c == 0 && n == 0 && m == 0 && s == -1 && d == -1){
				break;
			}
			
			int[][] adj = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					adj[i][j] = -1;
				}
			}
			for(int i = 0; i < m; i++){
				final int from = sc.nextInt() - 1;
				final int to = sc.nextInt() - 1;
				final int cost = sc.nextInt();
				
				adj[from][to] = adj[to][from] = cost;
			}
			
			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			queue.add(new Walk(0,s,c));
			
			boolean[][] visited = new boolean[n][c+1];
			
			while(!queue.isEmpty()){
				Walk walk = queue.poll();
				
				//System.out.println(walk.cost + " " + walk.pos + " " + walk.pass);
				if(walk.pos == d){
					System.out.println(walk.cost);
					break;
				}
				
				if(visited[walk.pos][walk.pass]){
					continue;
				}
				visited[walk.pos][walk.pass] = true;
				
				for(int to = 0; to < n; to++){
					if(adj[walk.pos][to] != -1){
						if(walk.pass > 0 && !visited[to][walk.pass - 1]){
							queue.add(new Walk(walk.cost + adj[walk.pos][to]/2, to, walk.pass - 1));
						}
						
						if(!visited[to][walk.pass]){
							queue.add(new Walk(walk.cost + adj[walk.pos][to], to, walk.pass));
						}
					}
				}
			}
		}
	}
}

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


using namespace std;
typedef long long LL;
const int maxn = 10010;
int a[maxn], b[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    LL x = 0, y = 0;
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &b[i]);
        int cur = b[i] - a[i];
        if(cur < 0)
            y += -cur;
        else
        {
            x += (cur + 1) / 2;
            y += cur % 2;
        }
    }
    if(x < y)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

class Song{
	String title;
	int time;
	public Song(String title, int time) {
		super();
		this.title = title;
		this.time = time;
	}
	
}


public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		List<Song> l = new ArrayList<Song>();
		for(int i=0;i<n;i++) {
			String s = fs.next();
			int t = fs.nextInt();
			Song song = new Song(s,t);
			l.add(song);
		}
		String x = fs.next();
		
		int all = 0;
		for(int i=0;i<n;i++) {
			Song song = l.get(i);
			all += song.time;
		}
		
		int total = 0;
		for(int i=0;i<n;i++) {
			Song song = l.get(i);
			if(!x.equals(song.title)) {
				total += song.time;
			}else {
				total += song.time;
				System.out.println(all-total);
				return;
			}
		}
		
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21588
# include <bits/stdc++.h>
using namespace std;
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<<" "<<c<<endl;
    }
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }
    if(b==c){
        cout<<a<<endl;
    }
    if(c==a){
        cout<<b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	vector<ll> vec(n,0);
	for(ll i=0;i<n;i++){
		cin>>vec[i];
	}
	ll anss=0;
	sort(vec.begin(),vec.end());
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			for(ll k=j+1;k<n;k++){
				if(vec[i]!=vec[j]&&vec[j]!=vec[k]&&vec[i]+vec[j]>vec[k]&&vec[i]+vec[k]>vec[j]&&vec[j]+vec[k]>vec[i]){
					anss++;
				}
			}
		}
	}
	cout<<anss<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,m;
    in(n,m);
    vector<vector<int>> a(n+1);
    vector<int> b;
    int x,y;
    rep(i,m){
        in(x,y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    rep(i,a[1].size()){
        b.push_back(a[1][i]);
    }
    int ans=0;
    rep(i,b.size()){
        rep(j,a[b[i]].size()){
            if(a[b[i]][j]==n){
                ans=1;
            }
        }
    }
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
}


Measured memory_bytes: 15880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int INF = 1e9+5;

vi adj[100005];
vi dist(100005, INF);
vpii edge;
map<pii, int> weight;

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

    int n,m; cin>>n>>m;
    vi D = readVector<int>(n);

    FOR(i,m) {
        int u,v; cin>>u>>v;
        u--; v--;
        edge.push_back({u,v});
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    map<int, vi> dv;
    FOR(i,n) {
        dv[D[i]].push_back(i);
    }

    set<int> whites;

    for(auto el : dv) {
        int d = el.first;
        for(auto v : el.second) {
            int ok=false;
            int samed = -1;
            for(auto to : adj[v]) {
                if(dist[to] != INF && dist[to]<d) {
                    weight[{v,to}] = d-dist[to];
                    weight[{to,v}] = d-dist[to];
                    ok = true;
                    dist[v]=d;
                }
                if(d == D[to])
                    samed = to;
            }
            if(ok) continue;
            if(samed<0)
                EXIT(-1);

            weight[{v,samed}] = d;
            weight[{samed,v}] = d;
            whites.insert(v);
            dist[v] = 0;
        }
    }

    FOR(i,n)
        cout<<(whites.count(i) ? 'W' : 'B');
    cout<<endl;

    FOR(i,m) {
        if(weight.count(edge[i])) {
            cout<<weight[edge[i]]<<endl;
        } else
            cout<<(int)1e9<<endl;
    }

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int sum=0;
  int tmp=N;
  while(tmp>0){
   sum+=tmp%10;
   tmp/=10; 
  }
  if(N%sum==0){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] arr = new int[num];
        for(int i = 0; i < num; i++) {
            arr[i] = sc.nextInt();
        }

        int max = -2000000000;
        int min = arr[0];
        for(int i = 1; i < num; i++) {
            max = Math.max(max, arr[i] - min);
            min = Math.min(min, arr[i]);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 100760
#include<stdio.h>
int main()
{
	int a, b, c, ans;
	scanf("%d%d", &a, &b);
  if(b==100){
    b++;
  }
	for (int i = 0; i < a; i++)
	{
		b *= 100;
	}
	printf("%d", b);
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	ans = n / (2*d+1);
	if (n % (2 * d+1) != 0)
		ans += 1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = (int)1e9+7;
int main() {
    int n, k; std::cin >> n >> k;
    std::vector<int> a(n), dp(1+k);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        auto s = dp;
        for (int j = 1; j <= k; j++) {
            (s[j] += s[j-1]) %= mod;
        }
        for (int j = 1; j <= k; j++) {
            int tmp = s[j];
            if (j - a[i] > 0) {
                tmp = (tmp - s[j - a[i] - 1] + mod) % mod;
            }
            dp[j] = tmp;
        }
    }
    std::cout << dp[k] << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *h = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, h + i);
  }
  i32 *dp = (i32 *) calloc (n, sizeof (i32));
  dp[1] = ABS(h[1] - h[0]);
  for (i32 i = 2; i < n; ++i) {
    dp[i] = MIN(dp[i - 1] + ABS(h[i] - h[i - 1]), dp[i - 2] + ABS(h[i] - h[i - 2]));
  }
  printf("%" PRIi32 "\n", dp[n - 1]);
}

int main (void) {
  run ();
  return 0;
}

Measured memory_bytes: 896
var primeNxt = new Array(1000000);

function primeGenerator()
{
    var p, fact, m;
    var maxN = 1002001;
    var primePrv = new Array(1000000);

    // Initial
    for(p=2;p<=maxN;++p){
        primeNxt[p] = p + 1;
        primePrv[p] = p - 1;
    }
    primePrv[2] = 0;
    primeNxt[maxN] = 0;
    
    // Make prime table (primeNxt)
    for(p=2;p*p<=maxN;p=primeNxt[p]){
        for(fact=p;p*fact<=maxN;fact=primeNxt[fact]){
            for(m=p*fact;m<=maxN;m*=p){
                primeNxt[primePrv[m]] = primeNxt[m];
                primePrv[primeNxt[m]] = primePrv[m];
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
 
process.stdin.on('data', function(input){
    primeGenerator();
    input.trim().split('\n').forEach(function(val){
        var N = parseInt(val);
        var cnt = 1;
        if( N == 1 ){
            console.log(0);
        }
        else if( N == 2 ){
            console.log(1);
        }
        else{
            for(var i=3;i<=N;i=primeNxt[i]){
               ++cnt;
            }
            console.log(cnt);
        }
    });
});

Measured memory_bytes: 72232
t=str(input())
n=t.count('N')
s=t.count('S')
w=t.count('W')
e=t.count('E')

if n-s !=0 and n*s==0:
    print('No')
    exit()
    
if w-e !=0 and w*e==0:
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3064
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(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

using namespace std;

const lint MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n, 0);
    bool flag = true;
    rep(i, n){
        int t;
        cin >> t;
        a[t]++;
        if(a[t] > 2){
            flag = false;
        }
    }
    if(flag){
        if(n % 2 == 1){
            if(a[0] != 1){
                flag = false;
            }
            for(int i = 2 ; i < n ; i += 2){
                if(a[i] != 2){
                    flag = false;
                    break;
                }
            }
        }else{
            for(int i = 1 ; i < n ; i += 2){
                if(a[i] != 2){
                    flag = false;
                    break;
                }
            }
        }
    }
    if(flag){
        lint ans = 1;
        rep(i, n/2){
            ans = (ans * 2) % MOD;
        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
    
    d n;
    cin>>n;
    cout<<n*(180-(360.0/n));
    
            
    return 0;
}


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

using namespace std;

const int W = 4, H = 5;
unordered_map<string, int> memo;

inline int next(int pos, int dy, int dx)
{
    if (dy == 0 && dx == 0)
        return -1;
    int x = (pos % W) + dx, y = (pos / W) + dy;
    if (x < 0 || y < 0 || x >= W || y >= H)
        return -1;
    return y * W + x;
}

int Rec(string s)
{
    if (memo.end() != memo.find(s))
        return memo[s];

    int res = s.size();

    for (int i = 0; i < s.size(); ++i) {
        for (int dy = -1; dy <= 1; ++dy) {
            for (int dx = -1; dx <= 1; ++dx) {
                int nx = next(i, dy, dx);
                if (nx == -1 || nx >= s.size())
                    continue;
                if (s[i] != s[nx])
                    continue;

                string tmp("", (int)s.size() - 2);
                int index = 0;
                for (int l = 0; l < s.size(); ++l)
                    if (l != i && l != nx)
                        tmp[index++] = s[l];

                res = min(res, Rec(tmp));
            }
        }
    }

    memo.insert(unordered_map<string, int>::value_type(s, res));
    return res;
}

int main()
{
    int N;

    cin >> N;
    while (N--) {
        // Input
        char ch;
        string card;

        for (int i = 0; i < H * W; ++i) {
            cin >> ch;
            card += ch;
        }
        // Solve
        cout << Rec(card) << endl;
    }

    return 0;
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

string s;

void solve()
{
    cin>>s;
    
    if(s=="SSS")
        cout<<0;
    else if(s=="RRS" or s=="SRR")
        cout<<2;
    else if(s=="RRR")
        cout<<3;
    else
        cout<<1;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







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

class UnionFind {
private:
    vector<int> parent;
    vector<int> rank;
    vector<int> size;
public:
    UnionFind(unsigned long n): parent(n), rank(n, 0), size(n, 1) {
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int count(int x) {
        return size[root(x)];
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
            size[y] += count(x);
        } else {
            parent[y] = x;
            size[x] += count(y);
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uf.unite(x, y);
            continue;
        }
        cout << uf.same(x, y) << endl;
    }
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x=0) : x((x%mod+mod)%mod) {}
	mint operator-() const { 
	return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res/=a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

vector<int> to[200005];
mint ans = 0;
int n;
int dfs(int v,int p = -1){
	int res = 1;
	vector<int> ts;
	for(int nv:to[v]){
		if(nv == p) continue;
		int t = dfs(nv,v);
		res += t;
		ts.push_back(t);
	}
	if(p != -1){
		ts.push_back(n-res);
	}
	mint now = mint(2).pow(n-1)-1;
	for(int t:ts){
		now -= mint(2).pow(t)-1;
	}
	ans += now;
	return res;
}
int main(){
	cin >> n;
	rep(i,n-1){
		int a,b;cin >> a >> b;
		--a;--b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	dfs(0);
	ans /= mint(2).pow(n);
	cout << ans << endl;

	
}
 
 

Measured memory_bytes: 32544
class UnionFind:
    def __init__(self,n):
        self.par = {i:i for i in range(1,n+1)}
        self.rank = {i:0 for i in range(1,n+1)}
        self.size = {i:1 for i in range(1,n+1)}

    def find(self,x):
        if x != self.par[x]:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self,x,y):
        px,py = self.find(x),self.find(y)
        res = 0
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.size[py] += self.size[px]
                res = self.size[py]
            else:
                self.par[py] = px
                self.size[px] += self.size[py]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                res = self.size[px]
        return res

n,m = map(int,input().split())
ans = 1
uf = UnionFind(n)
for _ in range(m):
    a,b = map(int,input().split())
    ans = max(ans,uf.union(a,b))
print(ans)

Measured memory_bytes: 68772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,k;
    cin>>n>>k;
    if(abs(n-k)%2 == 0){
        ll h = (abs(n-k))/2;
        cout<<max(n,k)-h<<"\n";
        return 0;
    }
    else{
        cout<<"IMPOSSIBLE"<<"\n";
    }

}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

static MOD: i64 = 1_000_000_000 + 7;

// 冪乗余計算アルゴリズム
// a^b mod m を計算します。
fn pow_mod(a: i64, b: i64, m: i64) -> i64 {
    if b == 0  {
        1
    } else if b % 2 == 0 {
        let d = pow_mod(a, b/2, m);
        (d * d) % m
    } else {
        (a * pow_mod(a, b-1, m)) % m
    }
}

// nCc mod m を計算します。
fn combination(mut n: i64, c: i64, m: i64) -> i64 {
    let mut upe = 1;
    let mut dow = 1;
    for i in 1..c + 1 {
        upe = upe * n % m;
        dow = dow * i % m;

        n -= 1;
    }
    upe * pow_mod(dow, m-2, m) % m
}

fn main() {
    let n: i64 = input();
    let k: i64 = input();
    for i in 1..k+1 {
        let d = combination(n-k+1, i, MOD) * combination(k-1, i-1, MOD) % MOD;
        println!("{}", d);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll w,h,x,y; cin >> w >> h >> x >> y;

    printf("%.8lf ", (double)w*h/2.0);

    if(w%2==0 && h%2 == 0 && x==w/2 && y==h/2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        String s=scan.next();
        StringBuilder sb=new StringBuilder();

        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='0'){
                sb.append("0");
            }
            if(s.charAt(i)=='1'){
                sb.append("1");
            }
            if(s.charAt(i)=='B' && sb.length()!=0){
                sb.deleteCharAt(sb.length()-1);
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 9428
#include<bits/stdc++.h>
#define int long long
int a[19];
using namespace std;
signed main(){
    int n;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            sum++;
        }
    }
    cout<<pow(3,n)-pow(2,sum)<<endl;
}

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

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> dir(N, -1); // 通ってきたところ
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            dir[nv] = v+1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << '\n';
    for (int v = 1; v < N; ++v) cout << dir[v] << endl;
}


Measured memory_bytes: 10728
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

c = Counter(A)
for i in range(N):
    print(c[str(i + 1)])


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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
    ll n, m;
    cin >> n >> m;
    if(abs(n-m) >= 2){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(ll i = n; i > 0; i--){
        ans = (ans * i) % mod;
    }
    
    for(ll i = m; i > 0; i--){
        ans = (ans * i) % mod;
    }
    if(abs(n-m) == 0) ans *= 2;
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int x, a, b; cin >>x>> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << "\n";
	}
	else {
		cout << "B" << "\n";
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
ll X;
ll B[MAXN];
ll L[MAXN], U[MAXN];
pair <ll, int> ord[MAXN];

ll ntime (int i, ll v)
{
    if (B[i] * L[i] >= v)
        return (v - 1) / L[i] + 1;
    v -= B[i] * L[i];
    return (v - 1) / U[i] + 1 + B[i];
}

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

    cin >> N >> X;

    ll cscore = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> B[i] >> L[i] >> U[i];
        cscore += B[i] * L[i];
        ord[i] = make_pair (B[i] * L[i] + (X - B[i]) * U[i], i);
    }
    if (cscore == 0)
    {
        cout << "0\n";
        exit(0);
    }

    sort (ord, ord + N);
    reverse (ord, ord + N);

    ll ctot = 0;
    int cv = 0;
    while (ctot < cscore)
    {
        ctot += ord[cv].first;
        cv++;
    }

    ll ans = cv * X;
    for (int i = 0; i < cv; i++)
        ans = min (ans, (cv - 1) * X + ntime (ord[i].second, cscore - (ctot - ord[i].first)));

    cv--;
    ctot -= ord[cv].first;
    for (int i = cv; i < N; i++)
        ans = min (ans, cv * X + ntime (ord[i].second, cscore - ctot));
    cout << ans << "\n";
}

Measured memory_bytes: 4224
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: chars,
        b: chars,
        c: chars,
    }

    let mut ans = 0;

    for i in 0..n {
        let ai = a[i];
        let bi = b[i];
        let ci = c[i];

        if ai == bi && bi == ci {
        } else if ai == bi || bi == ci || ci == ai {
            ans += 1;
        } else {
            ans += 2;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
//
// Created by bytedance on 2020/5/6.
//
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
const int maxn = 2e5 + 5;

int h[maxn], mem;
int q[maxn], top;
int ans[maxn];
int a[maxn];
struct {
    int v, next;
} e[maxn << 1];

void init() {
    mem = top = 0;
    memset(h, -1, sizeof(h));
}

void add(int u, int v) {
    e[mem].v = v;
    e[mem].next = h[u];
    h[u] = mem++;
}

void dfs(int u, int fa) {
    int ttop = top;
    int tid = -1, tv = 0;
    if (!top || a[u] > q[top - 1]) {
        q[top++] = a[u];
    } else {
        int l = 0, r = top - 1;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (q[mid] >= a[u]) {
                tid = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        tv = q[tid];
        q[tid] = a[u];
    }
    ans[u] = top;
    for (int i = h[u]; i + 1; i = e[i].next) {
        int v = e[i].v;
        if (v == fa) continue;
        dfs(v, u);
    }
    top = ttop;
    if (tid >= 0) {
        q[tid] = tv;
    }


}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
    }
    init();
    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        add(x, y);
        add(y, x);
    }
    dfs(1, 1);
    for (int i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 23552
#include<iostream>
using namespace std;
int main()
{
	int ans=1,n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		if(k>=ans)ans*=2;
		else	  ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	vector<long long> a;
	long long n, tmp, cnt=0;
	long long b[10];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	for(int i=a.size()-1;i>0;i--){
		if(a[i]==a[i-1]){
			b[cnt]=a[i];
			cnt++;
			if(cnt>=2)break;
			i--;
		}
	}
	if(cnt<2)puts("0");
	else cout << b[0] * b[1] << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<math.h>
//#include<map>                                                                                                        
using namespace std;

int main()
{
  // 入力                                                                                                              
  int a;
  string s;
  cin >> a >> s;

  // 出力                                                                                                              
  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;

long long gcd(const long long& a, const long long& b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll k;
    cin >> k;
    deque<string> q;
    q.push_front("1");
    
    ll c = 0;
    string ret;
    while(q.size() > 0 && c < k)
    {
        string cur = q.front();
        q.pop_front();
        ret = cur;
        if (cur.substr(cur.size() - 1, 1) != "9")
        {
            ll n1 = stoi(cur.substr(cur.size() - 1, 1));
            n1++;
            string next1 = cur.substr(0, cur.size() - 1) + to_string(n1);
            if (next1.size() < 2 || abs(stoi(next1.substr(next1.size() - 1, 1)) - stoi(next1.substr(next1.size() - 2, 1))) <= 1)
            {
                q.push_front(next1);
            }
        }
        string next10 = cur += to_string(max(stoi(cur.substr(cur.size() - 1, 1)) - 1, 0));
        q.push_back(next10);
        c++;
    }
    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 5404
r,c = map(int,input().split())
lst = [[0 for i in range(101)] for j in range(101)]
for i in range(r):
    lst[i][0:c] = map(int,input().split())
for i in range(r):
    lst[i][c] = sum(lst[i])
for i in range(c+1):
    for j in range(r):
        lst[r][i] += lst[j][i]
for i in range(r+1):
    for j in range(c+1):
        print(f"{lst[i][j]}",end = "")
        if j != c:
            print(" ",end = "")
        else:
            print()


Measured memory_bytes: 6740
package main

import "fmt"

func main(){
	var h1,m1,h2,m2,k int
	fmt.Scan(&h1,&m1,&h2,&m2,&k)
	m_val := m2-m1
	h_val := h2-h1
	time := h_val*60+m_val
	fmt.Println(time-k)
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll n,ans=LLONG_MAX; cin >> n; 
 
  for(ll i=1; i*i<=n;++i){
    ll res=0;
    if(n%i==0) res+=i+(n/i)-2;
    if(res)ans=min(ans,res); 
  }  
  cout << ans << endl;
}






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

int main() {
    int n, k; cin >> n >> k;
    int tmp = n - k;
    cout << ((k == 1) ? 0 : tmp) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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();
    int d = sc.nextInt();
    if(a*b > c*d){
      System.out.println(a*b);
    }
    else if(a*b < c*d){
      System.out.println(c*d);
    }
    else{
      System.out.println(a*b);
    }
  }
}


Measured memory_bytes: 21844
import math

n = int(input())


ans1 = 0
# 3つ同じ時
ans1 += int((n + 1) * n / 2)


ans2 = 0
# 2つ同じ時
for i in range(2, n + 1):
    for j in range(1, i):
        ans2 += math.gcd(i, j)
ans2 = ans2 * 6


ans3 = 0
# 全部違う時
for i in range(3, n + 1):
    for j in range(2, i):
        for k in range(1, j):
            ans3 += math.gcd(math.gcd(i, j), k)

ans3 = ans3 * 6

print(ans1 + ans2 + ans3)

Measured memory_bytes: 9208
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
//https://codeforces.com/contest/1213/problems
//https://codeforces.com/contest/1213/submit
ll a[300000];
ll b[300000];
ll aabs(ll a){
    if(a < 0){
        return a*-1ll;
    }else{
        return a;
        }
}
int main(){
    int n;
    s(n)
    ll sum = 0;
    for(int i = 0; i < n; i ++){
        sld(a[i])
        sum += a[i];
        b[i] = sum;
    }
    ll mini = 3000000000ll;
    for(int i = 0; i < n-1; i ++){
        mini = min(aabs(2ll*b[i]-sum),mini);
        //p(aabs(2ll*b[i]-sum)) pn
    }
    pld(mini) pn




    return 0;
}


Measured memory_bytes: 3840
package main
import(
  "fmt"
)
func main(){
  var i, n, x int
  ans:=1000
  flag:=0
  fmt.Scan(&n,&x)
  c:=make([]int, n)
  t:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&c[i], &t[i])
  }
  for i=0;i<n;i++{
    if c[i]<=ans&&t[i]<=x{
      ans=c[i]
      flag++
    }
  }
  if flag==0{
    fmt.Println("TLE")
  }else{
    fmt.Println(ans)
  }
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var m = s.Substring(s.Length - 1);

            if (m == "s")
            {
                Console.WriteLine(s + "es");
            }
            else
            {
                Console.WriteLine(s + "s");
            }

        }
    }
}

Measured memory_bytes: 25844
//
// Created on 2020/05/10.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string ans = "Yes";
    string s;
    string t;
    cin>>s>>t;

    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != t[i]) ans = "No";
    }

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll a,b;
    cin >> a >> b;
    if(a >= 13)cout << b;
    else if(a>=6 and a<=12) cout << b/2;
    else cout <<"0";

    return 0;

}

Measured memory_bytes: 256
//                      Aman Raj  - 201851015
#include<bits/stdc++.h>
using namespace std;
#define ll                        long long
#define vi                        vector<ll int>
#define pb                        emplace_back
#define rep(i,a,b)                for(int i = a; i<b; ++i)
#define rrep(i,a,b)               for(int i = a; i>=b; --i)
#define p(a)                      cout << a << "\n";
#define p2(a,b)                   cout << a << " " << b << "\n";
#define fast_io                   ios_base::sync_with_stdio(false);cin.tie(NULL);
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://

int32_t main() {
	fast_io;
    ll tt = 1;
	// cin >> tt;
    while(tt--) {
        ll n;   cin >> n;
		vi h(n);
		rep(i,0,n)	cin >> h[i];
		int dp[n];
		dp[0] = 0;
		dp[1] = abs(h[1]-h[0]);
		rep(i,2,n) {
			dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
		}
		// rep(i,0,n) cout<<dp[i]<<" ";
		p(dp[n-1]);
    }
    return 0;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://


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

int main(){

    int n,t;
    cin >> n >> t;
    vector<vector<int>> ct(n,vector<int>(2));
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            cin >> ct.at(i).at(j);
      }
    }
    int ans = 10000;
    for(int i=0; i<n; i++){
        if(ct.at(i).at(1) > t){
            continue;
        }
        else{
            if(ans > ct.at(i).at(0)){
                ans = ct.at(i).at(0);
            }
        }
    }
    if(ans == 10000){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val N = readInputLine().toInt()

    val AArr = readInputLine().split(" ").map { it.toInt() }.toIntArray()
    val cnt = mutableMapOf<Int, Long>()

    for (A in AArr) {
        cnt[A] = (cnt[A] ?: 0L) + 1L
    }

    var cntSum = 0L
    for ((k, v) in cnt) {
        cntSum += v * (v - 1L) / 2L
    }

    repeat(N) {
        println(cntSum - (cnt[AArr[it]]!! - 1L))
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 105176