akhauriyash/Code-Regression huggingface dataset:
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int INF = 1e9;
int fast_pow(int x, int y, int p);
int n;
int a[101];
int dp[101][100001];

void solve() {
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			dp[i][j]+=dp[i][j-1];
			dp[i][j]%=MOD;
		}
		for(int j=0;j<=k;j++){
			if(j<=a[i]){
				dp[i+1][j]=dp[i][j];
			}else{
				dp[i+1][j]=(dp[i][j]-dp[i][j-a[i]-1]+MOD)%MOD;
			}
		}
	}
	cout<<dp[n][k];

}

int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
//        cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 82500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 200100
struct BIT{
	ll bit[MAX_N+1];
	void add(int i,ll x){
		i++;
		while(i<=MAX_N){
			bit[i]+=x;
			i+=i&-i;
		}
		return;
	}
	ll sum(int i){
		i++;
		ll res=0;
		while(i>0){
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
	ll sum(int l,int r){ // [l,r]
		if(l==0)return sum(r);
		else return sum(r)-sum(l-1);
	}
}bit;
int N;
ll K;
ll a[200100];
int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> a[i];
		a[i]-=K;
	}
	vector<P> vec;
	vec.pb(P(0ll,0));
	for(int i=1;i<=N;i++){
		a[i]+=a[i-1];
		vec.pb(P(a[i],i));
	}
	sort(all(vec),greater<P>());
	ll ans = 0ll;
	for(int i=0;i<vec.size();i++){
		int idx = vec[i].sec;
		ll val = vec[i].fi;
		bit.add(idx,1ll);
		ans += bit.sum(idx+1,N);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    if(a+b < c*2) {
        // 全て個別に買った方がとく
        cout << a*x + b*y << endl;
        return 0;
    } else {
        // とりあえずa,bどちらかの必要文揃うまでは、c２枚がとく
        ll ans = min(x,y) * (2*c);
        if(x==y) {
            cout << ans << endl;
            return 0;
        }
        if(x > y) {
            if(a < 2*c) {
                ans += (x-y) * a;
                cout << ans << endl;
                return 0;
            } else {
                ans += (x-y) * (2*c);
                cout << ans << endl;
                return 0;
            }
        } else {
            if(b < 2*c) {
                ans += (y-x) * b;
                cout << ans << endl;
                return 0;
            } else {
                ans += (y-x) * (2*c);
                cout << ans << endl;
                return 0;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int H = NextInt(), N = NextInt();
        int[] dp = Enumerable.Range(0, H + 10).Select(v => INF).ToArray();
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            int A = NextInt(), B = NextInt();
            for (int hp = 0; hp <= H; hp++)
            {
                if (dp[hp] != INF)
                {
                    int nx_hp = Math.Min(hp + A, H);
                    dp[nx_hp] = Math.Min(dp[nx_hp], dp[hp] + B);
                }
            }
        }
        Console.WriteLine(dp[H]);
    }

}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13524
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], s;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s = s ^ a[i];
	}
	for (int i = 0; i < n; i++) {
		int tmp = s ^ a[i];
		cout << tmp << " ";
	}
	cout << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 4420
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> suuti = new ArrayList<Integer>();
		
		int n = sc.nextInt();
		int a;
		
		for(int i = 0; i < n; i++){
			suuti.add(sc.nextInt());
			
		}
        
		Collections.reverse(suuti);
		
		for(a = 0; a < n; a++){
			System.out.print(suuti.get(a));
			if(a < n - 1){
				System.out.print(" ");
			}
		}
        
		System.out.println("");
		
        }

	}

Measured memory_bytes: 26344
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int inum = n/100;
        String str = ""+inum+inum+inum;
        int xxx = Integer.parseInt(str);
        if(xxx < n) xxx += 111;
        System.out.println(xxx);
    }
}

Measured memory_bytes: 21844
/*
AizuOnline A2206
Title:Compile
*/
#include <stdio.h>
#include <string.h>
#define WIDTH 6
#define HEIGHT 12
//Global data section
int  t;
char block[HEIGHT][WIDTH+1];
char area[HEIGHT][WIDTH+1];
int  hist[HEIGHT*WIDTH];
int rensa;
int max_rin;
// const
char any_color[]="RGBYP";
//
extern int paint(int,int,char,int);
void shift_empty()
{
  int i,j1,j2,k;
  char buf[HEIGHT];

  for(i=0;i<WIDTH;i++)
    {
      for(j1=j2=HEIGHT-1;j2>=0;j2--)
	{
	  if(block[j2][i] != '.')
	    {
	      block[j1][i]=block[j2][i];
	      j1--;
	    }
	}
      if(j1>0)
	for(k=j1;k>=0;k--)
	  block[k][i]='.';	
    }
}
void erase_block()
{
  int i,j,c;

  for(i=0;i<HEIGHT;i++)
    for(j=0;j<WIDTH;j++)
      {
	if(hist[area[i][j]]>3)
	  block[i][j]='.';
      }

}
void erasable_ojama()
{
  int i,j,c;

  for(i=0;i<HEIGHT;i++)
    for(j=0;j<WIDTH;j++)
      {
	if(block[i][j] != 'O')
	  continue;
	if(i>0 && hist[area[i-1][j]]>3)
	  block[i][j]='.';
	if(i<HEIGHT-1 && hist[area[i+1][j]]>3)
	  block[i][j]='.';
	if(j>0 && hist[area[i][j-1]]>3)
	  block[i][j]='.';
	if(j<WIDTH-1 && hist[area[i][j+1]]>3)
	  block[i][j]='.';
      }
}
void make_hist()
{
 int i,j;
 for(i=0;i<HEIGHT*WIDTH;i++)
   hist[i]=0;
 for(i=0;i<HEIGHT;i++)
   for(j=0;j<WIDTH;j++)
     if(area[i][j])
       hist[area[i][j]]++;
}
int chk_rinsetu()
{
  int y,x,val,col,maxhist,i;

  x=0;y=0;val=0;
  while(col=search_next(&y,&x))
    {
      //printf("SN %d %d \n",y,x);
      val++;
      paint(y,x,col,val);
    }
  make_hist();
  maxhist=0;
 for(i=0;i<HEIGHT*WIDTH;i++)
   if(hist[i]>maxhist)
     maxhist=hist[i];
 return(maxhist);
}
void clear_area()
{
 int i,j;
  for(i=0;i<HEIGHT;i++)
    for(j=0;j<WIDTH;j++)
      area[i][j]=0;
}


int search_next(int *sy,int *sx)
{
  int i,j;
  i=*sy;j=*sx;goto LOOP;

  for(i=0;i<HEIGHT;i++)
    for(j=0;j<WIDTH;j++)
      {
      LOOP:
	if(area[i][j]==0 && strchr(any_color,block[i][j]))
	  {
	    *sy=i;*sx=j;return(block[i][j]);
	  }
      }
  return(0);
}
int paint(int y,int x,char col,int val)
{
  if(area[y][x]==0)
    {
      area[y][x] = val;
      if(y < HEIGHT-1 && block[y+1][x]==col)
	paint(y+1,x,col,val);
      if(y > 0 && block[y-1][x]==col)
	paint(y-1,x,col,val);
      if(x < WIDTH-1 && block[y][x+1]==col)
	paint(y,x+1,col,val);
      if(x > 0 && block[y][x-1]==col)
	paint(y,x-1,col,val);
    }

}
void count_rensa()
{
  //int i;

   rensa=0;
   while(1)
     //for(i=0;i<3;i++)
    {
      clear_area();	
      max_rin=chk_rinsetu();
      //printf("RINSETU %d\n",max_rin);
      if(max_rin > 3)
	rensa++;
      else
	goto EXIT;
 
	erasable_ojama();
	erase_block();
	shift_empty();
#ifdef DEBUG
	show();
#endif      
    }
  
 EXIT:
    ;
    //show();        
}
// debug write
show()
{
  int i,j;
  for(i=0;i<HEIGHT;i++)
    {
      for(j=0;j<WIDTH;j++)
	printf("%c",block[i][j]);
      printf("|  ");
      for(j=0;j<WIDTH;j++)
   	printf("%02d",area[i][j]);
      printf("\n");
    }
  printf("------   ------------\n");
}
main()
{
  int i,j,ret;

  while(EOF!=scanf("%d",&t))
    for(i=0;i<t;i++)
      {
	for(j=0;j<HEIGHT;j++)
	  scanf("%s",&(block[j][0]));

	count_rensa();
	printf("%d\n",rensa);

      }
return(0);
}

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

int main() {
	int N;
	cin >> N;
	if (N % 1000 == 0) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 1000 - N % 1000;
	cout << ans << endl;
	return 0;

}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

struct Dice {
	int num[6]; // top, bottom, front, back, right, left;
	static const int rd[3][4]; //?????¢??????
	
	Dice(int top, int bottom, int front, int back, int right, int left) {
		num[0] = top;		num[1] = bottom;
		num[2] = front;	num[3] = back;
		num[4] = right;	num[5] = left;
	}
	Dice(const Dice &d) {
		copy(d.num, d.num + 6, num);
	}
	
	bool operator == (const Dice &d) const {
		REP(i, 6) if (num[i] != d.num[i]) return false;
		return true;
	}
	
	bool operator < (const Dice &d) const {
		REP(i, 6) if (num[i] != d.num[i]) {
			return num[i] < d.num[i];
		}
		return false;
	}
	
	void X(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(0); }
	void Y(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(1); }
	void Z(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(2); }
	
	void rotate(int p) {
		int tmp = num[rd[p][0]];
		
		REP(i, 3) num[rd[p][i]] = num[rd[p][i + 1]];
		num[rd[p][3]] = tmp;
	}
	
	Dice unique() {
		Dice now = *this;
		
		Dice mi(*this);
		
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					if (now < mi) mi = now;
					now.X();
				}
				now.Y();
			}
			now.Z();
		}
		return mi;
	}
	
	void print() {
		REP(i, 6) printf("%d%c", num[i], i == 5 ? '\n' : ' ');
	}
};

const int Dice::rd[3][4] = {
	{2,1,3,0}, // x
	{2,4,3,5}, // y
	{0,5,1,4}, // z
};


Dice input() {
	int num[6];
	REP(i, 6) scanf("%d", num + i);
	return Dice(num[0], num[5], num[1], num[4], num[2], num[3]);
}

int main() {
	int n; cin >> n;
	
	set<Dice> ss;
	REP(i, n) ss.insert(input().unique());
	puts(ss.size() == n ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
struct Point{int x, y;};
main(){
  int n, t, d, minx, miny, maxx, maxy;
  Point P[200];
  while( cin >> n && n ){
    minx = miny = maxx = maxy = P[0].x = P[0].y = 0;
    for ( int i = 1; i < n; i++ ){
      cin >> t >> d;
      P[i].x = P[t].x + dx[d];
      P[i].y = P[t].y + dy[d];
      minx = min(minx, P[i].x);
      miny = min(miny, P[i].y);
      maxx = max(maxx, P[i].x);
      maxy = max(maxy, P[i].y);
    }
    cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int main()
{
	int n;
	int x[105],p[110] = {0};
	int num1;
	int num = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
//	for(int i = 0; i < n; i++){
//
//		if(x[i] >= num)		num = x[i];
//	}
	for(int i = 0; i < 105; i++){
		for(int j = 0; j < n; j++){
			if(x[j] > i){
				p[i] += (x[j] - i) * (x[j] - i);
			}
			else{
				p[i] += (i - x[j]) * (i - x[j]);
			}
		}
	}
	num1 = p[0];
	for(int i = 0; i < 105; i++){
		if(p[i] < num1){
			num1 = p[i];
		}
	}
	cout << num1 << endl;
	return 0;
	
		
}

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

int main() {
	int x, y;
	int xg, yg;
	scanf("%d %d", &x, &y);

	if (x == 2) {
		xg = 1;
	} else if (x == 4 || x == 6 || x == 9 || x == 11) {
		xg = 2;
	} else {
		xg = 3;
	}

	if (y == 2) {
		yg = 1;
	} else if (y == 4 || y == 6 || y == 9 || y == 11) {
		yg = 2;
	} else {
		yg = 3;
	}

	if (xg == yg) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 764
N,C,K=map(int,input().split())
T=[]
U=[]
for i in range(N):
  T.append(int(input()))
  U.append(T[i]+K)
T.sort()
U.sort()

#print("T:",T)
#print("U:",U)

j=0
k=0
p=[]  #居る人
bus=0
t=0

while k<N:
  #print(t,"j=",j,"k=",k)
  if j<N:
    if T[j]<=U[k]:
      #print("  T[j]",T[j],"<=U[k]",U[k])
      p.append(j)
      t=T[j]
      j +=1
      #print(t,"人数+1して",len(p))
      if len(p)>=C:
        #print(p,"人数max")
        k=max(p)+1
        p=[]
        #print(t,"バス発車。人数は",len(p),"k=",k)
        bus +=1
    else:
      #print("  T[j]",T[j],">U[k]",U[k])
      t=U[k]
      k=max(p)+1
      #print(p,"時間max")
      p=[]
      #print(t,len(p),"バス発車")
      bus +=1
  else:
    t=U[k]
    p=[]
    #print(t,len(p),"時間max,最終バス発車")
    bus +=1
    k =N
    
print(bus)

Measured memory_bytes: 11444
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(U == S){
        cout << (A-1) << " " << B << endl;
    }else{
        cout << A << " " << (B-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
// #define modd 2019

#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>

#include <cassert>
// #include <algorithm>
#include <functional>
using namespace std;

int euk(int a, int b){
    if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
//   printf("最大公約数 = %d\n", b);
 
  return b;

}

int main(){
  int a, b;
  cin >> a >> b;
  int bb = max(a,b);
  int aa = min(a,b);
  if((bb-aa)%2 == 0){
    cout << aa + (bb-aa)/2;
  }
  else{
    cout << "IMPOSSIBLE";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int M = 1e9 + 7;
int n;
int memo[100001][2] = {0};

int step(const vector<int>& a, int i = 0)
{
    if(i >  n) return 0;
    if(i == n) return 1;
    if(a[i] == 1) return 0;
    if(memo[i+1][0] == 0){
        memo[i+1][0] = 1;
        memo[i+1][1] = step(a, i+1);
    }
    if(memo[i+2][0] == 0){
        memo[i+2][0] = 1;
        memo[i+2][1] = step(a, i+2);
    }
    return (memo[i+1][1]%M + memo[i+2][1]%M)%M;
}
int main()
{
    int m, k;
    cin >> n >> m;
    vector<int> a(n, 0);
    for(int i = 0; i < m; i++){
        scanf("%d", &k);
        a[k] = 1;
    }
    cout << step(a) << endl;
    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c;
    if (a > b) { 
        d = b;
        b = a; 
        a = d;
    }
    if (b > c) { 
        d = c; 
        c = b; 
        b = d;
    }
    if (a > b) { 
        d = b; 
        b = a; 
        a = d;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw";
        return 0;

    }

    if(a==1&&b!=1){

        cout<<"Alice";
        return 0;

    }
    if(b==1&&a!=1){

        cout<<"Bob";
        return 0;

    }
    if(a>b){
        cout<<"Alice";
        return 0;


    } else

        cout<<"Bob";


}

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


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

    int k;  cin >> k;
    bool flag=true;

    if(k%2==0 || k%5==0){
        flag = false;
    }

    vector<int> x(k+1,0);
    double ans=1;
    int mod=7%k;
    while(mod!=0 && flag){
        int tmp=mod*10+7;
        mod=tmp%k;
        ans++;
        if(x[mod]==1){
            flag=false;
        }else{
            x[mod]=1;
        }
    }

    if(!flag){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }




    return 0;
}



Measured memory_bytes: 7072
#include<set>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
   int tot,eac;
   cin>>eac>>tot;
   eac--;
   int n=1;
   int ans=0;
   while(n<tot)
   {
    ans++;
    n=n+eac;
   }
   cout<<ans;
}

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

lucas_memo = {}
def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        if n-1 in lucas_memo:
            ln1 = lucas_memo[n-1]
        else:
            ln1 = lucas(n-1)
            lucas_memo[n-1] = ln1
        if n-2 in lucas_memo:
            ln2 = lucas_memo[n-2]
        else:
            ln2 = lucas(n-2)
            lucas_memo[n-2] = ln2
        return ln1 + ln2

print(lucas(N))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

char t[303][303];

int c[303][303];

int main() {
    int N;
    scanf("%d", &N);
    forn(i, 0, N) {
        forn(j, 0, N) {
            scanf(" %c", &t[i][j]);
        }
    }
    ll ans = 0;
    forn(B, 0, N) {
        bool good = true;
        forn(i, 0, N) {
            for (int j = B, x = 0; x < N; (j += 1) %= N, x++) {
                if (t[i][j] != t[x][(i + B) % N]) {
                    good = false;
                }
            }
        }
        ans += good;
    }
    printf("%llu\n", ans * N);
    return 0;
}



Measured memory_bytes: 384
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pii pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    int a[N];
	void main()
	{
		int n=qread(),wt=qread();fo(i,1,n) a[qread()&1]++;
		if(a[0]==n)
		{
			if(!wt) write(bin(n));
			else write(0);
		} else write(bin(n-1));
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
template<typename T>
struct BellmanFord{
  struct edge{
    int u,v;
    T w;
    edge(){}
    edge(int u,int v,T w):u(u),v(v),w(w){}
  };

  int n;
  vector< vector<int> > G;
  vector<int> used,reach;
  BellmanFord(int n):n(n),G(n),used(n,0),reach(n,0){}

  vector<edge> es;
  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
    G[u].emplace_back(v);
  }

  void dfs(int v){
    if(used[v]) return;
    used[v]=1;
    for(int u:G[v]) dfs(u);
  }

  T build(int from,int to,int &neg_loop){
    for(int i=0;i<n;i++){
      fill(used.begin(),used.end(),0);
      dfs(i);
      reach[i]=used[to];
    }
    const T INF = numeric_limits<T>::max();
    vector<T> ds(n,INF);
    ds[from]=0;
    for(int j=0;j<n;j++){
      bool update=0;
      for(auto e:es){
        if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
        if(ds[e.v]>ds[e.u]+e.w){
          ds[e.v]=ds[e.u]+e.w;
          update=1;
        }
      }
      if(!update) break;
      if(j==n-1){
        neg_loop=1;
        return INF;
      }
    }
    neg_loop=0;
    return ds[to];
  }

};
signed main(){
  int n,m,p;
  cin>>n>>m>>p;
  BellmanFord<int> G(n);
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G.add_edge(a,b,p-c);
  }
  int neg_loop;
  int res=G.build(0,n-1,neg_loop);
  if(neg_loop){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max(-res,0)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int array[1000][1000]={},r,c;
  int i,j;
  
  scanf("%d%d",&r,&c);
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&array[i][j]);
      array[i][c]+=array[i][j];
    }
  }

  for(i=0;i<r+1;i++){
    for(j=0;j<c+1;j++){
      if(j!=c) printf("%d ",array[i][j]);
      else printf("%d",array[i][j]);
      if(i!=r) array[r][j]+=array[i][j];
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 5704
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

int weight[101],value[101];
int dp[101][10001];

int main(){

  long ii,jj,kk,ww;
  vector<int> ret;

  int n,W;


  //cout << "input start" << endl;
  
  cin >> n >> W;

  for(ii=0;ii<n;ii++){
    cin >> value[ii] >> weight[ii];
  }

  //cout << "input end" << endl;

  for(ww=0;ww<W;ww++){
    dp[0][ww] = 0;
  }

  for(ii=0;ii<n;ii++){
    //cout << ii << endl;
    for(ww=0;ww<=W;ww++){
      if(ww - weight[ii] >= 0){
        dp[ii+1][ww] = max(dp[ii][ww-weight[ii]] + value[ii],dp[ii][ww]);
        //cout << "dp:ww" << ww <<":"<< dp[ii+1][ww] << endl;
        
      }
      else{
        dp[ii+1][ww] = dp[ii][ww];
      }
    }
    //cout << "-------------------" << endl;
    //for(ww=0;ww<=W;ww++){
    //  for(jj=0;jj<=n;jj++){
    //    cout << dp[jj][ww] << "\t";
    //  }
    //  cout << endl;
    //}
    //cout << "------------------" << endl;
  }

  cout << dp[n][W] << endl;
  
  return 0;
}



Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int A,B,M;cin>>A>>B>>M;
	int a[A],b[B];int s=inf,t=inf;
	rep(i,0,A){ cin>>a[i]; s=min(s,a[i]); }
	rep(i,0,B){ cin>>b[i]; t=min(t,b[i]); }
	int ans=s+t;
	int x,y,c;
	rep(i,0,M){
		cin>>x>>y>>c; x--;y--;
		ans = min(ans,a[x]+b[y]-c);
	}cout<<ans<<endl;
}

Measured memory_bytes: 1024
from math import ceil
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = 0
for x, y in zip(a, b):
    if y > x:
        c += ceil((y-x)/2)

if sum(b)-sum(a)>=0 and sum(b)-sum(a)>=c:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    long long A[n], L=0, R=2000000000, t;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    while (R - L > 1)
    {
        t = (L+R) / 2;
        long long K=0;
        for (int i = 0; i < n; i++)
        {
            K += (A[i]-1) / t;
        }
        if (K <= k)
        {
            R = t;
        }
        else
        {
            L = t;
        }
    }
    cout << R;
    return 0;
}


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

int main (){
	char s[111];
	int i,j,k,l;
	while(scanf("%s",s)!=EOF){
		l=strlen(s);
		for(i=0;i<l;i++) if(s[i]=='C'){j=i;break;} 
							else j=l;		
		for(i=l-1;i>0;i--) if(s[i]=='F'){k=i;break;}
							else k=0;
	//	printf("%d %d",j,k);
		if(j<k) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    edge = [[] for _ in range(N)]
    for _ in range(M):
        a,b = MI_()
        edge[a].append(b)
        edge[b].append(a)
    path = deque([0,edge[0][0]])
    in_path = [False]*N
    in_path[0] = True
    in_path[edge[0][0]] = True
    while len(path) < N:
        added = False
        for to in edge[path[0]]:
            if not in_path[to]:
                path.appendleft(to)
                added=True
                in_path[to]=True
                break
        if added:
            continue
        for to in edge[path[-1]]:
            if not in_path[to]:
                path.append(to)
                in_path[to]=True
                added=True
                break
        if not added:
            break
    print(len(path))
    print(*[p+1 for p in path])
if __name__ == '__main__':
    main()

Measured memory_bytes: 30848
#![allow(non_snake_case)]

use proconio::{input, marker::Usize1, fastout};
use superslice::*;

fn dfs(
  v: usize,
  dp: &mut Vec<usize>,
  hasVisited: &mut Vec<bool>,
  res: &mut Vec<usize>,
  graph: &Vec<Vec<usize>>,
  a: &[usize],
) {
  hasVisited[v] = true;
  let t = dp.lower_bound(&a[v]);
  let snapshot = dp[t];
  dp[t] = a[v];
  res[v] = dp.lower_bound(&std::usize::MAX);
  for &w in &graph[v] {
    if hasVisited[w] {
      continue;
    }
    dfs(w, dp, hasVisited, res, graph, a);
  }
  dp[t] = snapshot;
}

#[fastout]
fn main() {
  input! {
    N: usize,
    a: [usize; N],
    edges: [(Usize1, Usize1); N-1],
  }
  let mut graph = vec![vec![0; 0]; N];
  for &(u, v) in &edges {
    graph[u].push(v);
    graph[v].push(u);
  }
  let mut dp = vec![std::usize::MAX; N];
  let mut hasVisited = vec![false; N];
  let mut res = vec![0; N];
  dfs(0, &mut dp, &mut hasVisited, &mut res, &graph, &a);
  for r in res {
    println!("{}", r);
  }
}


Measured memory_bytes: 41304
//2714　加藤聖弥 問2
import java.util.Scanner;
public class Main{
    int [] seki={0,6000,4000,3000,2000};
    int t;
    int n;
    int k;
    int kin;
    
    public void solve(){
        Scanner sc=new Scanner(System.in);
        k=0;
        while(k<4){
            t=sc.nextInt();
            n=sc.nextInt();
        kin =seki[t]*n;
        System.out.println(kin);
        k+=1;
        }
    }
    
    public static void main(String[] args){
        Main obj=new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17176
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

ll a[N],sa[N];

int main() {
	ll n,m;cin>>n>>m;
	rep(i,n) cin>>a[i];
	sa[0]=a[0];
	rep(i,n-1) sa[i+1]=sa[i]+a[i+1];
	map<ll,ll> mp;
	rep(i,n) mp[sa[i]%m]++;
	ll ans=mp[0];
	rep(i,n-1){
		mp[sa[i]%m]--;
		ans+=mp[sa[i]%m];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
ll h[100010];
bool dp[100010][2]={};

int main(){_;
  int n;cin>>n;
  REP(i,n)cin>>h[i];
  dp[0][0]=dp[0][1]=true;
  for(int i=1;i<n;i++){
    if(dp[i-1][0]){
      dp[i][0] |= h[i-1]<=h[i];
      dp[i][1] |= h[i-1]<=h[i]-1;
    }
    if(dp[i-1][1]){
      dp[i][0] |= h[i-1]-1<=h[i];
      dp[i][1] |= h[i-1]<=h[i];
    }
  }
  if(dp[n-1][0]||dp[n-1][1]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

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



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String s = (a.substring(0,1) + b.substring(0,1) + c.substring(0,1));
	    System.out.println(s.toUpperCase());
	}

}

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

using namespace std;

int main() 
{
    int n, m;
    scanf("%d", &n);
    
    set<int> s;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &m);
        s.insert(m);
    }
    
    set<int>::iterator it;
    for(it = s.begin(); it != --s.end(); it++)
        printf("%d ", *it);
    printf("%d\n", *it);
    
    return 0;
}


Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  int cnt=0;
  for(int i=0; i<n; i++){
    cin >> m.at(i);
    x -= m.at(i);
  }
  sort(m.begin(),m.end());
  cnt = x/m.at(0);
  cout << cnt+n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    c = Counter(S)
    for x in ('AC', 'WA', 'TLE', 'RE'):
        print(f'{x} x {c[x]}')
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 16608
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  int64_t res = 0;
  for (int64_t n = 2, end = sqrt(N); n <= end; ++n) {
    if (N < n) break;
    if (N % n) continue;
    int64_t d = 0;
    while (N % n == 0) {
      ++d;
      N /= n;
    }
    for (int64_t i = 1, end = d; i <= end; ++i) {
      if (d - i >= 0) {
        ++res;
        d -= i;
      } else {
        break;
      }
    }
  }
  if (N > 1) ++res;
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3584
a = input()
a = list(a)
x = int(a[0])
y = int(a[1])
z = int(a[2])

if x + y + z == 0:
    print('0')
elif x + y + z == 1:
    print('1')
elif x + y + z == 2:
    print('2')
elif x + y + z == 3:
    print('3')


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

int main(){
    int N;
    cin >> N;
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    rep(i,N)cin>>t[i]>>x[i]>>y[i];

    int now_x = 0;
    int now_y = 0;
    int now_t = 0;

    int dis_t = 0;
    int dis_x = 0;
    int dis_y = 0;

    for(int i=0; i<N; i++){
        dis_t = t[i] - now_t;
        dis_x = abs(x[i] - now_x);
        dis_y = abs(y[i] - now_y);
        if(dis_x + dis_y > dis_t){
            cout << "No" << endl;
            return 0;
        }

        if((dis_t - dis_x + dis_y) % 2 == 1 ){
            cout << "No" << endl;
            return 0;
        }

        now_x = x[i];
        now_y = y[i];
        now_t = t[i];
    }

    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 4188
from collections import defaultdict

H, W, M = map(int, input().split())

row_bom_cnt = defaultdict(int)
col_bom_cnt = defaultdict(int)
row_max = 0
col_max = 0

boms = [list(map(int, input().split())) for _ in range(M)]

for rm, cm in boms:
    row_bom_cnt[rm] += 1
    col_bom_cnt[cm] += 1

    row_max = max(row_max, row_bom_cnt[rm])
    col_max = max(col_max, col_bom_cnt[cm])


target_row = set()
for r, val in row_bom_cnt.items():
    if val == row_max:
        target_row.add(r)

target_col = set()
for c, val in col_bom_cnt.items():
    if val == col_max:
        target_col.add(c)


cnt = 0
for rm, cm in boms:
    if rm in target_row and cm in target_col:
        cnt += 1

if len(target_row) * len(target_col) == cnt:
    print(row_max + col_max - 1)
else:
    print(row_max + col_max)


Measured memory_bytes: 107788
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXK = -1;
const int MAXN = 1 << MAXK;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 1.01e9;

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int a, b, c;
	while (cin >> a >> b >> c) {
		set<pair<pair<int, int>, int> > st;
		int ans = 0;
		while (1) {
			auto o = make_pair(make_pair(a, b), c);
			if (st.find(o) != st.end()) {
				ans = -1;
				break;
			}
			st.insert(o);
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
			ans++;
			int na = 0, nb = 0, nc = 0;
			na = b / 2 + c / 2;
			nb = a / 2 + c / 2;
			nc = a / 2 + b / 2;
			a = na, b = nb, c = nc;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 768
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define pb emplace_back
#define mp make_pair
#define eps 1e-8
#define lson (curpos<<1)
#define rson (curpos<<1|1)
/* namespace */
using namespace std;
/* header end */

const int maxn = 110;
int n, a[maxn], ans = INT_MAX;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= 100; i++) {
        int tmp = 0;
        for (int j = 1; j <= n; j++) tmp += (a[j] - i) * (a[j] - i);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n[6]={},x;
for(int i=0;i<5;i++)
{scanf("%d",&n[i]);}
 
for(int i=0;i<5;i++){
for(int j=4;j>i;j--){
if(n[j]>n[j-1]){int t=n[j-1];n[j-1]=n[j];n[j]=t;}
}}
for(int i=0;i<5;i++)
{if(i>0)printf(" ");
printf("%d",n[i]);}
printf("\n");
return 0;
}

Measured memory_bytes: 1032
import java.io.*;

public class Main{
  public static void main(String[] args){
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int w, n;
    try{
      w = Integer.parseInt(reader.readLine());
      n = Integer.parseInt(reader.readLine());
      int[] b = new int[w];
      for(int i = 0; i < w; i++){b[i] = i;}
      for(int i = 0; i < n; i++){
        String a = reader.readLine();
        String[] s = a.split(",", 0);
        swap(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1, b);
      }
      for(int v: b) System.out.printf("%d\n", v + 1);
    }catch(Exception e){}
  }

  public static void swap(int a1, int a2, int[] b){
    int tmp = b[a1];
    b[a1] =  b[a2];
    b[a2] = tmp;
  }
}


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

#define REP(i, t) for (int i = 0; i < t; i++)

int main() {
    string s;
    int m,n,o;
    cin >> s;
    s.pop_back();
    s.pop_back();
    n=s.length();
    for(int i =0;i<n;i+=2) {
        if (s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length()/2)) {if (n-i>0)cout << n-i << endl;break;}
        s.pop_back();
        s.pop_back();
    if (i==n-1) cout << "0" << endl;
    }
    return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
int ct[2][N], a[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	ct[i & 1][a[i]]++;
    }

    set<pair<int, int>> v[2];

    int ans = n;

    for (int i = 0; i < 2; i++) {
    	for (int j = 0; j < N; j++) {
    		if (ct[i][j]) {
    			v[i].insert({n / 2 - ct[i][j], j});
    			if (v[i].size() > 2)
    				v[i].erase(prev(v[i].end()));
    			ans = min(ans, n - ct[i][j]);
    		}
    	}
    }

    for (auto p : v[0]) {
    	for (auto q : v[1]) {
    		if (p.second != q.second) {
    			ans = min(ans, p.first + q.first);
    		}
    	}
    }

    cout << ans;


    return 0;   
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    
    /* 文字列sのABC数を「sのうち３文字に丸をつけ、
       丸をつけた文字を左から読むとABCとなるようにする方法」と言い換える*/
 
    vvl dp(n+1, vl(4));  /* dp[i+1][j] : i文字目(iは0-index)までの処理(?の置換と丸つけ)をすでに行っていて、
                                         これまでにj個丸をつけているときのsの残りの部分に対する処理を行う方法の数 */
    
    // n文字目までに３個丸をつけ終わっているのであとは何もしないの1通り
    dp[n][3] = 1;
    for(ll i = n-1; i >= 0; i--) {
        for(ll j = 3; j >= 0; j--) {
            // 丸を３個つけ終わった場合
            if(j == 3) {
                ll m0 = 1;
                if(s[i] == '?') {
                    m0 = 3;
                }
                // i文字目が?だったら3倍、それ以外は1倍 
                dp[i][j] = m0*dp[i+1][j];
            }
            // まだ丸を３個つけ終わっていない場合
            else {
                // 以下の条件を満たさないときは、丸をつけない場合1倍、つける場合もう無理なので0倍する
                ll m1 = 1;
                ll m2 = 0;
                string x = "ABC";
                // s[i]が?のときは、丸をつけない場合は3倍、つける場合は1倍する
                if(s[i] == '?') {
                    m1 = 3;
                    m2 = 1;
                }
                // 丸をつける場合、s[i]がABCのj文字目のときも1倍する
                else if(s[i] == x[j]) {
                    m2 = 1;
                }
                // 右辺の1項目はi文字目に丸をつけない場合で、2項目は丸をつける場合
                dp[i][j] = m1*dp[i+1][j] + m2*dp[i+1][j+1];
            }
            dp[i][j] %= mod;
        }
    }
    
    out(dp[0][0]);
    re0;
}

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

class Main {

	static final int INF = (1<<31)-1;
	static int n = 1;
	static int[] seg;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		int n_ = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		int q = Integer.parseInt(line.substring(line.indexOf(" ")+1));

		while (n < n_)
			n *= 2;

		seg = new int[2*n-1];
		for (int i=0; i<2*n-1; i++)
			seg[i] = INF;

		for (int i=0; i<q; i++) {
			line = br.readLine();
			String[] str = line.split(" ");
			int com = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			int y = Integer.parseInt(str[2]);
			if (com == 0)
				update(x,y);
			else
				System.out.println(query(x,y,0,0,n-1));
		}

		br.close();
	}

	static void update(int i,int a){
		i += n-1;
		seg[i] = a;
		while (i > 0) {
			i = (i-1)/2;
			seg[i] = Math.min(seg[2*i+1],seg[2*i+2]);
		}
	}

	static int query(int a,int b,int i,int l,int r){
		if (r<a || b<l)
			return INF;
		if (a<=l && r<=b){
			return seg[i];
		}else {
			int vl = query(a,b,i*2+1,l,(l+r)/2);
			int vr = query(a,b,i*2+2,(l+r+1)/2,r);
			return Math.min(vl,vr);
		}
	}
}

Measured memory_bytes: 66716
Scanf.scanf "%d" (fun t ->
    let module S = Set.Make (struct type t = int * int let compare = compare end) in
    for i = 1 to t do
        Scanf.scanf " %d" (fun n ->
            let klr = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun k l r -> k, l, r)) in
            let sum = Array.fold_left (fun acc (_, l, r) -> acc + min l r) 0 klr in

            let rec loop i left right =
                if i = n then Array.of_list left, Array.of_list right else
                    let k, l, r = klr.(i) in
                    if l > r then loop (i + 1) ((k, l - r) :: left) right
                             else loop (i + 1) left ((n - k, r - l) :: right)
            in
            let left, right = loop 0 [] [] in
            Array.sort compare left;
            Array.sort compare right;
            let proc a =
                let len = Array.length a in
                let rec loop i j acc set ct =
                    if i = len then acc else
                        let k, dif =  a.(i) in
                        if k > j then loop i (j + 1) acc set ct else
                            let set = S.add (dif, i) set in
                            let ct = ct + 1 in
                            let acc = acc + dif in
                            if ct <= k then loop (i + 1) j acc set ct else
                                let ((dif, _) as m) = S.min_elt set in
                                let set = S.remove m set in
                                let ct = ct - 1 in
                                let acc = acc - dif in
                                loop (i + 1) j acc set ct
                in
                loop 0 0 0 S.empty 0
            in
            Printf.printf "%d\n" @@ sum + proc left + proc right
        )
    done
)

Measured memory_bytes: 38280