akhauriyash/Code-Regression huggingface dataset:
loop do
  n = gets.to_i
  break if n == 0
  m = []
  n.times do
    m << gets.split.map do |v|
      v.to_i - 1
    end[1..-1]
  end
  k = gets.split.map do |v|
    v.to_i - 1
  end[1..-1]

  suspects = []
  m.each_with_index do |ids, mi|
    suspected = true
    k.each do |target|
      unless ids.include? target
        suspected = false
        break
      end
    end

    suspects << mi + 1 if suspected
  end

  puts suspects.size == 1 ? suspects[0] : -1
end

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

vector<vector<bool>> g(50,vector<bool>(50,false));
vector<bool> c(50,false);
int n,m;

void dfs(int a){
	c.at(a)=true;
	rep(i,n){
		if(!c.at(i) && g[a][i]) dfs(i);
	}
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i);
		a.at(i)--;
		b.at(i)--;
		g[a.at(i)][b.at(i)]=true;
		g[b.at(i)][a.at(i)]=true;
	}
	int ans=0;
	rep(i,m){
		rep(j,n) c.at(j)=false;
		bool flg=false;
		g[a.at(i)][b.at(i)]=false;
		g[b.at(i)][a.at(i)]=false;
		dfs(0);
		rep(j,n){
			if(!c.at(j)) flg=true;
		}
		if(flg) ans++;
		g[a.at(i)][b.at(i)]=true;
		g[b.at(i)][a.at(i)]=true;
	}
	cout << ans << endl;
}

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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<bool>>a(h,vector<bool>(w,false));
    rep(i,h){
        rep(j,w){
            int aij; cin >> aij;
            if(aij%2) a[i][j] = true;
        }
    }
    vector<bool>b(h*w,false);
    rep(i,h){
        if(i%2 == 0){
            rep(j,w){
                b[w*i+j] = a[i][j];
            }
        }
        else{
            for(int j = w-1; j >= 0; j--){
                b[w*i+w-1-j] = a[i][j];
            }
        }
    }

    int cnt = 0;
    vector<bool>c(h*w-1,false);
    rep(i,h*w-1){
        if(b[i]){
            b[i+1] = !b[i+1];
            c[i] = true;
            cnt++;
        }
    }

    cout << cnt << endl;
    rep(k,h*w-1){
        if(c[k]){
            int i = k/w; int j = k%w;
            bool bl = (j == w-1);
            int p; int q;
            if(bl){
                p = i+1; q = j;
            }
            else{
                p = i; q = j+1;
            }
            if(i%2 == 1){
                j = w-1-j; q = w-1-q;
            }
            i++; j++; p++; q++;
            cout << i << " " << j << " " << p << " " << q << endl;
        }
    }
}


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

int main(void){
    
    ll a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    while(1){
        
        c -= b;
        
        if(c<=0){
            
            cout << "Yes" << endl;
            return 0;
            
        }
        
        a -= d;
        
        if(a<=0){
            
            cout << "No" << endl;
            return 0;
            
        }
        
    }
    
    return 0;
    
}

Measured memory_bytes: 3620
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto f = readln.chomp.split.map!(to!int).array;
  int n = f[0];
  int m = f[1];
  int r = f[2];
  int[int] trg;
  foreach (int i, t; readln.chomp.split.map!(to!int).array)
  {
    trg[t - 1] = i;
  }
  long[][] d = new long[][](n, n);
  foreach (ref a; d)
  {
    a[] = 1L << 60;
  }
  foreach (i; 0 .. m)
  {
    auto l = readln.chomp.split.map!(to!int);
    int a = l[0] - 1;
    int b = l[1] - 1;
    long c = l[2];
    d[a][b] = d[b][a] = c;
  }
  foreach (k; 0 .. n)
  {
    foreach (i; 0 .. n)
    {
      foreach (j; 0 .. n)
      {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  long ans = 1L << 60;
  foreach (k, v; trg)
  {
    bool[][] done = new bool[][](n, 1 << r);
    alias Node = Tuple!(int, "now", int, "bits", long, "cost");
    alias RBT = RedBlackTree!(Node, (l, r) => l.cost < r.cost, true);
    RBT queue = new RBT();
    queue.insert(Node(k, 1 << v, 0));
    while (queue.length)
    {
      Node node = queue.front;
      queue.removeFront;
      if (done[node.now][node.bits])
      {
        continue;
      }
      done[node.now][node.bits] = true;
      if (node.bits == (1 << r) - 1)
      {
        ans = min(ans, node.cost);
        break;
      }
      foreach (to, bit; trg)
      {
        queue.insert(Node(to, node.bits | 1 << bit, node.cost + d[node.now][to]));
      }
    }
  }
  ans.writeln;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
ll dp[100005];
int main()
{
    ll n;
    cin>>n;
    ll h[n];
    rep(i,n)
    cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    dp[0]=0;
    repA(i,2,n-1)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int A,B,C,D;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
main()
{
	cin>>A>>B>>C>>D;
	A=abs(A-C);
	B=abs(B-D);
	if(A==0||B==0)
	{
		cout<<0<<endl;
		return 0;
	}
	int d=gcd(A,B);
	A/=d;
	B/=d;
	if(A>B)swap(A,B);
	long T=A==B?A:A+B-1;
	cout<<T*d<<endl;
}


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


int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A, B, sum = 0, i;
	scanf("%d%d", &A, &B);
	for(i = 1; i<=2; i++)
	{
		if(A > B){
		sum += A;
		A = A-1;
		}
		else
		sum += B;
		B = B-1;
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
void main()
{
int n,i,m;
scanf("%d",&n);
scanf("%d",&m);
  int a[10000];
  int t=0;
for(i=0;i<m;i++)
{
scanf("%d",&a[i]);
}
  for(i=0;i<m;i++)
    t=t+a[i];
  n=n-t;
  if(n>=0)
  printf("%d",n);
  else
  printf("-1");  
}

Measured memory_bytes: 1772
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
  int a,b[n+1];
  for(int i=0;i<=n;i++){
    b[i]=0;}
  for(int i=1;i<n;i++){
    cin>>a;
    b[a]++;}
  for(int i=1;i<=n;i++){
    cout<<b[i]<<" ";}
  return 0;
    
}

Measured memory_bytes: 4376
n = int(input())
w = list(map(int, input().split()))

ans = 10 ** 9
for t in range(n):
    cnt = 0
    for i in range(n):
        a = 1
        if i > t:
            a = -1
        cnt += a * w[i]
    ans = min(ans, abs(cnt))
    
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

char str[8];

int main(int argc, void **arg)
{
    char s[2 * 100000 + 1];
    int len, i;
    int count = 0;
    int p, l;
    int l1, l2;

    scanf("%s", s);
    len = strlen(s);

    count = 1;
    p  = 0;
    l1 = 1;
    l2 = 0;
    for (i = 1; i < len; i++)
    {
        l2++;
        if( l1 == l2 ) {
            if( strncmp(&s[p], &s[p+l1], l1) != 0 ) {
                count++;
                p  = i;
                l1 = l2;
                l2 = 0;
            }
            else {
                l2++;
            }
        }
        else {
            count++;
            p  = i;
            l1 = l2;
            l2 = 0;
        }
    }

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

    return 0;
}


Measured memory_bytes: 384
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj = null;
var inputFile = [];
reader.on('line', function(input){inputFile.push(input);});
reader.on('close', function(){
  obj = init(inputFile);
  Main();
});
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    "list" : input, "index" : 0, "max" : input.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var output = 100000000;
  for(var i = 1; i <= 100; i++){
    var cost = 0;
    for(var j = 0; j < N; j++){
      cost += Math.pow((list[j] - i),2);
    }
    output = Math.min(output,cost);
  }
  myout(output);
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int h, w, c;
int cnt = 0;

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

void fill(vvi &field, int y, int x, int cb, int ca){
  cnt++;
  field[y][x] = ca;
  REP(i, 4){
    int sx = x + dx[i];
    int sy = y + dy[i];
    if(0 <= sx && 0<= sy && sx<w && sy<h) {
      if(field[sy][sx] == cb) {
        fill(field, sy, sx, cb, ca);
      }
    }
  }
}

int result = 0;
void dfs(vvi &field, int step){
  if(step == 1) {
    if(field[0][0] == c) return;
    fill(field, 0, 0, field[0][0], c);
    cnt = 0;
    fill(field, 0, 0, field[0][0], 0);
    result = max(result, cnt);
    return;
  }
  FOR(i, 1, 7){
    if(field[0][0] == i) continue;
    vvi f = field;
    fill(f, 0, 0, field[0][0], i);
    dfs(f, step - 1);
  }
}

int main() {
  while(cin >> h >> w >> c, h | w | c) {
    result = 0;
    vvi field(h, vi(w, 0));
    REP(y, h) REP(x, w){
      cin >> field[y][x];
    }

    dfs(field, 5);
    cout << result << endl;
  }
}

Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string s; cin >> s;
    int posA = -1, posZ = 0;
    rep(i, s.size()) {
        if(s[i] == 'A' && posA == -1) posA = i;
        if(s[i] == 'Z') posZ = i;
    }
    cout << posZ - posA + 1 << endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int sum = 0;
		for (int i = 0; i < n - 1; i++) {
			sum += a[i];
		}
		if (a[n - 1] < sum) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void){

	while(1){
		int t, n, s, f, sum=0, i;
		scanf("%d", &t);
		if(t==0) break;
		scanf(" %d", &n);
		
		for(i=0; i<n; i++){
			scanf(" %d %d", &s, &f);
			sum += f-s;
		}
		
		if(sum >= t) printf("OK\n");
		else printf("%d\n", t-sum);
	
	}

	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            string s;
            cin >> s;
            int n = s.size();
            int a = 0;
            for(char c:s)
            {
                a += (c - '0');
                a %= 9;
            }
            if(a%9 == 0)
                cout << "Yes\n";
            else
                cout << "No\n";




           return 0;
        }
          

Measured memory_bytes: 3744
#include"bits/stdc++.h"

int main (int, char**) {
    std::string input;
    std::cin >> input;

    if (input[2]==input[3] && input[4]==input[5]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  if(n == 1){
    ll sum = 0;
    string s;cin>>s;
    for(int i=0;i<s.size();i++){
      if(s[i] =='(')sum++;
      else sum--;
      if(sum < 0){cout<<"No"<<endl;return 0;}
    }
    if(s[0] == '(' && s.back() == ')' && sum == 0){
      cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
  }




  ll sum = 0;

  vector<pair<ll,pair<ll,ll>>>plmi,cenmae;
  vector<pair<ll,ll>>minus;
  ll pl = 0;
  bool fl = false,fl2 = false;;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    ll now = 0;
    ll mi = 0;
    for(int j=0;j<s.size();j++){
      if(s[j] == '('){
	now++;sum++;
      }else{
	now--;sum--;
      }
      mi = min(mi,now);
    }
    if(s[0] =='(' && s.back() == ')'){
      if(mi < 0){
	if(now>=0){
	  cenmae.pb(mp(now+mi,mp(now,mi)));
	}else{
	  minus.pb(mp(now,mi));
	}
      }else{
	pl += now;
      }
    }else if(s[0] == '('){
      if(mi < 0){
	if(now > 0){
	  cenmae.pb(mp(now+mi,mp(now,mi)));
	}else{
	  cenmae.pb(mp(now+mi,mp(now,mi)));
	}
      }else pl += now;
    }else if(s.back() == ')'){
      if(mi < 0){
	if(now >= 0){
	  cenmae.pb(mp(now+mi,mp(now,mi)));
	}else{
	  minus.pb(mp(now,-mi));
	}
      }else{
	cenmae.pb(mp(now+mi,mp(now,mi)));
      }
    }else{
      cenmae.pb(mp(now+mi,mp(now,mi)));
    }
  }
  if(sum){
    cout<<"No"<<endl;
  }else{
    if(pl == 0 && minus.size() == 0 && cenmae.size() == 0){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(pl == 0 || minus.size() == 0){
      cout<<"No"<<endl;
      return 0;
    }
    sort(ALL(minus),greater<pair<ll,ll>>());
    sort(ALL(cenmae),greater<pair<ll,pair<ll,ll>>>());
    for(auto a:cenmae){
      // cout<<pl<<" "<<a.F<<" "<<a.S<<endl;
      if(pl < -a.S.S){
	cout<<"No"<<endl;
	return 0;
      }
      pl += a.S.F;
    }
    for(auto a:minus){
      // cout<<pl<<" "<<a.F<<" "<<a.S<<endl;
      if(pl < a.S){
	cout<<"No"<<endl;
	return 0;
      }
      pl += a.F;
    }
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 12628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer[][] dataSet = new Integer[3000][2];
        int i=0;
        while(true) {
            int tmp1 = sc.nextInt();
            int tmp2 = sc.nextInt();

            dataSet[i][0] = tmp1;
            dataSet[i][1] = tmp2;
            i++;

            if(tmp1 == 0 && tmp2 == 0) {
                break;
            }
        }

        for(int j=0; j<dataSet.length; j++) {
            if(dataSet[j][0] == 0 && dataSet[j][1] == 0) {
                break;
            }
            java.util.Arrays.sort(dataSet[j]);
            System.out.println(dataSet[j][0] + " " + dataSet[j][1]);
        }
    }
}



Measured memory_bytes: 36852
import std.stdio;
import std.algorithm;
import std.conv;
import std.typecons;

void main() {
	int n;
	scanf("%d", &n);
	auto ipt = new Tuple!(int, int)[n];
	foreach(i;0..n) {
		int a, b;
		scanf("%d %d", &a, &b);
		ipt[i] = tuple(a, b);
	}
	ipt.sort!((a, b) => a[1] < b[1]);
	int t;
	foreach(x; ipt){
		t += x[0];
		if (t > x[1]) {
			write("No");
			return;
		}
	}
	write("Yes");
}


Measured memory_bytes: 3708
#include <stdio.h>

int main(void){

  long n,m;
  scanf("%ld %ld", &n, &m);
  long h[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }
  long a[m],b[m];
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  int check[n];
  for (long i = 0; i < n; i++) {
    check[i] = 1;
  }
  for (long i = 0; i < m; i++) {
    if (h[a[i]-1] >= h[b[i]-1]) {
      check[b[i]-1] = 0;
    }
    if (h[a[i]-1] <= h[b[i]-1]) {
      check[a[i]-1] = 0;
    }
  }
  long count = 0;
  for (long i = 0; i < n; i++) {
    if (check[i] == 1) {
      count++;
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int main(){

     long double sum=100.00,n,i,j=0,k,x;
    cin>>x;
    for(i=0;;i++){
        sum=sum+sum*.01;
        j+=1;
        sum=floor(sum);

        if(sum>=x){
            cout<<j<<endl;
            break;
        }

    }
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

typedef pair<ll, ll> ii;

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

  vector<ii> v;
  rep(i, n) {
    ll a,b; cin>>a>>b;
    v.push_back(make_pair(a, b));
  }
  sort(v.rbegin(),v.rend());
  cout << v[0].first + v[0].second << endl;

  return 0;
}


Measured memory_bytes: 5340
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	set<int>S;
	S.insert(a);
	for(int i=2;;i++){
		if(a%2)a=a*3+1;
		else a/=2;
		if(S.count(a)){
			printf("%d\n",i);return 0;
		}
		S.insert(a);
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  cin >> n;
  vi32 x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  function<f80(int, int)> dist = [&](int i, int j) {
    return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
  };
  f80 ans = 0;
  rep(i, n) rep(j, i) ans += dist(i, j);
  ans *= 2.0 / n;
  cout << ans << endl;
}


Measured memory_bytes: 384
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll dp[N][10];
void solve()
{
  ll idx;
  cin>>idx;
  ll curs=0;
  rep(i,0,10)
  dp[1][i]=1;
  if(idx<=9) {
    cout<<idx;
    cout<<endl;
    return ;
  }
  idx-=9;
  rep(i,2,N)
  {
    rep(k,0,10)
    {
      rep(j,max(k-1,0LL),min(10LL,k+2))
        dp[i][k]=dp[i-1][j]+dp[i][k];
      if(k)
      {
        if(dp[i][k]>=idx)
        {
          vi v;
          ll len=i-1,cur=k;
          v.pb(k);
          while(len){
          rep(j,max(cur-1,0LL),min(10LL,cur+2))
          {
            if(dp[len][j]<idx)
            {
              idx-=dp[len][j];
            }
            else{
              v.pb(j);
              cur=j;
              len--;
              break;
            }
          }}
          for(auto j:v) cout<<j;
            cout<<endl;
          return ;
        }
        idx-=dp[i][k];
      }
    }

  }
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll 			long long int
#define vll 		vector<long long int>
#define vi  		vector<int>
#define vpi 		vector<pair<int,int>>
#define PR 		fixed<<setprecision(10)
#define set(x)		__builtin_popcount(x)
#define ffs(x) 		__builtin_ffs(x)
#define clz(x) 		__builtin_clz(x)
#define all(v) 		v.begin(),v.end()
#define PI 3.14159265358979323846264

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
    int n;
    cin >> n;
    int k = n%10;
    if(k==2 || k==4 || k==5||k==7||k==9)cout << "hon";
    else if(k==0 || k==1||k==6||k==8)cout << "pon";
    else if(k==3)cout << "bon";
}



Measured memory_bytes: 3636
/**
 *    author:  tourist
 *    created: 16.11.2019 23:34:45       
**/
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

typedef pair<long long, int> tp;
typedef tree<tp,null_type,less<tp>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// tp a;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= k;
  }
  pbds t;
  long long s = 0;
  t.insert(make_pair(s, -1));
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    s += a[i];
    ans += t.order_of_key(make_pair(s + 1, -1));
    t.insert(make_pair(s, i));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 13568
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int K,A,B; R(K,A,B);
    K++;
    if(B<=A+2)W(K);
    else{
        if(K<=A+1)W(K);
        else{
            if((K-A)%2==0)W(A+(LL)(B-A)*(K-A)/2);
            else W(A+1+(LL)(B-A)*(K-A-1)/2);
        }
    }
    return 0;
}


Measured memory_bytes: 256
def getval():
    h,w = map(int,input().split())
    a = [list(map(int,input().split())) for i in range(h)]
    b = [list(map(int,input().split())) for i in range(h)]
    return h,w,a,b

def main(h,w,a,b):
    dp = []
    for i in range(w):
        dp.append([False for j in range(1+160*(i+1))])

    dp[0][abs(a[0][0]-b[0][0])] = True
    for i in range(w-1):
        cura = a[0][i+1]
        curb = b[0][i+1]
        prev = dp[i]
        for j in range(len(prev)):
            if prev[j]:
                u1 = abs(j-(cura-curb))
                u2 = abs(j-(curb-cura))
                for k in [u1,u2]:
                    if k<=160*80:
                        dp[i+1][k] = True
    #for i in dp:
      #print(i[:20])
    for i in range(h-1):
        temp = []
        rowa = a[i+1]
        rowb = b[i+1]
        for j in range(w):
            cur = [False for k in range(min(1+160*(i+j+2),1+160*80))]
            prev1 = dp[j]
            prev2 = dp[j]
            if temp:
                prev2 = temp[-1]
            cura = rowa[j]
            curb = rowb[j]
            for k in range(len(prev1)):
                if prev1[k] or prev2[k]:
                    u1 = abs(k-(cura-curb))
                    u2 = abs(k-(curb-cura))
                    if u1<len(cur):
                        cur[u1] = True
                    if u2<len(cur):
                        cur[u2] = True
            temp.append(cur)
        dp = temp
        #for i in dp:
          #print(i[:20])

    ans = 0
    for i in range(160*80+1):
        if dp[-1][i]:
            ans = i 
            break
    print(ans)        

if __name__=="__main__":
    h,w,a,b = getval()
    main(h,w,a,b)

Measured memory_bytes: 173540
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=n;i>=1;i--)
    {
        if(sqrt(i)-(int)sqrt(i)==0)
            break;
    }
    printf("%d\n",i);
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];
    
    ll ans = 0;
    
    for (int A = 0; A <= K; A++) {
        ll sum = 0;
        vector<int> get;
        for (int i = 0; i < A; i++) {
            sum += V[i];
            get.push_back(V[i]);
        }
        for (int B = 0; B <= min(K-A, N-A); B++) {
            ll sum2 = sum;
            vector<int> get2 = get;
            for (int i = 0; i < B; i++) {
                sum2 += V[N-1-i];
                get2.push_back(V[N-1-i]);
            }
            sort(get2.begin(), get2.end());
            for (int i = 0; i < min(K-A-B, A+B); i++) {
                if (get2[i] < 0) sum2 -= get2[i];
                else break;
            }
            ans = max(sum2, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

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

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


#line 2 "tmp.cpp"

int dfs(int cur, const vector<vi> &g) {
  if (g[cur].size() == 0)
    return 0;
  vi tmp;
  for (const auto v : g[cur]) {
    tmp.push_back(dfs(v, g));
  }
  sort(ALL(tmp));
  int ans = g[cur].size();
  int s = tmp.size();
  REP(i, s) { chmax(ans, s - i + tmp[i]); }
  return ans;
}

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

  int n;
  cin >> n;
  vector<vi> g(n);
  REP(i, n - 1) {
    int a;
    cin >> a;
    a--;
    g[a].push_back(i + 1);
  }

  cout << dfs(0, g) << endl;

  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
      
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,m,sum=0,ac=0;
  cin>>n>>m;
  bool AC[n+5]={false};
  int WA[n+5]={};

  int p;
  string s;
  rep(i,m){
    cin>>p>>s;
    if(!AC[p]){
      if(s=="AC"){
	ac++;
	AC[p]=true;
	sum+=WA[p];
      }
      else{
	WA[p]++;
      }
    }
  }
    
  cout<<ac<<" "<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 768
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,in;
    cin >> n;
    vector<int> x(n+1);

    REP(i,n){
        cin >> in;
        if(in == i+1) x[i] = 1;
        else x[i] = 0;
    }

    int cnt = 0;
    REP(i,n){
        if(x[i] == 1){
            x[i]--;x[i+1]--;
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;

int main() {

    double r;
    double a, c;

    cin >> r;

    a = r * r * M_PI;
    c = 2 * r * M_PI;

    cout << fixed;
    cout << setprecision(6) << a << " " << c << "\n";
    return 0;

}



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

int main(){
	float a,b;
	float n1,n2;
	cin>>a>>b;
	for(int i=1;i<=10000;i++)
	{
		n1= i*0.08;
		n2= i*0.1;
		
		if(floor(n1)==a && floor(n2)==b){
			cout<<i;
			return 0;
		}
	}
	
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "bufio"
    "fmt"
    "os"
    "strings"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main(){
    line := nextLine()
    nums := strings.Split(line, " ")
    str_join_num := strings.Join(nums, "")
    num, _ := strconv.Atoi(str_join_num)

    if num % 4 == 0{
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
	int n, x;
	cin >> n >> x;
	int ans = 1;
	int xx = 0;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n) {
		xx += a[i];
		if (xx <= x)ans++;
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m,i,a,b;
  scanf("%d %d",&n,&m);
  int r[n];
  for(i=0;i<n;i++){
    r[i]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    r[a-1]++;
    r[b-1]++;
  }
  for(i=0;i<n;i++){
    printf("%d\n",r[i]);
  }
  return 0;
}

Measured memory_bytes: 128
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Debug.Trace

main :: IO ()
main = breads >>= main'
    where
        main' [h, w] = replicateM h breads >>= printRes . solve h w
        printRes = mapM_ (putStrLn . unwords . map show)

solve :: Int -> Int -> [[Int]] -> [[Int]]
solve h w = edit . concat . searchl (1, 1) Nothing
    where
        edit ps = [length ps] : ps

        searchl n@(nh, nw) (Just p@(ph, pw)) ((x : xs) : ys)
            | odd x = trace ("searchl: pathl" ++ show n ++ "," ++ show p) pathl n p : searchl (nh, nw + 1) Nothing (xs : ys)
            | otherwise = searchl (nh, nw + 1) (Just p) $ xs : ys
        searchl n@(nh, nw) _ ((x : xs) : ys)
            | odd x = searchl (nh, nw + 1) (Just (nh, nw)) $ xs : ys
            | otherwise = searchl (nh, nw + 1) Nothing $ xs : ys
        searchl (nh, _) Nothing (_ : ys) = searchl (nh + 1, 1) Nothing ys
        searchl (nh, _) p (_ : y : ys) = searchr (nh + 1, w) p (reverse y : ys)
        searchl _ _ _ = []

        searchr n@(nh, nw) (Just p@(ph, pw)) ((x : xs) : ys)
            | odd x = trace ("searchr: pathr" ++ show n ++ "," ++ show p) pathr n p : searchr (nh, nw - 1) Nothing (xs : ys)
            | otherwise = searchr (nh, nw - 1) (Just p) $ xs : ys
        searchr n@(nh, nw) _ ((x : xs) : ys)
            | odd x = searchr (nh, nw - 1) (Just (nh, nw)) $ xs : ys
            | otherwise = searchr (nh, nw - 1) Nothing $ xs : ys
        searchr (nh, _) p (_ : ys) = searchl (nh + 1, 1) p ys
        searchr _ _ _ = []

        pathl (th, tw) (sh, sw)
            | sh /= th && sw > tw = qs
            | sh /= th = [sh, sw, th, sw] : ps
            | otherwise = ps
            where
                ps = [[th, p, th, p + 1] | p <- [sw..(tw - 1)]]
                qs = build sw
                build x 
                    | x > tw = [sh, x, sh, x - 1] : build (x - 1)
                    | otherwise = [[sh, tw, th, tw]]

        pathr (th, tw) (sh, sw)
            | sh /= th && sw < tw = qs
            | sh /= th = [sh, sw, th, sw] : ps
            | otherwise = ps
            where
                ps = [[th, p, th, p - 1] | p <- [sw, (sw - 1)..(tw + 1)]]
                qs = build sw
                build x 
                    | x < tw = [sh, x, sh, x + 1] : build (x + 1)
                    | otherwise = [[sh, tw, th, tw]]


breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 31868
def main():
    import sys
    input = sys.stdin.readline #文字列をsplit()しない場合s=s[:-2]が必要

    n=int(input())
    A=[int(input())for _ in range(n)]
    a_max1=max(A)
    A1=A[:]
    A1.remove(a_max1)
    a_max2=max(A1)
    for i in range(n):
        if A[i]!=a_max1:print(a_max1)
        else:print(a_max2)

if __name__=='__main__':
    main()

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

// https://atcoder.jp/contests/abc159/tasks/abc159_f

const int N = 3008;
const int MOD = 998244353;
int a[N];
int dp[N][N]; // dp[i][j] = sum of ways to choose L and then make sum j with first i elements

int n, target;
int main() {
	cin >> n >> target;
	assert(n < N);
	assert(target < N);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		assert(a[i] < N);
	}

	int answer = 0;

	for (int i = 0; i < n; i++) {
		for (int s = 0; s <= target; s++) {
			dp[i][s] = 0;

			if (i > 0) {
				// don't use a[i]
				dp[i][s] += dp[i-1][s];
			}

			if (s == a[i]) {
				// use a[i] as x_1
				// i + 1 ways to choose L
				dp[i][s] += i + 1;
			} else if (s > a[i] && i > 0) {
				// use a[i] as x_j, j > 1
				dp[i][s] += dp[i-1][s - a[i]];
			}

			dp[i][s] %= MOD;

			if (s == target) {
				// use i as R
				answer = (answer + dp[i][s]) % MOD;
			}
		}
	}

	cout << answer << "\n";
}


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

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

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	ll a,b;
	cin >> a >> b;
  ll ans = floor((double) (a-1) * 25 / (double)2);
  while (floor((double)ans * 0.08) <= a) {
    if (floor((double)ans * 0.1) == b && floor((double)ans * 0.08) == a) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))

    cnt = 0
    for i in range(0, n, 2):
        #print(i)
        if a_list[i] % 2 != 0:
           cnt += 1

    print(cnt)



if __name__ == "__main__":
    resolve()



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

using namespace std;

const int maxn = 810;

int n, m, k;

char str[maxn][maxn];

int sx, sy;
int dis[maxn][maxn];
int qx[maxn*maxn], qy[maxn*maxn], s, t;

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%s", str[i]+1);
		for (int j = 1; j <= m; j++) {
			if (str[i][j] == 'S') {
				sx = i, sy = j;
			}
			dis[i][j] = 0x3f3f3f3f;
		}
	}
	dis[sx][sy] = 0;
	qx[t] = sx; qy[t] = sy; t++;
	while (s < t) {
		int ux = qx[s], uy = qy[s]; s++;
		if (ux + 1 <= n && str[ux+1][uy] == '.' && dis[ux+1][uy] == 0x3f3f3f3f) {
			dis[ux+1][uy] = dis[ux][uy] + 1;
			qx[t] = ux+1; qy[t] = uy; t++;
		}
		if (uy + 1 <= m && str[ux][uy+1] == '.' && dis[ux][uy+1] == 0x3f3f3f3f) {
			dis[ux][uy+1] = dis[ux][uy] + 1;
			qx[t] = ux; qy[t] = uy+1; t++;
		}
		if (ux - 1 >= 1 && str[ux-1][uy] == '.' && dis[ux-1][uy] == 0x3f3f3f3f) {
			dis[ux-1][uy] = dis[ux][uy] + 1;
			qx[t] = ux-1; qy[t] = uy; t++;
		}
		if (uy - 1 >= 1 && str[ux][uy-1] == '.' && dis[ux][uy-1] == 0x3f3f3f3f) {
			dis[ux][uy-1] = dis[ux][uy] + 1;
			qx[t] = ux; qy[t] = uy-1; t++;
		}
	}
	int ans = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (dis[i][j] <= k) {
				int mn = min(min(i-1, n-i), min(j-1, m-j));
				ans = min(ans, (mn+k-1)/k + 1);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  rep(i,s.size()){
    int a=s[i]-'A';
    a=(n+a)%26;
    s[i]=a+'A';
  }
  cout<<s<<endl;
}

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

int main()
{   
    int num;
    cin >> num;
    int tmp = 0,flag = 0;
    while(num > 0){
        tmp = num % 10;
        if(tmp == 7) {
            flag = 1;
            break;
        }
        num /= 10;
    }
    if(flag == 1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;
const long long   INF = 1e9;




int n;
vector <int> primes;
bool seive[1001];






void genPrime(){
	memset(seive, 1,sizeof(seive));
	int  i =2;
	while(i*i <= 1000){
		int  k = i*i;
		while(k<=1000){
			seive[k] = false;
			k += i;
		}
		i++;
	}
	for(int i=2;i<=1000;i++){
		if(seive[i])primes.pb(i);
	}
	return ;
}

void solve(){

     cin >> n;
     int a[1001];
     memset(a,0,sizeof(a));
     for(int i  = 2;i <= n;i++){
	     int j = 0;
	     int num = i;
	     
	     while(j<primes.size()){
		     
		     int cnt = 0;
		     while(num%primes[j] == 0){
			     num/=primes[j];
			     cnt++;
		     }
		     a[primes[j]] += cnt;
		     j++;
	     }
	     if(num != 1)a[i]++;
     }
     ll sum = 1;
     for(int i=2;i<=n;i++){
         sum = sum*(a[i]+1)%mod;
     }

     cout<<sum<<"\n";

	     


}






int main(){
	genPrime();
	solve();
	return 0;
}


Measured memory_bytes: 256