akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; cin >> N;
  int reach[500]={};
  int c,s,f;
  for(int i=0; i<N-1; i++){
    cin >> c >> s >> f;
    for(int j=0; j<=i; j++){
      if(reach[j]<s){
        reach[j]=s+c;
      }else{
        reach[j]=((reach[j]+f-1)/f)*f+c;
      }
    }
  }
  for(int i=0; i<N; i++){
    cout << reach[i] << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    vector<int> ans(n, 0);
    for(int i=1; i<n; i++){
        int a; cin>>a;
        a--;
        ans[a]++;
    }

    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3996
import java.util.Scanner;

/**
 * Greedy Takahashi
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long A = sc.nextLong();
            long B = sc.nextLong();
            long K = sc.nextLong();

            if (A + B <= K) {
                A = 0;
                B = 0;
            } else if (A <= K) {
                B -= K - A;
                A = 0;
            } else {
                A -= K;
            }

            System.out.println(A + " " + B);
        }
    }

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
		
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}
template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N,0);
    for(auto &a:A){
        cin >> a;
    }

    vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(3,vector<ll>(2,-MOD*MOD)));
    dp[0][0][0]=0;
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            dp[i+1][j][1]=max(dp[i+1][j][1], dp[i][j][0]+A[i]);
            dp[i+1][j][0]=max(dp[i+1][j][0], dp[i][j][1]);

            if(j<2){
                dp[i+1][j+1][0]=max(dp[i+1][j+1][0],dp[i][j][0]);
            }
        }
    }
    //cout_mat(dp[N]);cout << endl;
    if(N%2==0){
        cout << max(dp[N][0][0],max(dp[N][1][1],dp[N][1][0])) << endl;
    }else{
        cout << max(max(dp[N][1][1],dp[N][1][0]), dp[N][2][1]) << endl;
    }
}

Measured memory_bytes: 43796
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================



int weights[100+9];
long long benefit[100+9];
int n , kpWeight;
long long dp[100 + 9][100000 + 9];

long long  knapSack(int index , int reminderWeight)
{
	if (index == n)
		return 0;

	if (dp[index][reminderWeight] != -1)
	{
		return dp[index][reminderWeight];
	}

	long long leave = knapSack(index + 1, reminderWeight);

	long long take = 0;
	if (reminderWeight >= weights[index])
	{
		take = benefit[index] + knapSack(index + 1, reminderWeight - weights[index]);
	}
	return dp[index][reminderWeight] = max(leave, take);
}

int main()
{
	cin >> n >> kpWeight;
	for (int i1 = 0; i1 < 100+9; i1++)
	{
		for (int i2 = 0; i2 < 100000+9; i2++)
		{
			dp[i1][i2] = -1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		int a;
		long long b;
		cin >> a >> b;
		weights[i] = a;
		benefit[i] = b;
	}
	cout << knapSack(0, kpWeight);
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

struct BIT2d{
	int ymx, xmx;
	vector<vector<int>> dt;
	BIT2d(int my, int mx): ymx(my), xmx(mx), dt(my+5,(vector<int>(mx+5))){};
	void add(int y, int x, int v){
		for(int i = y+1; i <= ymx+1; i += i & -i)
			for(int j = x+1; j <= xmx+1; j += j & -j) dt[i][j] += v;
	}
	int qsum(int y, int x){
		int res = 0;
		for(int i = y+1; i > 0; i -= i & -i)
			for(int j = x+1; j > 0; j -= j & -j) res += dt[i][j];
		return res;
	}
	int qsum(int y0, int x0, int y1, int x1){
		return qsum(y1, x1) - qsum(y0-1, x1) - qsum(y1, x0-1) + qsum(y0-1, x0-1);
	}
};
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	const ll KS = 1e9;
	rep(i, n){
		string s;
		cin >>s;
		int ps = s.find(".");
		if(ps==-1){
			a[i]= stoll(s) * KS;
		}else{
			a[i] = stoll(s.substr(0, ps))*KS;
			string zs = s.substr(ps+1);
			while(sz(zs)<9) zs+="0";
			a[i] += stoll(zs);
		}	
	}
	for(auto x :a) cerr<<x<<" "; dbg();
	
	vector<pii> ys(n);
	rep(i, n){
		for(ll w = a[i]; w%2==0 && w>0 ; w/=2) ys[i].second++;
		for(ll w = a[i]; w%5==0 && w>0 ; w/=5) ys[i].first++;
	}
	
	for(auto x :ys) cerr<<x.first<<":"<<x.second<<" "; dbg();
	for(auto &x :ys){
		x.first = min(18, x.first);
		x.second = min(18, x.second);
	}
	ll ans =0;
	BIT2d bt(21,21);
	
	for(auto x :ys){
		
		ans += bt.qsum(18-x.first, 18-x.second, 20, 20);
		bt.add(x.first, x.second, 1);
	}
	
	cout << ans<<"\n";
	return 0;
}



Measured memory_bytes: 7020
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int a, b, c, d, e;

int main() {
    while (cin >> a >> b >> c >> d >> e) {
        int h1 = min(min(a, b), c), h2 = min(d, e);
        cout << h1 + h2 - 50 << endl;
    }
    return 0;
}


Measured memory_bytes: 1160
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String a = sc.next();
    		if(a.equals("a") || a.equals("i") || a.equals("u") || a.equals("e") || a.equals("o")) {
    			System.out.println("vowel");
    			System.exit(0);
    		}
    		else {
    			System.out.println("consonant");
    			System.exit(0);
    		}
    	}
    }

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MAXN 99999
#define INF 101;
using namespace std;
inline int read(){
 char c=getchar();int x=0,f=1;
 while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
 return x*f;
}
int a,b,c;
int main()
{
    a=read();
    b=read();
    c=read();
    for(int i=1;i<=b;++i)
     {
        if(a*i%b==c)
         {
            cout<<"YES\n";  
            return 0;
         } 
     }
    cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return - self.par[self.root(x)]


n, m = map(int, input().split())
edge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

uf = UnionFind(n)
ans = n * (n-1) // 2
anss = []
for i in reversed(range(m)):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size(a) * uf.size(b)
    # print(i, a, b)

    uf.unite(a, b)

for i in reversed(range(m)):
    print(anss[i])


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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> ns(n, vector<int>(2));
    rep(i, n){
        cin >> ns.at(i).at(0);
        ns.at(i).at(1) = i+1;
    }
    sort(ns.begin(), ns.end());
    rep(i, n){
        cout << ns.at(i).at(1) << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) <= abs(x - b)) {
        cout << "A" << endl;
        return 0;
    }
    cout << "B" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
  
    vi ans(10005);

    int d = sqrt(n)+1;
    //DEBUG(d);
    FOR(x,1,d+1){
        FOR(y,1,d+1){
            FOR(z,1,d+1){
                int tmp;
                tmp = x*x + y*y + z*z + x*y + y*z + z*x;

                if(tmp <= n)
                    ans[tmp]++;
                else
                    break;
                
                //if(tmp==i) ans++;
            }
        }
    }

    FOR(j,1,n+1){
        cout << ans[j] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int len=s.size(),ctr=0;
  for(int i=0;i<len;i++)
  {
    if(s.at(i)!=t.at(i))
    {
      ctr++;
    }
  }
  cout<<ctr;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,x;
int main()
{
	for(int i=1;i<=4;i++)
	{
		cin>>x;
		if(x==1) a++;
		if(x==4) b++;
		if(x==7) c++;
		if(x==9) d++;
	}
	if(a==1&&b==1&&c==1&&d==1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#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 chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=-INF;
	chmax(ans,a*c);
	chmax(ans,a*d);
	chmax(ans,b*c);
	chmax(ans,b*d);
	cout<<ans<<endl;
	return 0;
}

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


const int MAX_H = 10e4;
const int MAX_N = 10e3;
int N, H;
int A[MAX_N], B[MAX_N];


void Main() {
  cin >> H >> N;
  rep(i, N) {
    cin >> A[i] >> B[i];
  }

  ll dp[N + 1][H + 1];
  fill(dp[0], dp[N], LLONG_MAX);
  rep(i, N + 1) {
    dp[i][0] = 0;
  }

  rep(i, N) {
    rep(j, H + 1) {
      if (j < A[i]) {
        dp[i + 1][j] = min(dp[i][j], (long long)B[i]);
      } else {
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
      }

//      cout << i << " " << j << " " << dp[i + 1][j] << endl;
    }
  }

  cout << dp[N][H] << endl;
}

int main() {
  Main();
  return 0;
}

Measured memory_bytes: 78464
url = "https://atcoder.jp//contests/abc155/tasks/abc155_a"

def main():
    t = list(map(int, input().split()))
    if t[0] == t[1] and t[0] != t[2]:
        print('Yes')
    elif t[1] == t[2] and t[0] != t[1]:
        print('Yes')
    elif t[0] == t[2] and t[0] != t[1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n;
    string s,t;
    cin>>n;
    cin>>s>>t;
    REP(i,n){
        cout<<s[i];
        cout<<t[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

int Root(int t, int tree[]);

int Union(int s, int t, int tree[], int size[]) {
    int root_s = Root(s, tree);
    int root_t = Root(t, tree);
    tree[root_s] = root_t;
    size[root_t] += size[root_s];
    return 0;
}

int Root(int t, int tree[]){
    int init_t = t;
    int parent = tree[t];
    while (parent!=-1) {
        t = parent;
        parent = tree[t];
    }
    int last_t = t;
    
    t = init_t;
    parent = tree[t];
    while (parent!=-1) {
        int temp = t;
        t = parent;
        parent = tree[t];
        tree[temp] = last_t;
    }
    
    return last_t;
}

int main(){
    int N, M;
    int A[100000];
    int B[100000];
    long long result[100000];
    int tree[100000];
    int size[100000];
    
    cin >> N >> M;
    for (int i=0;i<M;i++) cin >> A[M-1-i] >> B[M-1-i];
    for (int i=0;i<M;i++) {A[i]-=1; B[i]-=1;}
    result[0] = (long long)N*(N-1)/2;
    //cout << result[0] << endl;
    
    for (int i=0;i<N;i++) tree[i] = -1;
    for (int i=0;i<N;i++) size[i] = 1;
    
    for (int i=1;i<M;i++) {
        int s = A[i-1];
        int t = B[i-1];
        if (Root(s,tree)!=Root(t,tree)) {
            result[i] = result[i-1] - size[Root(s,tree)]*size[Root(t,tree)];
            Union(s,t,tree,size);
        }
        else {
            result[i] = result[i-1];
        }
        //cout << result[i] << endl;
    }
    
    
    // 出力
    //cout << N << endl;
    for (int i=0;i<M;i++) cout << result[M-1-i] << endl;
    
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll h, w;
  cin >> h >> w;

  ll todd = h / 2;
  todd += h % 2 == 1 ? 1 : 0;

  ll teven = h / 2;

  // cout << todd << " " << teven << ln;

  todd *= ((w + 1) / 2);
  teven *= (w / 2);

  // cout << todd << " " << teven << ln;


  ll ans = todd + teven;

  if(h == 1 || w == 1) {
    ans = 1;
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll L, R;
	cin >> L >> R;

	if(R - L > 5000) {
		cout << 0 << endl;
	} else {
		ll ans = 2019;
		for(ll i = L; i <= R; i++) {
			for(ll j = i + 1; j <= R; j++) {
				ans = min(ans, (i * j)%2019);
			}
		}
		cout << ans << endl;
	}
}


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

using namespace std;
typedef long long ll;

int main() {
    int r,g;
    cin >> r >> g;
    int tmp=g-r;
    g+=tmp;
    cout << g << endl;
}

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

using namespace std;

int main(void){
	long long int n, h;

	cin >> n >> h;

	vector<int> a(n), b(n);

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

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int left = 1, right = 1000000000, mid;

	while (left <= right){
		mid = (left + right)/2;
		long long int id_a = n-1, id_b = n-1, num = mid, sum = 0;
		while (num > 0){
			if (b[id_b] > a[id_a]){
				sum += b[id_b];
				id_b--;
				num--;
			}
			else {
				sum += num*a[id_a];
				break;
			}
		}
		if (h <= sum){
			right = mid - 1;
		}
		else
			left = mid + 1;
	}

/*
	int id_b = n - 1, num = 0;
	while (1){
		if (b[id_b] > a[n-1]){
			h -= b[id_b];
			num++;
			id_b--;
			if (h <= 0)
				break;
		}
		else {
			num += h / a[n-1];
			break;
		}
	}
	left = num;
*/


	cout << left << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
using namespace std;

int main()
{
    string b;
    cin >> b;
    string ret;
    if(b == "A") ret = "T";
    else if(b == "T") ret = "A";
    else if(b == "G") ret = "C";
    else ret = "G";

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

Measured memory_bytes: 256
N = int(input())
ans = 0
for n in range(1,N+1):
    ans += n*(N+1-n)

for _ in range(N-1):
    a,b = map(int,input().split())
    if a > b:
        a,b = b,a
    ans -= a*(N+1-b)

print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int n, ai, bi;
vector<int> a, b;
long long ans;

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      cin >> ai >> bi;
      a.push_back(ai);
      b.push_back(bi);
   }

   reverse(a.begin(), a.end());
   reverse(b.begin(), b.end());

   for (int i = 0; i < n; i++) {
      int ca = a[i];
      int cb = b[i];

      if ((ca+ans) % cb != 0) {
         ans += cb-((ca+ans)%cb);
      }
   }

   cout << ans << endl;
}



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

using namespace std;


int main(){

    //freopen("input.txt", "r", stdin);

    int Max = 500;

    bool Can[Max];

    int a,b,c;

    for(int i=0;i<Max; i++){
        Can[i] = false;
    }

    cin >> a >> b >> c;

    Can[a] = true; Can[b] = true; Can[c] = true;

    int ans = 0;

    if(Can[a] == true){
        ans++;
        Can[a] = false;
    }
    if(Can[b] == true){
        ans++;
        Can[b] = false;
    }
    if(Can[c] == true){
        ans++;
        Can[c] = false;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split())) for _ in [0]*(n-1)]
g=[[] for _ in [0]*n]
[g[b-1].append(a-1) for a,b in ab]
[g[a-1].append(b-1) for a,b in ab]

dist_f=[None for _ in [0]*n]
dist_s=[None for _ in [0]*n]
dist_f[0]=0
dist_s[n-1]=0

q=[0]
while q:
    qq=q.pop()
    for i in g[qq]:
        if dist_f[i]==None:
            dist_f[i]=dist_f[qq]+1
            q.append(i)
            
q=[n-1]
while q:
    qq=q.pop()
    for i in g[qq]:
        if dist_s[i]==None:
            dist_s[i]=dist_s[qq]+1
            q.append(i)
            
cnt_f,cnt_s=0,0

for i in range(n):
    if dist_f[i]<=dist_s[i]:
        cnt_f+=1
    else:
        cnt_s+=1
if cnt_f>cnt_s:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 49816
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int n,m,h,k;
int a[1002];
bool xc[1002][1002];
int dp[1002][1002];
int dp2[1002][1002];

int main(void){
	while(1){
		memset(a,0,sizeof(a));
		memset(xc,false,sizeof(xc));
		memset(dp,-1,sizeof(dp));
		memset(dp2,-1,sizeof(dp2));
		scanf("%d%d%d%d",&n,&m,&h,&k);
		if(n==0 && m==0 && h==0 && k==0)break;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(int i=0;i<m;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			xc[x][y]=true;
		}
		for(int i=1;i<=n;i++){
			int p=i;
			for(int j=h;j>=0;j--){
				if(xc[p][j])p++;
				else if(xc[p-1][j])p--;
				dp[p][j]=a[i];
			}
		}
		for(int i=1;i<=n;i++){
			int p=i;
			for(int j=0;j<=h;j++){
				if(xc[p][j])p++;
				else if(xc[p-1][j])p--;
				dp2[p][j]=i;
			}
		}
		int cnt=0;
		for(int i=1;i<=k;i++)cnt+=dp[i][0];
		int res=cnt;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=h;j++){
				if(xc[i][j]){
					//printf("id %d %d %d %d\n",dp2[i][j],dp2[i+1][j],dp[i][j],dp[i+1][j]);
					if(dp2[i][j]<=k && dp2[i+1][j]<=k)continue;
					if(dp2[i][j]>k && dp2[i+1][j]>k)continue;
					if(dp2[i][j]<=k && dp2[i+1][j]>k){
						int point=dp[i][j]-dp[i+1][j];
						if(cnt+point<res)res=cnt+point;
					}
					if(dp2[i][j]>k && dp2[i+1][j]<=k){
						int point=dp[i+1][j]-dp[i][j];
						if(cnt+point<res)res=cnt+point;
					}
				}
			}
		}
		printf("%d\n",res);
		
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  string t = s;
  reverse(t.begin(), t.end());
  
  string a, b;
  a = s.substr(0, s.size() / 2);
  b = s.substr(s.size() / 2 + 1);
  
  string c = a, d = b;
  reverse(c.begin(), c.end());
  reverse(d.begin(), d.end());
  
  if (s == t && a == c && b == d) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
    int x,a,b,t,s;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);

    if(x<=1000 && a<=1000 && b<=1000 && x>=1 && a>=1 && b>=1){

    t=abs(x-a);
    s=abs(x-b);

    if(t>s) printf("B");
    else    printf("A");

    }
return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vect(N);
  for(int i=0; i<N; i++){
    cin >> vect.at(i);
  }
  if(N == 1){
    cout << 1 << endl;
  }
  else{
    int count = 1;
    int ind = vect.at(0);
    for(int i=1; i<N; i++){
      if(vect.at(i) < ind){
        count++;
        ind = vect.at(i);
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  double r;
  cin>>r;
  double pi = 3.141592653589;
    double are = 2*pi*r;
    double circ = pi*r*r;
  
       cout << fixed << setprecision(6) << circ << endl << are <<endl; 
  return 0;
}



Measured memory_bytes: 3264
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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() {
    ll n;
    cin >> n;

    rep(i, n) {
        char c;
        cin >> c;
        if(c == 'Y') {
            out("Four");
            re0;
        }
    }
    
    out("Three");
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
  //解説そのまま
  int func(string s, string t){
    int ans = 0;
    for(char c='a';c<='z';c++){
      bool founds = false,foundt=false;
      for(int i=0;i<s.length();i++){
        if(s[i]==c){
          founds=true;
        }
      }
      for(int i=0;i<t.length();i++){
        if(t[i]==c){
          foundt=true;
        }
      }
      if(founds&&foundt){
        ans++;
      }
    }
      return ans;
    }
        
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i=0;i<=n;i++){
      int tmp = func(s.substr(0,i),s.substr(i));
      ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;

}
    

Measured memory_bytes: 256
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;     
int read(){     
    int f=1,x=0;char c=getchar();        
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}       
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();     
    return x*f;    
}
#define MAXN 200
#define INF 0x3f3f3f3f
int a[MAXN+5];
int main(){
	int n=read(),A=read(),B=read(),cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=n;i++){
		if(a[i]<=A)
			cnt1++;
		else if(a[i]<=B)
			cnt2++;
	}
	printf("%d\n",min(cnt1,min(cnt2,n-cnt1-cnt2)));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, c, a[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		c += (a[i] + a[i - 1]) / 2;
		if (a[i]) a[i] = (a[i] + a[i - 1]) % 2;
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long  a,b,x,r;
	scanf("%lld %lld %lld" ,&a,&b,&x);
	r=(b/x) - (a/x);
    if(a%x == 0)
    ++r;
    printf("%lld\n",r);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int dat[200000];
int ind[200000];
bool flag[200000];
int vtype[200000];//1: circ1 2: circ2 3: edge
vector<int>circ1[200000];
int circ2[200001];
int flen[200000];
#define SIZE 300000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &dat[i]);
		dat[i]--;
		ind[dat[i]]++;
		if (ind[dat[i]] >= 3)
		{
			printf("0\n");
			return 0;
		}
	}
	for (int i = 0; i < num; i++)
	{
		if (ind[i] == 0)
		{
			int now = i;
			for (;;)
			{
				if (flag[now])
				{
					if (vtype[now] == 0)
					{
						int t = now;
						for (;;)
						{
							vtype[t] = 1;
							circ1[now].push_back(0);
							t = dat[t];
							if (now == t)break;
						}
					}
					else if (vtype[now] == 3)
					{
						printf("0\n");
						return 0;
					}
					break;
				}
				flag[now] = true;
				now = dat[now];
			}
			now = i;
			int t = 0;
			for (;;)
			{
				if (vtype[now] == 1)
				{
					flen[now] = t;
					break;
				}
				vtype[now] = 3;
				now = dat[now];
				t++;
			}
		}
	}
	for (int i = 0; i < num; i++)
	{
		if (!flag[i])
		{
			int now = i;
			int t = 0;
			for (;;)
			{
				if (flag[now])break;
				flag[now] = true;
				t++;
				now = dat[now];
			}
			circ2[t]++;
		}
	}
	for (int i = 0; i < num; i++)
	{
		int now = i;
		for (int j = 0; j < circ1[i].size(); j++)
		{
			circ1[i][j] = flen[now];
			now = dat[now];
		}
	}
	ll ans = 1;
	for (int i = 0; i < num; i++)
	{
		if (circ1[i].size() >= 1)
		{
			int x = circ1[i].size();
			for (int j = x * 3; j >= 0; j--)
			{
				if (circ1[i][j%x] >= 2)
				{
					if (circ1[i][(j + x - 1) % x] != 0)
					{
						printf("0\n");
						return 0;
					}
					circ1[i][(j + x - 1) % x] = circ1[i][j%x] - 1;
					circ1[i][j%x] = 1;
				}
			}
			ll r = 1;
			for (int j = 0; j < x; j++)
			{
				if (circ1[i][j] == 1 && circ1[i][(j + 1) % x] == 0)r = r * 2 % mod;
			}
			ans *= r;
			ans %= mod;
		}
	}
	invinit();
	for (int i = 1; i <= num; i++)
	{
		int x = circ2[i];
		ll tim = 1;
		ll now = 1;
		ll r = 0;
		vector<ll>zv;
		ll tt = 1;
		for (int j = 0; j <= x; j++)
		{
			zv.push_back(tt);
			tt = tt * 2 % mod;
		}
		for (int j = 0; j <= x / 2; j++)
		{
			if (i % 2 == 0 || i == 1)r += com(x, 2 * j)*now%mod*tim%mod;
			else r += com(x, 2 * j)*now%mod*tim%mod*zv[x - j - j] % mod;
			now = now*(j * 2 + 1) % mod;
			tim = tim * i % mod;
		}
		r %= mod;
		ans = ans*r%mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 14080
import numpy as np

x = input().split()

n = int(x[0])
k = int(x[1])
ds = []
bool_array = [0]*n

for num in range(k):
  di = int(input())
  ajs_input = input().split(' ')
  for j in range(di):
     bool_array[int(ajs_input[j])-1] = 1
      
print(n - np.array(bool_array).sum())

Measured memory_bytes: 27208
from collections import defaultdict

def main():
  n, k, q = map(int, input().split())
  member = defaultdict(lambda : 0)
  for _ in range(q):
    member[int(input())] += 1
  
  thresh = q - k
  
  for i in range(1, n+1):
    print("Yes" if member[i] > thresh else "No")
  
  
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 63192
a,b,c,d=map(int,input().split())
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y
x=gcd(c,d)
ans1=b-b//c-b//d+b//(c*d//x)
a-=1
ans2=a-a//c-a//d+a//(c*d//x)
print(ans1-ans2)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vi v;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        v.pb(k);
    }
    sort(v.rbegin(),v.rend());
    v.pb(-1);

    int count=1;
    int a=0;
    ll ans=1;
    int t=v[0];

    for(int i=1;i<=n;i++){
        if(v[i]==t){
            count+=1;
            if(count==2 || count==4){
                ans*=t;
                a+=1;
                if(a==2){
                    break;
                }
            }
        }
        else{
            t=v[i];
            count=1;
        }
    }
    if(ans>1)
        cout<<ans<<endl;
    else if(ans==1 && a==2)
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 892
import itertools

n = int(input())
map_list = []
for i in range(n):
    (x, y) = map(int, input().split())
    map_list.append((x, y))

def detect_dist(a, b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5



route_list = list(itertools.permutations(map_list, n))

dist_sum = 0

for route in route_list:
    for i in range(n-1):
        dist = detect_dist(route[i], route[i+1])
        dist_sum += dist

print(dist_sum/len(route_list))

Measured memory_bytes: 10100
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<int>();
    double x[8] = {}, y[8] = {};
    for (auto i : boost::irange(0, N)) {
        in >> x[i], y[i];
    }

    double sum = 0;
    for (auto i : boost::irange(0, N)) {
        for (auto j : boost::irange(0, i)) {
            sum += std::hypot(x[i] - x[j], y[i] - y[j]);
        }
    }
    out << sum / N * 2;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int mod = 1e9 + 7;
const double EPS = 1e-9;


int main(){
	int n;
	while(cin>>n && n > 0){
		vvi v(n, vi(n, 0));
		vvi u(n, vi(n, 0)), w(n, vi(n, 0));
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin>>v[i][j];
			}
		}

		int a = 0, b = 0;
		for(int i = 0; i < n; i++){
			a = b = i;
			for(int j = 0; j < n; j++){
				if(v[i][a] > v[i][j]) a = j;
				if(v[b][i] < v[j][i]) b = j;
			}
			u[i][a] = 1;
			w[b][i] = 1;
		}

		int ans = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(u[i][j] && w[i][j]) ans = v[i][j];
			}
		}

		cout<<ans<<endl;
	}
}	

Measured memory_bytes: 1216
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

import math
ans=0
lista=[a,b,c,d,e]

if min(lista)>=n:
	ans=5
	
else:
	ans=math.ceil(n/min(lista))+4
	
print(ans)

Measured memory_bytes: 38512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
	res = res * 10 + ch - '0';
	return res * ok;
}
char s[100005];
int n, cnt1, cnt2;
int main()
{
	scanf ("%s", s + 1);
	n = strlen (s + 1);
	for (int i = 1; i <= n; i++)
	if (s[i] == 'W' && s[i - 1] != 'W')
	cnt1++;
	for (int i = 1; i <= n; i++)
	if (s[i] == 'B' && s[i - 1] != 'B')
	cnt2++;
	printf ("%d\n", cnt1 + cnt2 - 1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	ll n;
	cin>>n;
	ll a[n];
	ll xo=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		xo=xo^a[i];
	}
	for(int i=0;i<n;i++){
		cout<<(xo^a[i])<<" ";
	}
	


    return 0;
}


Measured memory_bytes: 5220
n=int(input())
q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
list_point = sorted(q, key=lambda x:x[1], reverse=1)
list_city = sorted(list_point, key=lambda x:x[0], reverse=0)
for s,t,r in list_city:
    print(r+1)
    

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static Scanner sc;
		//入力
	public static void main(String args[]){
		//System.out.println("Please input three numbers below");
		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		//最大値の決定
		if(a>b && a>c) {
			if(b>c) {
				System.out.println(c+" "+b+" "+a);
			}else {
				System.out.println(b+" "+c+" "+a);
			}
		}else if(a<b && a<c) {
			if(b>c) {
				System.out.println(a+" "+c+" "+b);
			}else {
				System.out.println(a+" "+b+" "+c);
			}
		}else {
			if(b>c) {
				System.out.println(c+" "+a+" "+b);
			}else {
				System.out.println(b+" "+a+" "+c);
			}
		}
	}
}



Measured memory_bytes: 26200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 10;
ll calc(ll a[],int n){
    sort(a+1,a+1+n);
    if(n&1) return a[(n+1)/2];
    return (a[n/2]+a[n/2+1])/2;
}
ll a[N],b[N];
int main(){
    ios::sync_with_stdio(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    if(n&1){
        cout<<calc(b,n)-calc(a,n)+1<<endl;
    }
    else{
        for(int i=1;i<=n;i++) a[i] *= 2, b[i] *= 2;
        cout<<calc(b,n)-calc(a,n)+1<<endl;
    }

}


Measured memory_bytes: 6804
<?php
$keys = array(
    "A" => array(
        "B" => true,
        "D" => true,
    ),
    "B" => array(
        "A" => true,
        "C" => true,
        "E" => true,
    ),
    "C" => array(
        "B" => true,
        "F" => true,
    ),
    "D" => array(
        "A" => true,
        "E" => true,
        "G" => true,
    ),
    "E" => array(
        "B" => true,
        "D" => true,
        "F" => true,
        "H" => true,
    ),
    "F" => array(
        "C" => true,
        "E" => true,
        "I" => true,
    ),
    "G" => array(
        "D" => true,
        "H" => true,
    ),
    "H" => array(
        "E" => true,
        "G" => true,
        "I" => true,
    ),
    "I" => array(
        "F" => true,
        "H" => true,
    ),
);

while($line = trim(fgets(STDIN))) {
    $flg = true;
    $prev = null;
    foreach(str_split($line) as $char) {
        if(isset($prev) && !isset($keys[$prev][$char])) {
            $flg = false;
            break;
        }
        $prev = $char;
    }
    if($flg) {
        echo $line, PHP_EOL;
    }
}

Measured memory_bytes: 15384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(),b = sc.nextInt(),x = sc.nextInt();
    int c = a+b;
    if(a <= x && x <= c){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    cout<<n/3<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256