akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 123456789;

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

int id(int x, int y, int d){
  return (x * 32 + y) * 4 + d;
}

int cmdpos(int x, int y, int c, int d){
  return id(x+dx[(d+c)%4], y+dy[(d+c)%4], (c+d)%4);
}

struct Edge{
  int to, cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};

typedef vector< vector<Edge> > Graph;

void Dijkstra(const Graph& edges, vector<int>& d, int s){
  const int V = edges.size();
  priority_queue<PII, vector<PII>, greater<PII> > pq;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	PII pii = pq.top(); pq.pop();
	int v = pii.second;
	if(d[v] < pii.first) continue;
	for(int i=0;i<edges[v].size();++i){
	  const Edge& e = edges[v][i];
	  if(d[e.to] > d[v] + e.cost){
		d[e.to] = d[v] + e.cost;
		pq.push(MP(d[e.to], e.to));
	  }
	}
  }
}

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

  int W, H;
  while(cin >> W >> H, W){
	int bd[32][32], cost[4];
  
	REP(y,H) REP(x,W)
	  cin >> bd[y+1][x+1];
	
	REP(i,4) cin >> cost[i];
	
	Graph G(4100);
	VI dist(4100);
	FOR(y,1,H+1) FOR(x,1,W+1){
	  if(bd[y][x] == 4) continue;
	  REP(d,4)
		G[id(x,y,d)].PB(Edge(cmdpos(x,y,bd[y][x],d), 0));
	}
	
	FOR(y,1,H+1) FOR(x,1,W+1) REP(d,4) REP(c,4){
	  if(c == bd[y][x]) continue;
	  G[id(x,y,d)].PB(Edge(cmdpos(x,y,c,d), cost[c]));
	}

	Dijkstra(G, dist, id(1,1,0));
	int ans = INF;
	REP(d,4)
	  ans = min(ans, dist[id(W,H,d)]);
	cout << ans << endl;
  }
  
  return 0;
}

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return (key % M); }
int h2(int key){ return 1 + key %( M - 1 ); }

int find(char str[]){
	int key = getKey(str);
	int _h1 = h1(key);
	int _h2 = h2(key);
	int i= 0;
//	printf("== %s -> %d , h1 = %d, h2 = %d\n",str,key,_h1,_h2);
	while(i <= M){
		int h = (_h1 + i * _h2) % M;
		if(strlen(H[h])==0){
//			printf("H[%d] : no value\n",h);
			return -1;
		}else if(strcmp(H[h],str)==0){
//			printf("H[%d] = %s, tgt = %s (hit)\n",h,str,H[h]);
			return h;
		}else{
//			printf("H[%d] = %s, tgt = %s (collision)\n",h,str,H[h]);
		}
		i++;
	}
	return -1;
}

int insert(char str[]){
	int key = getKey(str);
	int _h1 = h1(key);
	int _h2 = h2(key);
	int i= 0;
//	printf("%s -> %d , h1 = %d, h2 = %d\n",str,key,_h1,_h2);
	while(i <= M){
		int h = (_h1 + i * _h2) % M;
		if(strlen(H[h])==0){
//			printf("H[%d] : %s (null) <= insert %s\n",h,H[h],str);
			strcpy(H[h],str);
			return 1;
		}
//		printf("H[%d] : %s (not null) <= could not insert %s\n",h,H[h],str);
		i++;
	}
	return -1;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str) >= 0){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 17064
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	set<long long>set;
	for(int i=0;i<N;i++){
		long long t;
		cin>>t;
		if(set.find(t)==set.end())set.insert(t);
		else set.erase(t);
	}
	cout<<(long long)set.size()<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int i, j, k;
    vector <vector <int> > v(n);
    for(i = 0; i < n; i ++)
    {
    	for(j = 0; j < d; j ++)
    	{
	    	int val;
	    	cin >> val;
	    	v[i].push_back(val);	
    	}    	
    }

    int count = 0;
    for(i = 0; i < n - 1; i ++)
    {
    	for(j = i + 1; j < n; j ++)
    	{
    		double dist = 0;
    		for(k = 0; k < d; k ++)
    		{
    			dist = dist + (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]); 
    		}
    		dist = sqrt(dist);
    		// cout << dist << endl;
    		if(ceil(dist) == floor(dist))
    			count ++;
    	}
    }

    cout << count << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    string S;
    cin >> S;
    int score = 0;
    int n_p = 0;  // パーの回数
    REP1 (i, S.length())
    {
        if (S[i - 1] == 'g')
        {
            if (n_p < i / 2)
            {
                score++;
                n_p++;
            }
        }
        else  // 相手がパー
        {
            if (n_p >= i / 2)  // あいこにできない
                score--;
            else  // あいこにして回避
                n_p++;
        }
    }
    std::cout << score << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;






public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    //public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
   private static int N = (int) (2e5 + 11);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();

	int n = sc.nextInt();
	int[] a = new int[n];
	for(int i=0;i<n;++i) a[i] = sc.nextInt();
	int[] idx = new int[n];
	idx[0] = 0;
    int ans = 0;
	for(int i=1;i<n;++i) {
		if(a[i]<=a[i-1]) idx[i] = idx[i-1]+1;
		else idx[i] = 0;
		ans = Math.max(ans, idx[i]);
	}
	out.print(ans);
	 out.close();
	}
}

Measured memory_bytes: 40968
using System;
using System.Linq;

namespace AGC010B
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

            long onetime = N * (N + 1) / 2;
            long Sum = A.Sum();

            if (Sum % onetime != 0)
            {
                Console.WriteLine("NO");
                return;
            }

            long times = Sum / onetime;

            long[] Difference = new long[N];
            for (long i = 0; i < N - 1; i++)
            {
                Difference[i] = A[i + 1] - A[i] - times;
            }

            Difference[N - 1] = A[0] - A[N - 1] - times;

            long count = 0;
            for (long i = 0; i < N; i++)
            {
                if (Difference[i] % N != 0 | Difference[i] > 0)
                {
                    Console.WriteLine("NO");
                    return;
                }

                count += Difference[i] / N;
            }

            if (-count == times)
            {
                Console.WriteLine("YES");
                return;
            }
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 23648
// A - Transfer
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(c-(a-b) <= 0){
        printf("0\n");
    }else{
        printf("%d\n", c-(a-b));
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M,a,b,c; cin>>N>>M;
  vector<ll> A(M+1),B(M+1),C(M+1),D(N+1,-1e15);
  D[1]=0;
  for(int i=1; i<=M; i++){
    cin>>a>>b>>c;
    A[i]=a; B[i]=b; C[i]=c;
  }
  for(int i=1; i<=N-1; i++){
    for(int j=1; j<=M; j++){
      if(D[A[j]]==-1e15) continue;
      else if(D[B[j]]<D[A[j]]+C[j]) D[B[j]]=D[A[j]]+C[j];
    }
  }
  vector<bool> E(N+1,false);
  for(int i=1; i<=N; i++){
    for(int j=1; j<=M; j++){
      if(D[B[j]]<D[A[j]]+C[j]){
        D[B[j]]=D[A[j]]+C[j];
        E[A[j]]=true, E[B[j]]=true;
      }
    }
  }
  if(E[N]) cout<<"inf"<<endl;
  else cout<<D[N]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 1e5+5;
const ll M = 1e9+7;

char mp[10][10];
int n,m,k;

inline bool check(int x,int y){
	int res = 0;
	for(int i = 0;i < n;++i){
		for(int j = 0;j < m;++j){
			if((x & (1 << i)) || (y & (1 << j))) continue;
			if(mp[i][j] == '#') res++;
		}
	}
	return res == k;
}

int main()
{	
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0;i < n;++i) scanf("%s",mp[i]);
	
	int ans = 0;
	for(int i = 0;i < (1 << n);++i){
		for(int j = 0;j < (1 << m);++j){
			if(check(i,j)) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3812
import math
# s=int(input())
# b=input()
# c=[]
# for i in range(b):
#     c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))

if a[0]+a[1]<a[2]+a[3]:
    print("Right")
elif a[0]+a[1]==a[2]+a[3]:
    print("Balanced")
elif a[0]+a[1]>a[2]+a[3]:
    print("Left")

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N;
ll a[100010] = {};
int main(){
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        ans += a[i]/2;
        a[i] %= 2;

        if(a[i] == 1 && i < N-1 && a[i+1] > 0){
            ans++;
            a[i+1]--;
        }
    }
    cout << ans << endl;
}



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

const ll INF = 1LL << 60;

ll N, M;
vector<ll> a, b;

vector<P> keys;


int main() {
    cin >> N >> M;
    a.resize(M);
    b.resize(M);

    rep(i, M) {
        cin >> a[i] >> b[i];

        ll s = 0;
        rep(j, b[i]) {
            ll tmp_c;
            cin >> tmp_c;
            tmp_c--;
            s |= (1LL << tmp_c);
        }

        keys.push_back(P(s, a[i]));  
    }

    vector<ll> dp(1 << N, INF);
    dp[0] = 0;

    rep(s, 1 << N) {
        rep(i, M) {
            ll to = s | keys[i].first; 
            ll cost = dp[s] + keys[i].second;
            dp[to] = min(dp[to], cost);
        }
    }

    // 一番後ろの要素
    ll ans = dp.back();
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

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

int N,A[200000];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	ll res=0;
	int mx=0;
	for(int i=0;i<N;i++){
		res+=max(mx-A[i],0);
		mx=max(mx,A[i]);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 4372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



string s;

int main () {
  cin >> s;
  int n = s.size();

  string tmp = "";

  Rep(i, n) {
    if (i % 2 == 0) {
      tmp += "1";
    } else {
      tmp += "0";
    }
  }

  int ct = 0;

  Rep(i, n) {
    if (s[i] != tmp[i]) ct++;
  }

  cout << min(ct, n-ct) << "\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for (int i = 0; i < 3 * N; ++i) cin >> a[i];
  sort(a.begin(), a.end(), [](int a, int b) { return b < a; });
  // for (auto _a: a) cerr << _a << " ";
  // cerr << endl;
  long sum = 0;
  for (int i = 0; i < N; ++i) sum += a[2 * i + 1];
  cout << sum << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    ll num[n];
    for (int k = 0; k < n; ++k) {
        num[k]=0;
    }
    for (int i = 0; i < n-1; ++i) {
        int j;
        cin>>j;
        num[j-1]++;
    }
    for (int l = 0; l < n; ++l) {
        cout<<num[l]<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10, M = 1e6 + 10;
const int mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;

int t;

int main()
{
    int a, b, c;
    int flag = 1;
    cin >> a >> b >> c;
    if(a == b  && b == c)
        flag = 0;
    if(a != b && a != c && b != c)
        flag = 0;
    if(flag)
        puts("Yes");
    else
    {
        puts("No");
    }
    

    return 0;
}


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

int main () {
    int A, B, i; cin >> A >> B;
    bool ans = false;
    for (i = 0; i < max(A,B); i++) {
        if (abs(A - i) == abs(B - i)) {
            ans = true;
            break;
        }
    }
    if(ans == true) cout << i << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

int main()
{
  int n;
  cin>>n;
  int h[n+1];
  for(int i=1;i<=n;i++)
    cin>>h[i];
  int m[n+1];
  m[0]=0;
  m[1]=0;
  m[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++)
  {

      if(m[i-1]+abs(h[i]-h[i-1])>m[i-2]+abs(h[i]-h[i-2]))
        m[i]=m[i-2]+abs(h[i]-h[i-2]);
      else
         m[i]=m[i-1]+abs(h[i]-h[i-1]);
  }
  cout<<m[n];
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
int N,M,K,D;
int C[105][105],pw[105][10205],tmp1[105][105][105],tmp2[105][105][105],tmp3[105][105][105],tmp4[105][105][105],f[105][4][105][105];
int main(){
	scanf("%d%d%d%d",&N,&M,&K,&D);
	f[K][3][N][M]=1;
	for(int i=0;i<=101;i++){
		for(int j=*C[i]=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%D;
		for(int j=*pw[i]=1;j<=10201;j++)pw[i][j]=1ll*pw[i][j-1]*i%D;
	}
	for(int i=1;i<=K;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=M;k++){
				tmp1[i][j][k]=pw[K-i][j*k]*1ll*pw[i][j*(M-k)]%D;
				tmp2[i][j][k]=pw[K-i+1][j*k]*1ll*pw[i][j*(M-k)]%D;
			}
			for(int k=0;k<=N;k++){
				tmp3[i][j][k]=pw[K-i][j*k]*1ll*pw[i][j*(N-k)]%D;
				tmp4[i][j][k]=pw[K-i+1][j*k]*1ll*pw[i][j*(N-k)]%D;
			}
		}
	}
	for(int x=K;x;x--){
		for(int ty=4;ty--;){
			for(int i=0;i<=N;i++){
				for(int j=0,F;j<=M;j++)if(F=f[x][ty][i][j]){
					if(ty==3){
						for(int y=0;y<=i;y++)
							f[x][2][i-y][j]=(f[x][2][i-y][j]+1ll*F*(y&1?D-C[i][y]:C[i][y])%D*tmp1[x][y][j])%D;
					}
					if(ty==2){
						for(int y=0;y<=j;y++)
							f[x][1][i][j-y]=(f[x][1][i][j-y]+1ll*F*(y&1?D-C[j][y]:C[j][y])%D*tmp3[x][y][i])%D;
					}
					if(ty==1){
						for(int y=0;y<=i;y++)
							f[x][0][i-y][j]=(f[x][0][i-y][j]+1ll*F*C[i][y]%D*tmp2[x][y][j])%D;
					}
					if(ty==0){
						for(int y=0;y<=j;y++)
							f[x-1][3][i][j-y]=(f[x-1][3][i][j-y]+1ll*F*C[j][y]%D*tmp4[x][y][i])%D;
					}
				}
			}
		}
	}
	printf("%d\n",f[0][3][0][0]);
}

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

// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  for (ll i = 1; i <= 3500; i++) {
    for (ll j = 1; j <= 3500; j++) {
      if (4 * i * j - n * i - n * j == 0) continue;
      ll k = (n * i * j) / (4 * i * j - n * i - n * j);
      if ((n * i * j) % (4 * i * j - n * i - n * j) == 0 && k > 0) {
        cout << i << ' ' << j << ' ' << k << "\n";
        return 0;
      }
    }
  }
  return 0;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		
		int sum = 0;
		for (int i = 0; i < n - 1; i++) {
			sum += p[i];
		}
		sum += p[n - 1] / 2;

		pr.println(sum);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#ALDS1_2_C
n = int(input())
a_master = input()

#BubbleSort
a = [[i[0],i[1]] for i in a_master.split()]
for ni in range(n):
   for ii in range(n-1, ni, -1):
      if int(a[ii][1]) < int(a[ii-1][1]):
        a[ii], a[ii-1] = a[ii-1], a[ii]
b_ans = " ".join(["".join(i) for i in a])
print(b_ans)
print("Stable")
#SelectionSort
a = [[i[0],i[1]] for i in a_master.split()]
for ni in range(n):
  mini = ni
  for ii in range(ni,n):
    if int(a[ii][1]) < int(a[mini][1]):
      mini = ii
  a[ni], a[mini] = a[mini], a[ni]
s_ans = " ".join(["".join(i) for i in a])
print(s_ans)
if b_ans == s_ans:
  print("Stable")
else:
  print("Not stable")


Measured memory_bytes: 5608
def four_adjacent():
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	odd_num = 0
	mod_four_mum = 0
	for item in a:
		if item%2!=0:
			odd_num+=1
		if item%4==0:
			mod_four_mum+=1
	if mod_four_mum>=odd_num:
		print "Yes"
	elif odd_num-mod_four_mum==1:
		if n==odd_num+mod_four_mum:
			print "Yes"
		else:
			print "No"
	else:
		print "No"


if __name__ == "__main__":
	four_adjacent()

Measured memory_bytes: 11320
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,m=0;
  string s;
  map<string,int> c;
  cin>>n;
  while(n--){
    cin>>s;
    ++c[s];
  }
  cin>>n;
  while(n--){
    cin>>s;
    --c[s];
  }
  for(auto p:c)m=max(m,p.second);
  cout<<m;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long W, long a, long b) = Slice3<long>();
            if (a < b + W)
                WriteLine(Max(0, b - (a + W)));
            else
                WriteLine(a - (b + W));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27312
a, b, c, x, y = map(int, input().split())
cost = 0
if a + b > 2 * c:
    ma = max(x,y)
    nc = min(x, y)
    x -= nc
    y -= nc
    cost = min(ma * 2 * c, nc * 2 * c + x * a + y * b)
else:
    cost = a * x + b * y
print(cost)


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

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

    vector<long long> dp(W+1,0);

    for(int i=0; i<n; i++){
      int w, v;
      cin>>w>>v;
      for(int wa = W - w; wa>=0; wa--){
        dp[wa+w] = max(dp[wa+w], dp[wa]+v);
      }
      
    }

    long long maxi=0;
    for(int i=0; i<=W; i++) maxi = max(dp[i],maxi);
    cout<<maxi;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        long A = scanner.nextLong();
        long B = scanner.nextLong();

        if ((A + B) % 2 != 0) {
            System.out.println("IMPOSSIBLE");
            return;
        }

        System.out.println((A + B) / 2);
    }
}


Measured memory_bytes: 35764
n = (int)(input())
s = input().split(" ")
before= (int)(s[0])
count = 0
max = 0
flg = 0
for i in s:
  if(flg==0):
    flg=1
    continue
  k = (int)(i)
  if(before>=k):
    count+=1
  else:
    if(count>max):
      max = count
    count = 0
  before = k
if(count>max):
  max = count
print(max)

Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        var cost = b;
        if (a < 13)
        {
            if (a < 6)
            {
                cost = 0;
            }
            else
            {
                cost /= 2;
            }
        }
        Console.WriteLine(cost);
    }
}


Measured memory_bytes: 13268
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my %h;
$h{$_}++ for @a;
my (%k, %g);
my $sum = 0;
for my $key (keys %h) {
  $k{$key} = $h{$key} * ($h{$key} - 1) / 2;
  $sum += $k{$key};
  $g{$key} = ($h{$key} - 1) * ($h{$key} - 2) / 2;
}
for my $i (0..($n-1)) {
  say  $sum - $k{$a[$i]} + $g{$a[$i]};
}

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

int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
cout<<1<<endl;
  else if(a==b||b==c||a==c)
    cout<<2<<endl;
  else
    cout<<3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int N,A,B;
ll v[SIZE];
ll u[SIZE]; //小さい順

ll C[55][55];
const int MAX = 50;

void get_comb(){
	C[0][0] = 1LL;
	rep(i,1,MAX+1) rep(j,0,i+1) {
		C[i][j] += C[i-1][j];
		if(j>0) C[i][j] += C[i-1][j-1];
	}
}


int main()
{
	cin >> N >> A >> B;
	rep(i,0,N)cin >> v[i];
	rep(i,0,N)u[i] = v[i];
	sort(v,v+N,greater<ll>());
	sort(u,u+N);
	get_comb();
	double V = 0.0;
	rep(i,0,A) V += v[i];
	V /= A;
	cout.precision(20);
	cout << fixed << V << endl;
	if(v[0] != v[A-1]){
		int X = upper_bound(u,u+N,v[A-1]) - lower_bound(u,u+N,v[A-1]);
		int Y;
		rep(i,0,N){
			if(v[i] == v[A-1]){
				Y = A-i;break;
			}
		}
		//XCYがこたえ
		cout << C[X][Y] << endl;
	}else{
		int X = upper_bound(u,u+N,v[A-1]) - lower_bound(u,u+N,v[A-1]);
		ll ans = 0LL;
		rep(i,A,X+1){
			//XCiの和がこたえ
			if(i>B)break;
			ans += C[X][i];
		}
		cout << ans << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#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,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    cout << x/500*1000 + (x%500)/5*5 << endl;
    
    
}




Measured memory_bytes: 256
z=list(map(int,input().split()))
list.sort(z, reverse=True)
c=z[0]
b=z[1]
a=z[2]
x=(c-b)//2 + (c-a)//2

if((c-b)%2==1):
  if((c-a)%2==1):
    x+=1
  else:
    x+=2
elif((c-a)%2==1):
  x+=2
print(x)

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n;
	n=sc.nextInt();
        for(int i=0;i<n;i++){
            int x,y,b,p,sum=0;
            x=sc.nextInt();
            y=sc.nextInt();
            b=sc.nextInt();
            p=sc.nextInt();
            if(b>=5&&p>=2){
                sum=((x*b+y*p)*4)/5;
            }else if(b>=5&&p<2){
                sum=x*b+y*p;
                if(sum>((x*b+y*2)*4)/5){
                    sum=((x*b+y*2)*4)/5;
                }
            }else if(b<5&&p>=2){
                sum=x*b+y*p;
                if(sum>((x*5+y*p)*4)/5){
                    sum=((x*5+y*p)*4)/5;
                }
            }else{
                sum=x*b+y*p;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 31316
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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

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

using namespace std;


struct UnionFind {
    vector<int> rank, parent;

    UnionFind() {}

    UnionFind(int size) {
        rank.resize(size, 0);
        parent.resize(size, 0);
        for (int i = 0; i < size; ++i) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

    void link(int x, int y) {
        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

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

    void unite(int x, int y) {
        link(find(x), find(y));
    }

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

int main() {
    int n, k, l, p, q;
    cin >> n >> k >> l;
    UnionFind ro(n+1);
    UnionFind ra(n+1);
    rep(i, k){
        cin >> p >> q;
        ro.unite(p, q);
    }
    rep(i, l){
        cin >> p >> q;
        ra.unite(p, q);
    }
    vector<pair<int,int> > com(n);
    map<pair<int,int> ,int> s;
    rep(i, n){
        com[i].first = ro.find(i+1);
        com[i].second =  ra.find(i+1);
        s[com[i]]++;
    }
    for(int i = 0; i < n; i++){
        cout << s[com[i]] << " ";
    }printf("\n");
}



Measured memory_bytes: 16640
#include <stdio.h>

int main(void){
	int a, b, c;
	int i = 0;
	int count = 0;
	scanf("%d %d %d", &a, &b, &c);
	
	for(i = a; i <= b; i++){
		if(c % i == 0){
			count++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++) 
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    map<string,ll> mp;
    rep(i,N) {
        string w;
        cin>>w;
        sort(all(w));
        mp[w]++;
    }
    ll answer=0;
    for(auto p : mp) {
        ll a=p.se;
        answer+=a*(a-1)/2;
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    reps(i,1,n+1){
        if(i % 3==0) continue;
        else if(i % 5==0) continue;
        else ans += i;
    }

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

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

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

    vector<int> data(n);
    for (auto& i : data)
    {
        cin >> i;
    }

    int numOdd = 0;
    int numEven = 0;
    int numMultiple4 = 0;
    for (const auto& i : data)
    {
        if (i % 2 == 0)
            numEven++;
        else
            numOdd++;
        if (i % 4 == 0) numMultiple4++;
    }

    if (numMultiple4 >= (numOdd - data.size()%2))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;

#define INF 1234567890
#define N (int)(2e5 + 5)
const double pi = 3.14159265358979323846;
typedef unsigned long long ull;

void solve()
{
    ull n, k;
    cin >> n >> k;
    if(n == k) cout << 0;else
        if(n < k) cout << min(n, k - n);else
        {
            ull nr = n / k;
            n -= nr * k;
            cout << min(n, k - n);
        }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
//-----------------------
// author : xyqkoala
// time : 2020-08-03
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int res = 0;
	int l=0,r = n-1;
	while(l<r){
		while(l<r && s[l]=='R') l++;
		while(l<r && s[r]=='W') r--;
		if(l<r){
			swap(s[l],s[r]);
			res++;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3752
#include <stdio.h>

int main(void) {
  int H , W,i,j,k;

  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) {
      break;
    }
		for(i=1;i<H+1;i++){
      if(i%2==1){
        for(j=1;j<W+1;j++){
          if(j%2==1){
            printf("#");
          }
          else{
            printf(".");
          }
        }
        printf("\n");
      }
      else{
        for(k=1;k<W+1;k++){
          if(k%2==1){
            printf(".");
          }
          else{
            printf("#");
          }
        }
        printf("\n");
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2020
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
  stack<int> st;
  int r,l,k,sum;
  string str;
  while(cin >> str){
    if('0'<=str[0]&&str[0]<='9'){
      k=1,sum=0;
      for(int i=str.size()-1;i>=0;--i){
	sum=sum+k*(str[i]-'0');
	k=k*10;
      }
      st.push(sum);
    }else{
      r=st.top();
      st.pop();
      l=st.top();
      st.pop();
      if(str[0]=='+'){
	st.push(l+r);
      }else if(str[0]=='-'){
	st.push(l-r);
      }else if(str[0]=='*'){
	st.push(l*r);
      }
    }
  }
  cout<<st.top()<<endl;

  return 0;
}


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

int main() {
  int a,b,L,c,d,R;

  cin >> a >> b >> c >>d;

  L = a+b;
  R = c+d;

  if(L>R){
      cout << "Left" << endl;
  }else if(L<R){
      cout << "Right" << endl;
  }else{
      cout << "Balanced" << endl;
  }

}


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

class Main {
  public static void main(String [] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    for(;;) {
      int n = sc.nextInt();
      if(n == 0) break;
      int [] as = new int[n];
      for(int i = 0; i < n; i++) {
        as[i] = sc.nextInt();
      }
      double ave = 0;
      for(int a : as) { ave += a; }
      ave /= n;
      int c = 0;
      for(int a : as) { if(a <= ave) c++; }
      System.out.println(c);
    }
  }
}



Measured memory_bytes: 59288
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll m,cnt=0,sum=0,d,c;
  cin >> m;
  for(int i=0; i<m; i++) {
    cin >> d >> c;
    sum+=d*c;
    cnt+=c;
  }
  cout << (sum-1)/9+cnt-1 << endl;
}

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

const ll mod = 1000000007;
const int INF = 1001001001;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n; i++) cin >> a[i];
	ll ans = 0;
	for(int i = 0; i < n-1; i++){
		if(a[i] > a[i+1]){
			ans += a[i] - a[i+1];
			a[i+1] = a[i];
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 3972
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

static double get_concentration(int32_t water, int32_t sugar)
{
	return water + sugar == 0 ? 0.0 : 1.0 * sugar / (water + sugar);
}

int main()
{
	int32_t A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	double _max = 0.0;
	int32_t max_total = 0, max_sugar = 0;
	for (int32_t a = 0; a <= F; a += 100 * A) {
		for (int32_t b = 0; a + b <= F; b += 100 * B) {
			for (int32_t c = 0; a + b + c <= F; c += C) {
				for (int32_t d = 0; a + b + c + d <= F; d += D) {
					if ((a + b) / 100 * E < c + d)
						continue;
					double concentration = get_concentration(a + b, c + d);
					if (_max < concentration) {
						_max = concentration;
						max_total = a + b + c + d;
						max_sugar = c + d;
					}
				}
			}
		}
	}
	if (max_sugar == 0)
		max_total = 100 * A;

	cout << max_total << " " << max_sugar << endl;

	return 0;
}

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

int main(){
	const double PI=3.14159265358979;
	int x,y;
	double theta=0;
	double sum_x=0;
	double sum_y=0;
	char c;
	
	while(std::cin >> x >> c >> y){
		sum_y += x * cos(theta * PI / 180);
		sum_x += x * sin(theta * PI / 180);
		theta += y;
	}
	
	std::cout << (int)sum_x << std::endl;
	std::cout << (int)sum_y << std::endl;

}

Measured memory_bytes: 1164
n=int(input())
a=list(map(int,input().split()))
r=set()
free=0
for x in a:
    y=x//400
    if y>=8:
        free+=1
        y=8
    r.add(y)
len_r=len(r)
if len_r==1 and free>0:
    print(1,free)
elif len_r>1 and free>0:
    print(len_r-1,len_r-1+free)
else:
    print(len_r,len_r)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if ((w | h) == 0) break;
			long[][] path = new long[h][w];
			int n = sc.nextInt();
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				path[y][x] = -1;
			}
			
			for (int i = 0; i < h; i++) {
				if (path[i][0] == -1) break;
				path[i][0] = 1;
			}
			for (int i = 0; i < w; i++) {
				if (path[0][i] == -1) break;
				path[0][i] = 1;
			}
			for (int i = 1; i < h; i++) {
				for (int j = 1; j < w; j++) {
					if (path[i][j] == -1) continue;
					long a = path[i - 1][j] == -1 ? 0 : path[i - 1][j];
					long b = path[i][j - 1] == -1 ? 0 : path[i][j - 1];
					path[i][j] += a + b;
				}
			}
//			for (int i = 0; i < h; i++) {
//				for (int j = 0; j < w; j++) {
//					System.out.printf("%12d ", path[i][j]);
//				}
//				System.out.println();
//			}
			System.out.println(path[h - 1][w - 1]);
		}
		
	}
	
}

Measured memory_bytes: 11000
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int ret = 1;
    int used = 1;
    while (true) {
        used += (used + k - 1) / k;
        if (used > n)break;
        ret++;
    }

    cout << ret << endl;
    return 0;
}


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

    if temp!=1:
        arr.append(temp)

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

    return set(arr)

import math
N=int(input())
A=list(map(int,input().split()))
ans=['pairwise coprime','setwise coprime','not coprime']
k=0
s=factorization(A[0])
for a in A[1:]:
    tmp=factorization(a)-{1}
    if s&tmp==set():
        s|=tmp
    else:
        k=-1
        break
if k==-1:
    g=A[0]
    for a in A[1:]:
        g=math.gcd(g,a)
    if g==1:
        k=1
    else:
        k=2
print(ans[k])

Measured memory_bytes: 213220
package main

import(
    "fmt"
)

func main(){
    var message string
    fmt.Scan(&message)

    for i := 0; i < len(message); i++ {
        c := message[i]
        if c >= 'a' && c <= 'z' {
            c = c + 1
            if c > 'z' {
                c = c - 26
            }
        }
        fmt.Printf("%c", c)
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		int count = 0;
		while(isAllEven(a)) {
		    count++;
		    for(int i = 0;i < n;i++) a[i] /= 2;
		}

		System.out.println(count);
    }

    private static boolean isAllEven(int[] a) {
        for(int i = 0;i < a.length;i++) {
            if(a[i] % 2 == 1) return false;
        }

        return true;
    }

}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A < 10 and B < 10:
        print(A*B)
    else:
        print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main(void){
  int X, Y;
  int price = 0;
  cin >> X >> Y;
  switch(X){
    case 1:
      price += 300000;
      break;
    case 2:
      price += 200000;
      break;
    case 3:
      price += 100000;
      break;
  }
  switch(Y){
    case 1:
      price += 300000;
      break;
    case 2:
      price += 200000;
      break;
    case 3:
      price += 100000;
      break;
  }
  if(X == 1 && Y == 1){
    price += 400000;
  }
  cout << price << endl;
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    LL n,m;
    cin >> n >> m;
    LL sum=0;
    REP(i,m){
        LL tmp;
        cin >> tmp;
        sum+=tmp;
    }
    if(sum>n) cout << -1;
    else cout << n-sum;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;



int main(){
  int x;
  cin>>x;
  if(x>=30){
    cout<<"Yes";
  }else{
    cout<<"No";
  }



}


Measured memory_bytes: 3632
#include <stdio.h>

int main () {
	char input[105][105];
	int h, w;
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", input[i]);
	}
	
	for (int i = 0; i < h; i++) {
		printf("%s\n", input[i]);
		printf("%s\n", input[i]);
	}
	return 0;
}

Measured memory_bytes: 1652
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var allSet = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToList();

            if (allSet[0] == allSet[1])
                Console.WriteLine(allSet[2]);
            else if (allSet[2] == allSet[1])
                Console.WriteLine(allSet[0]);
            else
                Console.WriteLine(allSet[1]);

        }
    }
}

Measured memory_bytes: 13268