akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define N 3

int pane[N][N], temp[N][N];
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};


void empty(int *,int *);
void swap(int *,int *);
int cal();
int dfs(int ,int ,int ,int ,const int );

int main() {
  int i,j,h,ans,row,col;
      
  for(i=0; i<3; i++){
    for(j=0; j<3; j++)
      scanf("%d",&pane[i][j]);
  }  
  empty(&row,&col);  
  for(h=0; h<100; h++){
    for(i=0; i<3; i++){
      for(j=0; j<3; j++)
	temp[i][j] = pane[i][j];
    }    
    ans = dfs(row,col,-1,0,h);    
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }    
    for(i=0; i<3; i++){
      for(j=0; j<3; j++)
	pane[i][j] = temp[i][j];
    }    
    ans = -1;
    if(h==99) printf("%d\n",ans);
  }      
  return 0;
}

void empty(int *row,int *col){
  int i,j;
  for(i=0; i<3; i++)
    for(j=0; j<3; j++)
      if(!pane[i][j]){
	*row = j;
	*col = i;
	return;
      }  
}
   
void swap(int *a,int *b){
  int temp;
  temp = *a;*a = *b;*b = temp;
}
  
int cal(){
  int i,e,count=0; 
  for(i=0; i<9; i++){
    e = pane[i/3][i%3];
    if(e){
      e--;
      count += abs(i/3 - e/3) + abs(i%3 - e%3);
    }
  }    
  return count;
}
  
int dfs(int x,int y,int p,int deep,const int limt){
  int i,l,x2,y2,emc;   
  l = cal();
  if(l==0) return deep;
  if(deep+l > limt) return -1; 
  for(i=0; i<4; i++){
    x2 = x+dx[i];
    y2 = y+dy[i];      
    if(~p && i==(p+2)%4) continue;
    if(!(0<=x2 && x2<3 && 0<=y2 && y2<3)) continue;    
    swap(&pane[y][x],&pane[y2][x2]);
    emc = dfs(x2,y2,i,deep+1,limt);
    if(~emc) return emc;       
    swap(&pane[y][x],&pane[y2][x2]);
  }   
  return -1;
}  
  



Measured memory_bytes: 2112
import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine(); //文字列を読み込む
        char[] c = s.toCharArray(); //文字単位で配列に詰める
        int sum = 0; //水たまりの面積
        Deque<Integer> stack1 = new ArrayDeque<Integer>();
        Deque<Water> stack2 = new ArrayDeque<Water>();
        for(int i=0; i<c.length; i++) {
            if(c[i]=='\\') {
                stack1.push(i);
            } else if (c[i]=='/' && !stack1.isEmpty()) {
                int n = stack1.pop();
                int a = i-n;
                sum += a;
                while(!stack2.isEmpty() && stack2.peek().index>n) {
                    a += stack2.pop().area;
                }
                Water water = new Water(n,a);
                stack2.push(water);
            }
        }
        System.out.println(sum);
        System.out.print(stack2.size());
        while(!stack2.isEmpty()) {
            System.out.print(" "+stack2.pollLast().area);
        }
        System.out.println();
    }
}
class Water {
    int index;
    int area;
    Water(int index, int area) {
        this.index = index;
        this.area = area;
    }
}



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

using namespace std;

int main() {

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

	int counter = 0;
	vector<vector<int>> hw(h, vector<int>(w, 0));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 0) {
				hw[i][j] = counter+1;
				a[counter]--;
				if (a[counter] == 0) { counter++; }
			}
			else {
				hw[i][w-1-j] = counter+1;
				a[counter]--;
				if (a[counter] == 0) { counter++; }
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w-1; j++) {
			cout << hw[i][j] << " ";
		}
		cout << hw[i][w - 1] << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<vector<vector<string> > >s(n+1,vector<vector<string> >(n+1));
    s[0][0].pb("");
    rep(i,n){
        rep(j,n){
            for(auto e:s[i][j]){
                rep(k,j){
                    s[i+1][j].pb(e+(char)('a'+k));
                }
                s[i+1][j+1].pb(e+(char)('a'+j));
            }
        }
    }
    vector<string>ans(0);
    rep(i,n+1){
        for(auto e:s[n][i]){
            ans.pb(e);
        }
    }
    sort(all(ans));
    rep(i,ans.size()){
        cout<<ans[i]<<endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define endl '\n'

using ull = unsigned long int;
using ll = long long;

template <class Key, class Val>
using hmap = gp_hash_table<Key, Val>;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    const int precision = 13;
    cout.precision(precision);
    cout.setf(ios_base::fixed);

    int n; cin >> n;
    vector<vector<int>> g(n+1);
    for (int i = 0; i < n-1; ++i) {
      int u, v; cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }

    const ll mod = 1e9 + 7;
    vector<vector<ll>> memo(2, vector<ll>(n+1, -1));
    function<ll(int, int, int)> dfs = [&](int u, int par, int col) -> ll {
      ll& ans = memo[col][u];
      if (ans != -1) return ans;

      ans = 1;
      for (int v : g[u]) {
        if (v == par) continue;
        if (col == 0) {
          ans = (ans * (dfs(v, u, 0) + dfs(v, u, 1))) % mod;
        } else {
          ans = (ans * dfs(v, u, 0)) % mod;
        }
      }
      return ans;
    };

    cout << (dfs(1, -1, 0) + dfs(1, -1, 1)) % mod << endl;

    return 0;
}


Measured memory_bytes: 19824
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <unordered_map>
#include <iomanip>

struct Node {
	int mCounter = 0;
	int mNum = 0;
	std::vector<Node*> mChild;
};

using namespace std;

int main() {
	int N, Q; 
	cin >> N >> Q;

	std::vector<Node> nodes;
	nodes.resize(N);

	for (int i = 0; i < N-1; i++) {
		nodes.at(i).mNum = i;
		int parent, child;
		cin >> parent >> child;
		parent--;
		child--;
		nodes.at(parent).mChild.push_back(&(nodes.at(child)));
	}

	for (int i = 0; i < Q; i++) {
		int target, value;
		cin >> target >> value;
		target--;
		nodes.at(target).mCounter += value;
	}

	for (int i = 0; i < N; i++) {
		cout << nodes.at(i).mCounter;
		for (int j = 0; j < nodes.at(i).mChild.size(); j++) {
			nodes.at(i).mChild.at(j)->mCounter += nodes.at(i).mCounter;
		}

		if (i != N - 1) {
			cout << " ";
		}
	}
}



Measured memory_bytes: 14848
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
 int n,tim;
scanf("%d%d",&n,&tim);
int result=-1;
int c[n],t[n];
scanf("%d%d",&c[0],&t[0]);
int min=1001;
if(t[0]<=tim)
{
result=c[0];
min=c[0];
}
for(int i=1;i<n;i++)
{
scanf("%d%d",&c[i],&t[i]);
if(c[i]<=min&&t[i]<=tim)
{
result=c[i];
min=c[i];
}
}

if(result==-1)
printf("TLE");
else
printf("%d",result);
}


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

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

    double sum = 0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else sum += 380000.0 * x;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
S = str(input())
T = input()
arr1 = [i for i in S.split(' ')]
arr2 = [int(j) for j in T.split(' ')]
U = str(input())

if(U == arr1[1]):
	arr2[1] = arr2[1] - 1
	print(str(arr2[0])+' '+str(arr2[1]))
else:
	arr2[0] = arr2[0] - 1
	print(str(arr2[0])+' '+str(arr2[1]))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
}

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

typedef long long ll;

#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
  int n;
  vector<ll> v;
  cin >> n;

  int cnt_ = 0;
  int sum = 0;
  int mn = INF;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    mn = min(mn, abs(tmp));
    if (tmp < 0)
      cnt_++;
    sum += abs(tmp);
  }

  if (cnt_ % 2)
    cout << sum - mn * 2 << endl;
  else
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K; cin >> N >> K;
  vecll LI(N);
  REP(i, N) cin >> LI[i];
  sort(LI.begin(), LI.end());
  ll mm = *LI.begin();
  ll MM = *(LI.end() - 1);
  ll hi = max(MM*MM, mm*mm)+1;
  ll lo = min(min(mm*mm, MM*mm), MM*MM);
  ll value_mid = 0;
  while (hi != lo) {
    ll cnt = 0;
    value_mid = lo+ (hi - lo)/2;
    REP(i, N-1) {
      ll llo = 0, hhi = N-1-i;
      ll mmid = 0;
      while (hhi != llo) {
        mmid = (hhi + llo)/2;
        if (LI[i]*(LI[i] >= 0 ? LI[i+1+mmid] : LI[N-1-mmid]) < value_mid) {
          llo = mmid + 1;
        } else {
          hhi = mmid;
        }
      }
      cnt += llo;
    }
    if (cnt < K) lo = value_mid + 1;
    else hi = value_mid;
  }
  cout << lo-1 << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
using namespace std;

//JAI SHREE KRISHNA

const int MAXN = (ll)1e6+1e5;

ll n;
vector<ll>v1[MAXN];
ll val;
ll dp[MAXN];


void DFS(ll node)
{
    vector<pii>order;
    loop(i,v1[node].size())
    {
        ll to  = v1[node][i];
        DFS(to);
        order.push_back({dp[to],to});
    }
    sort(order.begin(),order.end());
    reverse(order.begin(), order.end());
    loop(i,order.size())
    {
        dp[node] = max(dp[node],order[i].first+i+1);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(ll i=2;i<=n;i+=1)
    {
        ll val;
        cin>>val;
        v1[val].push_back(i);
    }
    DFS(1);
    cout<<dp[1]<<endl;
    return 0;
}


Measured memory_bytes: 39296
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    K,N = map(int,input().split())
    A = list(map(int,input().split()))

    most = A[0] + K - A[-1]

    for i in range(1,N):
        now = A[i] - A[i-1]
        most = max(most,now)

    res = K - most
    print(res)



main()


Measured memory_bytes: 25976
#include <iostream>
#include <math.h>
using namespace std;

int32_t gcm(int32_t a, int32_t b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcm(b, a % b);
  }
}

int main() {
  int32_t n, k;
  cin >> n >> k;
  int32_t a[n];

  int32_t m = 0;
  for (int32_t i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > m) {
      m = a[i];
    }
  }
  if (n >= 2) {
    int32_t g = a[0];
    for (int32_t i = 1; i < n; i++) {
      g = gcm(g, a[i]);
    }
    if (k % g == 0 && k <= m) {
      cout << "POSSIBLE" << endl;
    } else {
      cout << "IMPOSSIBLE" << endl;
    }
  } else {
    if (a[0] == k) {
      cout << "POSSIBLE" << endl;
    } else {
      cout << "IMPOSSIBLE" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 640
a,b,c,d=map(int,input().split())
gcd=lambda a,b:gcd(b,a%b)if a%b else b
def 数学は最強也(a,b):
  q=gcd(a,b)
  return q*((a//q)+(b//q-1))
print(数学は最強也(abs(a-c),abs(b-d)))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    vector<char> S(N);
    REP(i, N) cin >> S[i];
    string res = "Three\n";
    REP(i, N) {
        if (S[i]=='Y') res = "Four\n";
    }
    cout << res;
}


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

int main() {
    int n;
    cin>>n;
    int a[n],t[n];
    long sum=0;
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    int m;cin>>m;
    for(int i=0;i<m;i++){
        int p,x;
        long temp=sum;
        cin>>p>>x;
        temp-=a[p-1];
        temp+=x;
        cout<<temp<<endl;
    }
    return 0;
}

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

ll solve() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            cout << ((j < A) ^ (i < B)) ? 0 : 1;
        }
        cout << "\n";
    }
    cout << "\n";
    return 0;
}

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

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

int main(){
	int m,nmin,nmax,x,res,resmax;
	vector<int> v;
	while(1){
		cin >> m >> nmin >> nmax;
		if(m == 0)break;
		resmax = 0;
		v.clear();
		for(int i = 0;i < m;i++){
			cin >> x;
			v.push_back(x);
		}
		sort(v.begin(),v.end(),greater<int>());
		for(int i = nmin - 1;i < nmax;i++){
			x = v[i] - v[i+1];
			if(x >= resmax){
				res = i + 1;
				resmax = x;
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int main(){
    int S; cin >> S;
    int h = S / 3600;
    int m = (S - h*3600) / 60;
    int s = S - h*3600 - m*60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, b;
    cin >> a >> b;
    cout << max({a+a-1, a+b, b+b-1}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B/2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	long a[] = new long[N];

	for (int i = 0; i < N; i++) {
	    a[i] = Long.parseLong(scan.next());
	}

	long s1 = 0;
	long s2 = 0;
	long count1 = 0;
	long count2 = 0;
	for (int i = 0; i < N; i++) {
	    s1 += a[i];
	    s2 += a[i];
	    if(i%2 == 0) {
		if(s1 <= 0) {
		    count1 += (1-s1);
		    s1 = 1;
		}
		if(s2 >= 0) {
		    count2 += (s2+1);
		    s2 = -1;
		}
	    } else {
		if(s1 >= 0) {
		    count1 += (s1+1);
		    s1 = -1;
		}
		if(s2 <= 0) {
		    count2 += (1-s2);
		    s2 = 1;
		}
	    }
	}

	System.out.println(count1 < count2 ? count1 : count2);
	scan.close();
    }
}


Measured memory_bytes: 48984
// Example program
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int seg, hr, min;
  cin>>seg;
  hr = seg / (60*60);
  seg %= 60*60;
  min = seg / 60;
  seg %= 60;
  cout<<hr<<":"<<min<<":"<<seg<<endl;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2) {
		cout << "Odd";
	}
	else
	{
		cout << "Even";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();

        long cR = 0;
        long cG = 0;
        long cB = 0;
        

        for(int i = 0; i < n; i++){
            if(c[i] == 'R'){
                cR++;
            }
            else if(c[i] == 'G'){
                cG++;
            }
            else if(c[i] == 'B'){
                cB++;
            }
        }

        // System.out.println(cR + " " + cG + " " + cB);

        long cnt = cR*cG*cB;

        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n ; j++){
                int k = 2*j-i;
                if(n <= k)continue;
                if(c[i] != c[j] && c[j] != c[k] && c[i] != c[k])cnt--;
            }
        }

        if(cnt >= 0)System.out.println(cnt);
        else System.out.println(0);
        sc.close();
    }
}


Measured memory_bytes: 36004
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
ll MOD=1e9+7;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%13;
        a=a*a%13;
        x>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    vector<int> co(1e5+1,0),ce(1e5+1,0);
    for(int i=0;i<n;i++){
        if(i%2==0) co[v[i]]++;
        else ce[v[i]]++;
    }
    int o1,o2,e1,e2;
    o1=o2=e1=e2=-1;
    int mo=-1,me=-1;
    for(int t=0;t<2;t++){
        vector<int> cx=(t==0?co:ce);
        int& x1=(t==0?o1:e1);
        int& x2=(t==0?o2:e2);
        int& mx=(t==0?mo:me);
        for(int i=1;i<=1e5;i++){
            if(x1==-1){
                x1=cx[i];
                mx=i;
            }else if(x2==-1){
                if(x1<cx[i]){
                    x2=x1;
                    x1=cx[i];
                    mx=i;
                }else{
                    x2=cx[i];
                }
            }else if(x1<cx[i]){
                x2=x1;
                x1=cx[i];
                mx=i;
            }else if(x2<cx[i]){
                x2=cx[i];
            }
        }
    }
    if(mo!=me){
        cout<<n-(o1+e1)<<endl;
    }else{
        cout<<n-max(o1+e2,o2+e1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 4844
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	foreach (line; stdin.byLine) {
		auto inp = line.chomp.split.map!(to!int);
		if (inp[0] == 0) break;
		immutable a = inp[1],
		b = inp[2],
		c = inp[3];
		auto x = inp[4];
		auto tar = readln.chomp.split.map!(to!int);
		int cnt, fi;
		while (cnt <= 10000) {
			if (tar[fi] == x) fi++;
			if (fi == inp[0]) break;
			cnt++;
			x = (a*x+b) % c;
		}
		if (cnt == 10001) writeln(-1);
		else writeln(cnt);
	}
}

Measured memory_bytes: 1604
h, w = map(int, input().split())
s = [input() for _ in range(h)]
dp = [[0]*w for _ in range(h)]
if s[0][0] == "#": dp[0][0]=1
for i in range(1, w):
    if s[0][i] == "#" and s[0][i-1] != "#": dp[0][i] = dp[0][i-1]+1
    else: dp[0][i] = dp[0][i-1]
for i in range(1, h):
    if s[i][0] == "#" and s[i-1][0] != "#": dp[i][0] = dp[i-1][0]+1
    else: dp[i][0] = dp[i-1][0]
for i in range(1,h):
    for j in range(1,w):
        if s[i][j] == "#" and s[i-1][j] != "#": res1 = dp[i-1][j]+1
        else: res1 = dp[i-1][j]
        if s[i][j] == "#" and s[i][j-1] != "#": res2 = dp[i][j-1]+1
        else: res2 = dp[i][j-1]
        dp[i][j] = min(res1, res2)
print(dp[h-1][w-1])

Measured memory_bytes: 3188
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val a = Scanner.nextInt()
  val b = Scanner.nextInt()
  val t = Scanner.nextInt()

  println((t/a)*b)
}

Measured memory_bytes: 25424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; ++i) {
        if (n % i == 0) {
            int t = n / i;
            if (t <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stack>
#include <string>
#include<cstdlib>
#include <iostream>

using namespace std;

int main()
{
	stack<int> data;
	string str[1000];
	int a;
	int b1;
	int b2;
	int c=0;
	while(cin>>str[c]){
		if(str[c]!="+" && str[c]!="-" && str[c]!="*"&& str[c]!="/"){
			a=atoi(str[c].c_str());
			data.push(a);
			c++;
		}
		if(str[c]=="+"){
			b1=data.top();
			data.pop();
			b2=data.top();
			data.pop();
			data.push(b1+b2);
		}
		if(str[c]=="-"){
			b1=data.top();
			data.pop();
			b2=data.top();
			data.pop();
			data.push(b2-b1);
		}
		if(str[c]=="*"){
			b1=data.top();
			data.pop();
			b2=data.top();
			data.pop();
			data.push(b1*b2);
		}
	}
	cout<<data.top()<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i=0; i<H; i++) cin >> S.at(i);
  
  int sharp = 0, field = H*W;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if( S.at(i).at(j) == '#' ) sharp++;
    }
  }
  queue<pair<int,int>> q;
  q.push( make_pair(0,0));
  vector<vector<int>> time(H, vector<int>(W, -1));
  vector<int> xm = {-1, 0, 1, 0};
  vector<int> ym = { 0,-1, 0, 1};
  
  time.at(0).at(0) = 1;
  while (!q.empty()) {
    pair<int,int> s = q.front();
    int sx = s.first;
    int sy = s.second;
    q.pop();
    
    for(int i=0; i<4; i++) {
      int x = sx + xm.at(i);
      int y = sy + ym.at(i);
      if ( x < 0 || W <= x || y < 0 || H <= y) continue;
      if ( S.at(y).at(x) == '#') continue;
      if (time.at(y).at(x) == -1 ) {
        q.push( make_pair(x,y));
        time.at(y).at(x) = time.at(sy).at(sx) + 1;
      }
    }
  }
  if (time.at(H-1).at(W-1) == -1) cout << -1 << endl;
  else cout << field - time.at(H-1).at(W-1) - sharp << endl;

}

Measured memory_bytes: 256
import math
def isPrime(n):
    limit = int(math.sqrt(n))
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    else:
        for i in range(3,limit + 1, 2):
            if n % i == 0:
                return False
    return True

X = int(input())
for n in range(X, 1000000):
    if isPrime(n):
        print(n)
        break



Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10],op;
    int i,j,b[10];
    while(scanf("%s",a)==1)
    {
        op='a',b[0]=0,b[1]=0,b[2]=0;
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(a[j]==op)
                {
                    op++;
                    b[j]=1;
                    break;
                }
            }
        }
        for(i=0;i<3;i++)
        {
            if(b[i]==0)
            {
                printf("No\n");
                break;
            }
        }
        if(i==3)
            printf("Yes\n");

    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
	int x, i, t;
	x = A[r];
	i = p - 1;
	for (int j = p; j < r; ++j) {
		if (A[j] <= x) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

int main() {
	int q;

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);

	q = partition(0, n - 1);

	for (int i = 0; i < n; ++i) {
		if (i) printf(" ");
		if (i == q) printf("[");
		printf("%d", A[i]);
		if (i == q) printf("]");
	}
	printf("\n");
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod>
struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x (y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    Mod_Int &operator += (const Mod_Int &p){
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p){
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p){
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p){
        *this *= p.inverse();
        return *this;
    }

    Mod_Int &operator ++ () {return *this += Mod_Int(1);}

    Mod_Int operator ++ (int){
        Mod_Int tmp = *this;
        ++*this;
        return tmp;
    }

    Mod_Int &operator -- () {return *this -= Mod_Int(1);}

    Mod_Int operator -- (int){
        Mod_Int tmp = *this;
        --*this;
        return tmp;
    }

    Mod_Int operator - () const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int inverse() const {
        assert(*this != Mod_Int(0));
        return pow(mod-2);
    }

    Mod_Int pow(ll k) const{
        Mod_Int now = *this, ret = 1;
        while(k){
            if(k&1) ret *= now;
            now *= now, k >>= 1;
        }
        return ret;
    }

    friend ostream &operator << (ostream &os, const Mod_Int &p){
        return os << p.x;
    }

    friend istream &operator >> (istream &is, Mod_Int &p){
        ll a;
        is >> a;
        p = Mod_Int<mod>(a);
        return is;
    }
};

using mint = Mod_Int<MOD>;

int main(){
    int N;
    cin >> N;
    mint A[N];
    mint s = 0, ans = 0;
    rep(i, N){
        cin >> A[i];
        s += A[i], ans -= A[i]*A[i];
    }
    ans += s*s;
    cout << ans/2 << endl;
}

Measured memory_bytes: 5152
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

string left_str = "qwertasdfgzxcvb";
int GetType(string c)
{
  return (left_str.find(string(c)) == string::npos) ? 0 : 1;
}

int main()
{
  string str;
  while (cin >> str && str != "#") {
    int type = GetType(str.substr(0, 1)), ret = 0;
    for (int i = 1; i < str.size(); i++) {
      if (GetType(str.substr(i, 1)) != type) {
        ret++;
      }
      
      type = GetType(str.substr(i, 1));
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 0
from math import sqrt
N,D,A=[int(x)for x in input().split()]+[[]];exec("A+=[[int(x)for x in input().split()]];"*N);C=0
for i in range(N):
    for j in range(i+1,N):
        S=k=0;exec("S+=(A[i][k]-A[j][k])**2;k+=1;"*D);C+=1 if int(sqrt(S))==sqrt(S) else 0
print(C)


Measured memory_bytes: 3060
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count =0;
		int max =0;
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)=='A'||s.charAt(i)=='C'||s.charAt(i)=='G'||s.charAt(i)=='T') {
				count ++;
				if (max<count) {
					max = count;
				}
			} else {
				count =0;
			}
		}
		System.out.println(max);
	}
}

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

int main(){
  int a,b,c,d,e,f,w,s,W,S,maxs;
  double maxc=0;
  cin>>a>>b>>c>>d>>e>>f;
  for(int i=0;i*a*100<=f;i++){
      for(int j=0;(i*a+j*b)*100<=f;j++){
          w=(i*a+j*b)*100;
          maxs=min(f-w,w/100*e);
          for(int k=0;k*c<=maxs&&k<30;k++){
              s=(maxs-k*c)/d*d+k*c;
              if(maxc<=(double)s*100/(w+s)){
                  maxc=(double)s*100/(w+s);
                  W=w;
                  S=s;
              }
          }
      }
  }
  
  
  cout<<W+S<<" "<<S<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll int d,t,s;
 	cin>>d>>t>>s;
 	s*=t;
 	if(s>=d)
 		cout<<"Yes";
 	else
 		cout<<"No";
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

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

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    init();

    vl rui(101010);  // rui[i] : inv[0]からinv[i]までの和
    rui[1] = 1;
    rep(i, n) {
        rui[i+2] = (rui[i+1] + inv[i+2])%mod;
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i]*(rui[i+1] + rui[n-i] - 1)%mod;
        ans %= mod;
    }
    ans *= fact[n];
    ans %= mod;

    out(ans);
    re0;
};

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> N;
    int X ,Y;
    cin >> X  >> Y;
    --X; --Y;
    ll d[N][N];
    ll ans[N];
    REP(i, N) ans[i] = 0;
    REP(i, N){
        for(int j = i + 1; j <N; ++j){
            d[i][j] = min(abs(j-i), abs(X-i) + 1 + abs(Y-j));
            //cout << i << " " << j << " " << d[i][j] << "\n";
            ++ans[d[i][j]];
        }
    }
    REP(i,N-1) cout << ans[i + 1] << "\n";
    return 0;
}

Measured memory_bytes: 31360
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

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

Measured memory_bytes: 128
import sys


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


def get_sum(x1, x2, y1, y2):
    return acc[x2][y2] - acc[x1][y2] - acc[x2][y1] + acc[x1][y1]


h, w, k = map(int, input().split())
s = [[int(c) for c in input()] for i in range(h)]

acc = [[0 for j in range(w + 1)] for i in range(h + 1)]
for i in range(h):
    for j in range(w):
        acc[i + 1][j + 1] = acc[i][j + 1] + acc[i + 1][j] - acc[i][j] + s[i][j]

ans = h + w

for h_div in range(1 << (h - 1)):
    h_ranges = []
    h_begin = 0
    for i in range(h - 1):
        if h_div >> i & 1:
            h_ranges.append([h_begin, i + 1])
            h_begin = i + 1
    h_ranges.append([h_begin, h])
    div_cnt = len(h_ranges) - 1

    def is_addable():
        for h_range in h_ranges:
            if get_sum(h_range[1], h_range[0], j + 1, w_begin) > k:
                return False
        return True

    w_begin = 0
    for j in range(w):
        if not is_addable():
            w_begin = j
            div_cnt += 1
            if not is_addable():
                div_cnt = h + w
                break
    ans = min(ans, div_cnt)

print(ans)


Measured memory_bytes: 3436
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
              
main ()


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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
	
	int x, y;
	cin >> x >> y;
	if(x < y) swap(x, y);
	if((x + y) % 3 != 0){
		cout << 0 << endl;
		return 0;
	}
	if(x / y > 2){
		cout << 0 << endl;
		return 0;
	}
	int i = (x+y)/3;
	int j = (-x+2*y)/3;
	
	// 前処理
	COMinit();
	
	cout << COM(i, j) << endl;
	return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <string>

using namespace std;


int main(){
    
    string s, t, p;

    cin >> s >> p;
    t = s + s;

    if(t.find(p)==-1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;;
    }

    return 0;
}




Measured memory_bytes: 3216
#include <stdio.h>
s[1000],i,c=0;
main(n)
{
float w,t;
while(scanf("%d,%f,%f",&n,&w,&t)!=-1)
if(w/(t*t)>=25)s[c++]=n;
if(c==1)printf("ツ該ツ督鳴づ按つオ");
for(i=0;i<c;i++)printf("%d\n",s[i]);
return 0;
}

Measured memory_bytes: 0
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  vi a(3);

  rep(i,3)
  {
    cin >> a[i];
  }
  vsort(a);

  cout << a[0] + a[1] << endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Dice {
 public:
  int dice[6];
  Dice(int a, int b, int c, int d, int e, int f) {
	dice[0] = a;
	dice[1] = b;
	dice[2] = c;
	dice[3] = d;
	dice[4] = e;
	dice[5] = f;
  }
  void roll(char ch) {
	if(ch == 'N') {
	  rollN();
	}
	else if(ch == 'E') {
	  rollE();
	}
	else if(ch == 'S') {
	  rollS();
	}
	else {
	  rollW();
	}
  }
  void rollN() {
	swap(dice[0], dice[1]);
	swap(dice[1], dice[5]);
	swap(dice[5], dice[4]);
  }
  void rollS() {
	swap(dice[0], dice[4]);
	swap(dice[4], dice[5]);
	swap(dice[5], dice[1]);
  }
  void rollE() {
	swap(dice[0], dice[3]);
	swap(dice[3], dice[5]);
	swap(dice[5], dice[2]);
  }
  void rollW() {
	swap(dice[0], dice[2]);
	swap(dice[2], dice[5]);
	swap(dice[5], dice[3]);
  }
  void spinL() {
	swap(dice[1], dice[2]);
	swap(dice[2], dice[4]);
	swap(dice[4], dice[3]);
  }
  int top() {
	return dice[0];
  }
  int front() {
	return dice[1];
  }
  int right() {
	return dice[2];
  }
};
int right(Dice d1, int top, int front) {
	for(int i = 0; i < 4; ++i) {
	  if(d1.top() == top) break;
	  d1.rollE();
	}
	for(int i = 0; i < 4; ++i) {
	  if(d1.top() == top) break;
	  d1.rollN();
	}
	for(int i = 0; i < 4; ++i) {
	  if(d1.front() == front) break;
	  d1.spinL();
	}
	return d1.right();
}
string isSame(Dice d1, Dice d2) {
  if(right(d1, d1.dice[0], d1.dice[1]) == right(d2, d1.dice[0], d1.dice[1]) && right(d1, d1.dice[3], d1.dice[4]) == right(d2, d1.dice[3], d1.dice[4])) {
	return "Yes";
  }
  else {
	return "No";
  }

}
int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  Dice d1(a, b, c, d, e, f);
  cin >> a >> b >> c >> d >> e >> f;
  Dice d2(a, b, c, d, e, f);
  cout << isSame(d1, d2) << endl;

  return 0;
}

Measured memory_bytes: 3160