akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ld n,m,d;
    cin>>n>>m>>d;
    if(d==0){
        printf("%.7Lf\n",(n-d)*(m-1)/(n*n));
    } else {
        printf("%.7Lf\n",2*(n-d)*(m-1)/(n*n));
    }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
    fastio();
    string s;
    int k;
    cin>>k>>s;
    int len = s.size();
    if(len<=k) cout<<s<<endl;
    else {
        rep(i,0,len-1){
            cout<<s[i];
            if(i%k==k-1) {cout<<"...";return 0;}
        }
        //cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

/********************Template********************/

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

	int n;
	cin >> n;

	if(n % 2 == 0) cout << (n/2)*(n/2) << endl;
	else cout << (n/2)*(n/2 +1) << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
int main() {

int n;
cin >> n;
vector<int> field(n+1);
rep(i,n+1)
{cin >> field[i];}
sort(field.begin(),field.end());

int ans=field[1]-field[0];
rep(i,field.size()-1)
{ //cout << ans <<endl;
  int gap=field[i+1]-field[0];
  ans=gcd(ans,gap);
}


cout << ans<<endl;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

bool dp[85][85][13000];  // マス(y,x)までに差をaにできるか?
// ====================================================================

int main() {
  ll h, w;
  cin >> h >> w;

  // 2次元配列2つに突っ込む
  int ga[h][w], gb[h][w];
  for (int i = 0; i < h * w; i++) cin >> ga[0][i];
  for (int i = 0; i < h * w; i++) cin >> gb[0][i];

  // for (int y = 0; y < h; y++) {
  //   for (int x = 0; x < w; x++) {
  //     cout << gb[y][x] << " ";
  //   }
  //   cout << endl;
  // }

  memset(dp, 0, sizeof(dp));
  dp[0][0][abs(ga[0][0] - gb[0][0])] = true;

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      // cout << "-------" << endl;
      // cout << "now = " << y << " " << x << endl;
      // cout << "{";
      // for (int i = 0; i < 13000; i++)
      //   if (dp[y][x][i]) cout << i << " ";
      // cout << "}" << endl;

      if (y + 1 < h) {                                 // 下に行けるなら、遷移する
        int shita = abs(ga[y + 1][x] - gb[y + 1][x]);  // 下側で作れる差
        // cout << "shita=" << shita << endl;
        for (int d = 0; d < 13000; d++) {
          if (abs(shita + d) < 13000) dp[y + 1][x][abs(shita + d)] |= dp[y][x][d];
          if (abs(shita - d) < 13000) dp[y + 1][x][abs(shita - d)] |= dp[y][x][d];
        }
      }
      if (x + 1 < w) {                                // 右に行けるなら、遷移する
        int migi = abs(ga[y][x + 1] - gb[y][x + 1]);  // 右側で作れる差
        // cout << "migi=" << migi << endl;
        for (int d = 0; d < 13000; d++) {  // 自分が作れる差
          if (abs(migi + d) < 13000) dp[y][x + 1][abs(migi + d)] |= dp[y][x][d];
          if (abs(migi - d) < 13000) dp[y][x + 1][abs(migi - d)] |= dp[y][x][d];
        }
      }
    }
  }

  for (int i = 0; i < 13000; i++) {
    if (dp[h - 1][w - 1][i]) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 92032
s = [input() for i in range(2)]
l1=s[0].split(" ")
l2=s[1].split(" ")

d=int(l1[0])
h_c=0
for h in l2:
  h_c+=int(h)
  
if h_c > d:
  print(-1)
else:
  print(d-h_c)
  

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

signed main(){
    int n;
    cin >> n;
    int ans=0;
    rep(i,n-1){
        ans+=i+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int, int>
#define y1 skldjfskldjg
#define y2 skldfjsklejg

using namespace std;

const int N = 7e5 + 7;
const int M = 1e5 + 7;
const int inf = 0x3f3f3f3f;


int n, m, tot, head[N], all, d[N], que[2000100];

struct Edge {
    int u, v, w, nx;
} edge[4000100];

struct node {
    int u, v, w, id;
    bool operator < (const node &rhs) const {
        return w < rhs.w;
    }
} a[N];

vector<node> vec[100001];

void add(int u, int v, int w) {
    edge[tot].u = u;
    edge[tot].v = v;
    edge[tot].w = w;
    edge[tot].nx = head[u];
    head[u] = tot++;
}

void init() {
    all = m + 1; tot = 0;
    for(int i = 0; i <= all; i++) head[i] = -1;
    for(int i = 1; i <= n; i++) vec[i].clear();
}

int Dij(int S, int T) {
    for(int i = 0; i <= all; i++) d[i] = inf;
    int l = 1000001, r = 1000000;
    d[S] = 0; que[++r] = S;
    while(l <= r) {
        int u = que[l++];
        if(u == T) return d[u];
        for(int i = head[u]; ~i; i = edge[i].nx) {
            int v = edge[i].v, w = edge[i].w;
            if(d[v] != inf) continue;
            if(w == 0) {
                d[v] = d[u];
                que[--l] = v;
            } else {
                d[v] = d[u] + w;
                que[++r] = v;
            }
        }
    }
    return -1;
}

inline int read() {
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}

int main() {
    while(scanf("%d%d", &n, &m) != EOF) {
        init();
        for(int i = 1; i <= m; i++) {
            a[i].u = read();
            a[i].v = read();
            a[i].w = read();
            a[i].id = i;
            vec[a[i].u].push_back(a[i]);
            vec[a[i].v].push_back(a[i]);
        }

        for(int i = 1; i <= n; i++) {
            sort(vec[i].begin(), vec[i].end());
            if(vec[i].size() <= 1) continue;
            head[++all] = -1;
            int root = all;
            for(int j = 0; j < vec[i].size(); j++) {
                if(!j || vec[i][j].w != vec[i][j - 1].w) {
                    add(root, vec[i][j].id, 1);
                    add(vec[i][j].id, root, 1);
                    head[++all] = -1;
                }
                add(all, vec[i][j].id, 0);
                add(vec[i][j].id, all, 0);
            }
        }

        for(int i = 1; i <= m; i++) {
            if(a[i].u == 1 || a[i].v == 1) {
                add(0, a[i].id, 0);
                add(a[i].id, 0, 0);
            }
            if(a[i].u == n || a[i].v == n) {
                add(m + 1, a[i].id, 0);
                add(a[i].id, m + 1, 0);
            }
        }
        int ans = Dij(0, m + 1);
        if(ans < 0) printf("%d\n", ans);
        else printf("%d\n", ans / 2 + 1);
    }
    return 0;
}
/********************
7 6
1 7 1
1 3 2
2 4 3
3 4 4
2 5 5
3 6 6
********************/


/*
*/


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

using namespace std;

int main() {
  int H, W;
  scanf("%d %d", &H, &W);
  while (H || W) {
    for (int i = 0; i < W; i++) {
      printf("#");
    }
    printf("\n");
    for (int i = 1; i < H - 1; i++) {
      printf("#");
      for (int j = 1; j < W - 1; j++) {
        printf(".");
      }
      puts("#");
    }
    for (int i = 0; i < W; i++) {
      printf("#");
    }
    puts("\n");
    scanf("%d %d", &H, &W);
  }
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
ll n;
cin>>n;
vector<ll> v(n);
vector<ll> rui(n+1,0);
rep(i,n){
    cin>>v[i];
    rui[i+1]=rui[i]+v[i];
    rui[i+1]%=MOD;
}

ll ans = 0;
rep(i,n-1){

    ll x = (rui[n]-rui[i+1]);
    if(x<0)x+=MOD;
    x%=MOD;
    x*=v[i];
    x%=MOD;
    ans+=x;
    ans%=MOD;
}

cout<<ans<<endl;







    
return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string T[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

    REP(i, 7) {
        if (T[i] == S) {
            cout << (7 - i) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a*n) << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Strange Bank
            int n = int.Parse(Console.ReadLine());
            int minCount = n;
            
            for(int i = 0; i <= 11111; i++)
            {
                if(i * 9 > n)
                {
                    break;    
                }
                else
                {
                    int rest = n - i * 9;
                    int remainder = rest % 6;
                    
                    int count = DrawerNineYen(i * 9);
                    count += DrawerSixYen(rest - remainder);
                    count += remainder;
                    
                    if(count < minCount)
                    {
                        minCount = count;    
                    }
                }
            }
            
            Console.WriteLine(minCount);
        }
        
        static int DrawerNineYen(int money)
        {
            int count = 0;
            var nines = new int[] { 59049, 6561, 729, 81, 9 };
            
            foreach(var nine in nines)
            {
                count += money / nine;
                money %= nine;
            }
            
            return count;
        }
        
        static int DrawerSixYen(int money)
        {
            int count = 0;
            var sixs = new int[] { 46656, 7776, 1296, 216, 36, 6 };
            
            foreach(var six in sixs)
            {
                count += money / six;
                money %= six;
            }
            
            return count;
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,p,a=0,b=0;

    cin>>n;
    int ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
    }
    p=1;
    for(i=0;i<n;i++){
        if(p==ara[i]){
            p++;b=1;
           // cout<<p<<endl;
        }

    }
    if(b==0){
        cout<<-1<<endl;
    }
    else{cout<<n-p+1<<endl;}

    return EXIT_SUCCESS;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, k, s; cin >> n >> k >> s;
	vector<Int> a(n);
	for(Int i=0; i<k; ++i) a[i] = s;
	for(Int i=k; i<n; ++i) a[i] = (s == 1e9 ? 1e9-1 : 1e9);
	for(Int i=0; i<n; ++i)
		cout << a[i] << " \n"[(i+1 == n)];
}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-

while True:
    try:
        A, B = input().split(), input().split()
        hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ])
        blow = sum([ 1 for i in range(len(A)) if B[i] in A ]) - hit
        print(str(hit) + ' ' +str(blow))
    except:
        break


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

void fnInput(vector<double>& rvnValue)
{
  int nValueSiz;
  cin >> nValueSiz;
  rvnValue.resize(nValueSiz);

  for(double& rnValue : rvnValue)
    cin >> rnValue;
}
  
double fnMaxValueGet(const vector<double>& cnrvnValue)
{
  vector<double> vnAscValue(cnrvnValue);

  while (vnAscValue.size() > 1)
  {
    sort(begin(vnAscValue), end(vnAscValue));
    auto it = begin(vnAscValue);
    double nAveValue = ( *it + *(it + 1) ) / 2;

    vnAscValue.erase(it, it + 2);
    vnAscValue.push_back(nAveValue);
  }
  return vnAscValue[0];
}
  
int main()
{
  vector<double> vnValue;

  fnInput(vnValue);
  cout << fnMaxValueGet(vnValue) << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $x);
$arr = explode(' ', trim(fgets(STDIN)));
sort($arr);

$count = 0;
$tmpx = $x;
if ($x == array_sum($arr)) {
  printf("%d\n",$N);
} else {
  for ($i = 0; $i < $N; $i++) {
    $tmpx -= $arr[$i];
    if ($tmpx >= 0) {
      $count++;
    } else {
      break;
    }
  }
  if ($tmpx > 0) $count--;
  printf("%d\n",$count);
}
?>

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

int main() {
  string s; cin >> s;
  int a[26] = {};
  for (int i = 0; i < s.size(); i++) a[s[i] - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (a[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

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

int main() {
	int n,d;
	cin >> n;
	d = n%10;
	if((d==2)||(d==4)||(d==5)||(d==7)||(d==9)){
		cout << "hon" << endl;
	}
	else if((d==0)||(d==1)||(d==6)||(d==8)){
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
	return 0;
}

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

int main() {
	int N, n1, n2, n3, n4;
	cin >> N;
	n1 = N / 1000;
	n2 = N / 100 - n1 * 10;
	n4 = N % 10;
	n3 = (N % 100 - n4) / 10;
	if (n1 == n2 && n2 == n3) {
		cout << "Yes" << endl;
	} else if (n2 == n3 && n3 == n4) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c;
    string str;
    cin >> a >> b >> c;
    if (a == b && a != c || a == c && a != b || b == c && b != a)
    {
        str = "Yes";
    }
    else
    {
        str = "No";
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
      myout((one.get(0) - 1) * (one.get(1) - 1));
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32888
#include <bits/stdc++.h>
#define MAX_N 100000
#define INF 0x3f3f3f3f
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[MAX_N+5][3], f[MAX_N+5][3];
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i][0]), read(a[i][1]), read(a[i][2]);
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++) if (j ^ k)
				f[i][j] = max(f[i][j], f[i-1][k]+a[i][j]);
	return printf("%d\n", max(max(f[n][0], f[n][1]), f[n][2])), 0;
}


Measured memory_bytes: 2560
_MULTITEST = False
##
def solve():
    D = {
        "AC" : 0,
        "WA" : 0,
        "TLE" : 0,
        "RE" : 0
    }

    n = int(input())
    for i in range(n):
        verdict = str(input())
        D[verdict] = D[verdict]+1
    print("AC x ", D["AC"])
    print("WA x ", D["WA"])
    print("TLE x ", D["TLE"])
    print("RE x ", D["RE"])

##
if __name__ == "__main__":
    t = (int(input()) if _MULTITEST else 1)
    for tt in range(t):
        solve()

Measured memory_bytes: 69868
def solve():
    N,M = [int(i) for i in input().split()]
    digits = ['0'] * N
    digits[0] = '0' if N == 1 else '1'
    targets = set([])
    for i in range(M):
        s,c = [int(num) for num in input().split()]
        target = s - 1
        if target == 0 and c == 0 and N != 1:
            digits = ['-1']
            break
        if target in targets and str(c) != digits[target]:
            digits = ['-1']
            break
        else:
            digits[s-1] = str(c)
            targets.add(s-1)
    print(''.join(digits))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9148
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    cond do
    a <= 5 -> 
    IO.puts(0) 
    a <= 12 ->
    IO.puts(div(b, 2))
    a >= 13 ->
    IO.puts(b)
    end
  end
end


Measured memory_bytes: 30784
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]
t=list(map(int,input().split()))
ans=0
for i in range(2**n):
  bit=[i>>j & 1 for j in range(n)]
  for k,x in enumerate(s):
    if t[k]!=sum([bit[y-1] for y in x[1:]])%2:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split())) # A_1からA_M

l = 0
r = 0
for i in range(M):
    if A[i] < X:
        l += 1
    else:
        r += 1

ans = min(l, r)
print(ans)


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

int main()
{
  int64_t A, B, C, a, b, X, Y, cost, ans = 5000 * 100000 * 2;
  cin >> A >> B >> C >> X >> Y;
  int64_t maxc = max(X, Y) * 2;
  for (int64_t c = 0; c <= maxc; c += 2)
  {
    a = (X - c / 2) >= 0 ? (X - c / 2) : 0;
    b = (Y - c / 2) >= 0 ? (Y - c / 2) : 0;
    cost = A * a + B * b + C * c;
    ans = cost < ans ? cost : ans;
    cost = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	// 繰り上げ金額の単位(円)
	private static final int ROUND_UNIT = 1000;

	// 利子
	private static final double LOAN_INTEREST = 1.05;

	/**
	 * 返済額計算実行
	 */
	public static void main(String[] args) throws Exception {

		// 標準入力
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		// 返済額の計算
		new Main().calcAmountRepaid(Integer.parseInt(reader.readLine()));
	}

	/**
	 * 返済額計算
	 */
	private void calcAmountRepaid(int weekNum) {

		// 借金10万円を初期値とする
		int debt = 100000;

		// 週単位で返済額を計算
		for (int i = 0; i < weekNum; i++) {

			// 利子込みの返済額を計算
			debt *= LOAN_INTEREST;

			// 計算結果から1000円未満を切り上げ
			if (debt % ROUND_UNIT != 0) {
				debt = ROUND_UNIT * (debt / ROUND_UNIT + 1);
			} else {
				debt = ROUND_UNIT * (debt / ROUND_UNIT);
			}

		}

		// 結果出力
		System.out.println(debt);

	}

}

Measured memory_bytes: 16860
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans, rem;
    if(a + b > c * 2){ //ABを2枚買った方が安い時
        ans = c*2 * min(x, y);
        if(x < y){
            rem = y - x;//Bの残った枚数
            if(b > c * 2){
                ans += rem * c * 2;
            }
            else{
                ans += rem * b;
            }
        }else{
            rem = x - y;//Aの残った枚数
            if(a > c * 2){
                ans += rem * c * 2;
            }
            else{
                ans += rem * a;
            }
        }
    }
    else{
        ans = a * x + b * y;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int N = 5e3 + 10;
int n, m, p;
int num[N], dis[N], inq[N];
bool ok[N], vis[N];
int to[N << 1], nxt[N << 1], lnk[N], cnt, val[N << 1];
queue<int> q;

void add(int x, int y, int z) {
    to[++cnt] = y, nxt[cnt] = lnk[x], lnk[x] = cnt, val[cnt] = z;
}

void spfa() {
    memset(dis, ~0x3f, sizeof(dis));
    q.push(1);
    dis[1] = 0;
    inq[1] = 1;
    while (q.size()) {
        int x = q.front(); q.pop();
        inq[x] = 0;
        for (int i = lnk[x]; i; i = nxt[i]) {
            int y = to[i], z = val[i];
            if (!ok[y]) continue;
            if (dis[y] < dis[x] + z) {
                dis[y] = dis[x] + z;
                if (!inq[y]) {
                    inq[y] = 1;
                    ++num[y];
                    if (num[y] >= n) { puts("-1"); return; }
                    q.push(y);
                }
            }
        }
    }
    printf("%d\n", max(0, dis[n]));
}

bool dfs(int x) {
    if (vis[x]) return 0;
    if (x == n) return 1;
    vis[x] = 1;
    for (int i = lnk[x]; i; i = nxt[i]) {
        int y = to[i];
        if (dfs(y)) return 1;
    }
    return 0;
}

int main() {
    cin >> n >> m >> p;
    rep(i, 1, m) {
        int x, y, z; scanf("%d%d%d", &x, &y, &z);
        add(x, y, z - p);
    }
    rep(i, 1, n) {
        memset(vis, 0, sizeof(vis));
        ok[i] = dfs(i);
    }
    spfa();
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
typedef long long ll;
const int mod=1000000007;
const ll MAX=1000000000000000000ll;
ll f[100];
int lim;
struct Point{ll x,y;}a[100][100];
int calc(ll X,ll Y){
	if(X>Y)return calc(Y,X);
	int i=1;
	while(i+1<lim&&X>=f[i+1]&&Y>=f[i+2])i++;
	printf("%d ",i);
	if(i==1)return X%mod*(Y%mod)%mod;
	ll s=0;
	for(Point*p=a[i];p<=a[i]+i;p++)if(p->x<=X&&p->y<2*p->x){
		if(p->y<=Y)s+=(Y-p->y)/p->x+1;
		if(p->y<=X)s+=(X-p->y)/p->x+1;
		s%=mod;
	}
	return s;
}
int main(){
	lim=1,f[0]=f[1]=1;
	for(;f[lim-1]+f[lim]<=MAX;lim++)f[lim+1]=f[lim-1]+f[lim];
	a[1][0]=(Point){1,2};
	a[1][1]=(Point){1,3};
	for(int i=2;i<lim;i++){
		for(Point*j=a[i-1],*k=a[i];j<a[i-1]+i;j++){
			*k++=(Point){j->y,j->x+j->y};
			if(j->x==f[i-1]&&j->y==f[i])*k++=(Point){j->y,j->x+j->y*2};
		}
	}
	int Q;scanf("%d",&Q);
	while(Q--){
		ll X,Y;
		scanf("%lld%lld",&X,&Y);
		printf("%d\n",calc(X,Y));
	}
}

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

int main() {
    int N, a;
    cin >> N;
    vector<int> btn(N + 1);
    rep(i, N){
        cin >> a;
        btn[i + 1] = a;
    }
    int now = 1, count = 0;
    vector<bool> used(N + 1, false);
    while (true){
        now = btn[now];
        count++;
        if (now == 2){
            cout << count << endl;
            break;
        }
        else if (!used[now]){
            used[now] = true;
        }
        else{
            cout << -1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base;
		String comparison;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
			
			Inversions(base, comparison, br);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		StringBuilder sb = new StringBuilder();
		int length = base.length() - comparison.length();
		String 	container;
		int ans_num = 0;
		int[] ans = new int[1000000];
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				ans[ans_num] = i;
				ans_num ++;
			}
		}
		
		for(int i = 0; i <ans_num; i++){;
			sb.append(ans[i] + "\n");
		}
		 
		System.out.print(sb);
	}
}


Measured memory_bytes: 28416
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int bound(int k, int N, int *b){
	int l = -1, h, r = N;
	while(r - l > 1){
		h = (l + r) / 2;
		if(b[h] < k){
			l = h;
		}
		else{
			r = h;
		}
	}
	return r;
}

int main(){
	int N, i, j, ans = 0, xor, dig, cov;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%d", &b[i]);
	}
	for(i = 28; i >= 0; i--){
		dig = 1 << i, cov = (dig << 1) - 1;
		xor = N & 1;
//		printf("i = %d\n", i);
		for(j = 0; j < N; j++){
			a[j] &= cov;
			b[j] &= cov;
		}
		sort(b, N);
/*		for(j = 0; j < N; j++){
			printf("b[%d] = %d\n", j, b[j]);
		}
*/		for(j = 0; j < N; j++){
			xor ^= bound(1 * dig - a[j], N, b) & 1;
			xor ^= bound(2 * dig - a[j], N, b) & 1;
			xor ^= bound(3 * dig - a[j], N, b) & 1;
		}
//		printf("xor = %d\n", xor);
		ans |= (xor << i);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl '\n'



using namespace std;
ll exp(ll a,ll b,ll m)
{
if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


	
int main()
{
	int n;
	cin>>n;
	string array[n];
	f(i,0,n)
	{
		cin>>array[i];
	}	
	map<string, int> mp; 
	int num[n] = {0};
	f(i,0,n)
	{
		
		mp[array[i]]++;
		num[i] = mp[array[i]];
	}
	int max = 0;
	f(i,0,n)
	{
		if(num[i]>max) max = num[i];
	}
	set<string> s;
	f(i,0,n)
	{
		if(num[i] == max) s.insert(array[i]);
	}
	set<string>:: iterator itr;
	for(itr = s.begin(); itr!= s.end(); itr++)
	{
		cout<<*itr<<endl;
	}
	return 0;
}



Measured memory_bytes: 36864
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

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

int gcd(int a,int b);

int main(void)
{
  int r,d,x;
  scanf("%d%d%d",&r,&d,&x);
  int i;
  int t=x;
  REP(i,10)
  {
    t = r*t-d;
    printf("%d\n",t);
  }
  return 0;
  
  
}

int gcd(int a,int b)
{
  int max,min,tmp;
  max = MAX(a,b);
  min = MIN(a,b);
  if(max%min==0) return min;
  else
  {
    tmp = min;
    min = max%min;
    max = tmp;
    return gcd(max,min);
  }
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        List<int> num = new List<int>();
        for(int i = 0; i < 4; i++)
        {
            int a = Console.Read();
            a -= 48;
            num.Add(a);
        }
        int mae = num[0] * 10 + num[1];
        int usiro = num[2] * 10 + num[3];
        if (1 <= mae && mae <= 12) mae = 1;
        else mae = 0;
        if (1 <= usiro && usiro <= 12) usiro = 1;
        else usiro = 0;
        if (mae == 1 && usiro == 1) Console.WriteLine("AMBIGUOUS");
        else if (mae == 1 && usiro == 0) Console.WriteLine("MMYY");
        else if (mae == 0 && usiro == 1) Console.WriteLine("YYMM");
        else if (mae == 0 && usiro == 0) Console.WriteLine("NA");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include<ctime>
#include<cstdlib>
#include<algorithm>
using namespace std;


int main()
{
	{
		string s;
		cin >> s;

		int n = s.size();

		while (1) {
			n -= 2;
			string a = s.substr(0, n / 2);
			string b = s.substr(n / 2, n / 2);
			if (a == b) {
				cout << n << endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(6)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e16)
#define inf 1e16
#define f first
#define se second
const ll mod=1e9+7;
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
char move[]={'D','R','U','L'};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};	
void solve(){
	//ifstream fin("input.txt");
	//ofstream fout("output.txt");
	int x;
	cin>>x;
	cout<<(x^1)<<endl;
	
	
	
	
	
	
	
}	
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();     
}
return 0;
}    


Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1 
    if a[i]-1 in d:
        d[a[i]-1] += 1
    else:
        d[a[i]-1] = 1
    if a[i]+1 in d:
        d[a[i]+1] += 1
    else:
        d[a[i]+1] = 1
maxc = 0
for i in d.keys():
    maxc = max(maxc,d[i])

print(maxc)

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

using ll = long long;
const int MOD = 1000000007;
#define p(var)  std::cout<<var<<std::endl
#ifdef LOCAL_ENV
    #define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
    #define debug(var)
#endif
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

/*-----8<-----8<-----*/


int main(){
    ll N;
    string S;
    cin >> N >> S;

    vector<ll> shiro(N+1,0),kuro(N+1,0);

    rep(i,S.size()){
        if(S[i]=='#'){
            kuro[i+1]=kuro[i]+1;
            shiro[i+1]=shiro[i];
        }else{
            shiro[i+1]=shiro[i]+1;
            kuro[i+1]=kuro[i];
        }

    }


    ll t,minval=99999999;
    rep(i,N+1){
        //....####
        t=kuro[i]+   shiro[N]-shiro[i];
        chmin(minval,t);
        debug(minval);
    }




    p(minval);
    return 0;
}



Measured memory_bytes: 3716
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func min(x,y int) int {
	if x<y {
		return x
	}
	return y
}
func max(x,y int) int {
	if x>y {
		return x
	}
	return y
}
const MAXN=100000
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n:=IO.ReadInt()
	var ax [MAXN+10]int
	a:=ax[1:n+1]
	for i,_:=range a {
		a[i]=IO.ReadInt()
	}
	mx:=0
	for _,v:=range a {
		mx=max(mx,v)
	}
	cnt1,cnt2:=0,0
	for _,v:=range a {
		if v<mx-1 {
			fmt.Println("No")
			return
		} else if v<mx {
			cnt1++
		} else {
			cnt2++
		}
	}
	if cnt1==0 {
		if mx>0 && (mx==n-1 || mx<=n/2) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		n-=cnt1
		mx-=cnt1
		if mx>0 && mx<=n/2 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
	cout.Flush()
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long

int main(){
	ll n,ai;
	// 1:偶数番目を正にする場合, 2:奇数番目を正にする場合
	ll sum1 = 0, sum2 = 0, ans1 = 0, ans2 = 0;

	scanf("%lld",&n);
	FOR(i,0,n){

		scanf("%lld",&ai);
		sum1 += ai;
		sum2 += ai;

		//sum1が正,sum2が負になるべきとき
		if(i%2 == 0){
			if(sum1 <= 0){
				ans1 += -sum1 + 1;
				sum1 = 1;
			}
			if(sum2 >= 0){
				ans2 += sum2 + 1;
				sum2 = -1;
			}
		}

		//sum1が負,sum2が正になるべきとき
		if(i%2 == 1){
			if(sum2 <= 0){
				ans2 += -sum2 + 1;
				sum2 = 1;
			}
			if(sum1 >= 0){
				ans1 += sum1 + 1;
				sum1 = -1;
			}
		}
	}

	printf("%lld\n",ans1<ans2 ? ans1:ans2);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int tmp = 0;
		int ans = 0;
		int[] a = new int[n];

		for ( int i = 0 ; i < n ; i++ ) {
			a[i] = sc1.nextInt();
			if ( i > 0 && a[i] == a[i-1]) {
				tmp++;
			}
			else {
				if (tmp == 0) {
					continue;
				}
				else {
					ans += (tmp + 1) / 2;
					tmp = 0;
				}
			}
		}

		if (tmp > 0) {
			ans += (tmp + 1) / 2;
		}

		System.out.println(ans);

		sc1.close();
	}

}

Measured memory_bytes: 23252
#include<iostream>

using namespace std;

int main(){

    int former, latter;

    while(1){

        cin >> former >> latter;

        if(former == 0 && latter == 0){
            break;
        }else{
            if(former > latter){
                former = former + latter;
                latter = former - latter;
                former = former - latter;
            }
            cout << former << " " << latter << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int table[55];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    for(int i=a;i<10000;i+=a){
        if(i%b==c){
            cout <<"YES"<<endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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();
        int ans = 0;

        for(int i=1; i<=N; i++){
            if(i!=sc.nextInt()){
                ans += 1;
            }
        }
        if(ans<=2){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22740
a, b = map(int, input().split())

# 最大公倍数、最小公倍数
from functools import reduce


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


print(lcm(a, b))



Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll n,top,bot;
int main()
{
    while(scanf("%lld",&n)==1)
    {
        top=bot=-1;
        for(int i=0;i<n;i++)
        {
            ll tmp;
            scanf("%lld",&tmp);
            if(top==-1)top=bot=tmp;
            else
            {
                top=max(top,tmp);
                bot=min(bot,tmp);
            }
        }
        printf("%lld\n",top-bot);
    }
}


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

int main()
{
  string s;
  cin >> s;
  int count = 0;
  
  if(s[0] == 'o') count++;
  if(s[1] == 'o') count++;
  if(s[2] == 'o') count++;
  cout << 700 + count * 100 << endl;
}

Measured memory_bytes: 256
def gcd(x, y):
    if x < y:
        a, b = x, y
    else:
        a, b = y, x

    while True:
        r = a % b
        if r == 0:
            break
        a, b = b, r

    return b


A, B = map(int, input().split())

ans = A * B // gcd(A, B)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
 
using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
 
//recollect
//simplify
//divide into cases (i.e. i = 1, 2, N, a prime number, etc...)
  
void solve() {
	int a, b;
	cin >> a >> b;
	if(b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
}
 
int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else
 
    solve();
    
#endif
 
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    double C;
    cin>>C;
    double PI=acos(-1);
    double theta=PI*C/180;
    double h=b*sin(theta);
    double S=a*h/2;
    double L=a+b+sqrt(a*a+b*b-2*a*b*cos(theta));
    cout<<fixed<<setprecision(8)<<S<<endl;
    cout<<fixed<<setprecision(8)<<L<<endl;
    cout<<fixed<<setprecision(8)<<h<<endl;
}


Measured memory_bytes: 3660