akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
main(){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d ",d,r);
  printf("%f\n",f);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
int dx[] = {1, 0}, dy[] = {0, 1};
char arr[1005][1005];
ll dp[1005][1005];
int h, w;
ll dfs(int u, int v){
    if(u == h - 1 && v == w - 1)
        return dp[u][v] = 1;
    if(dp[u][v] != -1)return dp[u][v];
    dp[u][v] = 0;
    fore(i, 0, 2){
        int x = u + dx[i];
        int y = v + dy[i];
        if(x < h && y < w && arr[x][y] == '.')
            dp[u][v] = (dp[u][v] % mod + dfs(x, y) % mod) % mod;
    }
    return dp[u][v];
}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    cls(dp, -1);
    cin >> h >> w;
    fore(i, 0, h)
        fore(j, 0, w)
            cin >> arr[i][j];

    cout << dfs(0, 0) << '\n';
    return 0;
}   

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  static int num[100010];
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    ++num[a];
    --num[b+1];
  }
  int ans = 0;
  int acc = 0;
  for (int i = 0; i <= N+1; i++) {
    acc += num[i];
    if (acc >= i-1) {
      ans = i-1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int max_n = 1e6 + 6;
vector<int> spf;

void sieve()
{
	spf.resize(max_n, 1);
	
	for(int num = 2; num < max_n; num++)
		spf[num] = num;

	for(int num = 2; num < max_n; num++)
	{
		if(spf[num] == num)
		{
			for(int mult = 2*num; mult < max_n; mult += num)
			{
				spf[mult] = num;
			}
		}
	}
}

void solve()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for(auto &ele : a)
		cin >> ele;

	vector<int> freq(max_n, false);
	bool first = true;

	for(int i = 0; i < n; i++)
	{
		int num = a[i];
		while(num != 1)
		{
			int pf = spf[num];
			if(freq[pf] == true)
			{
				first = false;
				break;
			}
			
			freq[pf] = true;
			while(num % pf == 0)
				num /= pf;
		}
	}
	
	if(first)
	{
		cout << "pairwise coprime" << endl;
		return;
	}

	int g = a[0];
	for(int i = 1; i < n; i++)
		g = __gcd(g, a[i]);

	if(g == 1)
	{
		cout << "setwise coprime" << endl;
		return;
	}

	cout << "not coprime" << endl;
}



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

	sieve();
	solve();
	return 0;
}


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

namespace ARC70_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var x = long.Parse(Console.ReadLine());
            long n = 2;
            for (; x > n * (n - 1) / 2; n++);

            Console.WriteLine(n-1);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
  int c[101][101], t[101][101], n, m, a, b, u, v;

  while(1){
    cin >> n >> m;

    if(n == 0 && m == 0){
      break;
    }

    fill(&c[1][1], &c[m][m], 99999);
    fill(&t[1][1], &t[m][m], 99999);

    for(int i = 1; i <= m; i++){
      c[i][i] = t[i][i] = 0;
    }

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

    for(int k = 1; k <= m; k++){
      for(int i = 1; i <= m; i++){
	for(int j = 1; j <= m; j++){
	  c[i][j] = (c[i][j] < c[i][k]+c[k][j])? c[i][j] : c[i][k]+c[k][j];
	  t[i][j] = (t[i][j] < t[i][k]+t[k][j])? t[i][j] : t[i][k]+t[k][j];
	}
      }
    }
    cin >> n;
    while(n--){
      cin >> a >> b >> u;
      if(u == 0){
	cout << c[a][b] << endl;
      } else {
	cout << t[a][b] << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 948
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int nodes, edges;
std::vector<pair<int, int> > edge;
std::vector<int> v;

int main()
{
	int i, j;

	si(nodes);	si(edges);

	fl(i,0,edges)
	{
		int x, y;
		si(x);	si(y);
		edge.PB(MP(x, y));
	}

	fl(i,1,nodes)
	{
		v.PB(i + 1);
	}

	int ans = 0;

	do
	{
		int prev = 1;
		bool got = 1;
		// cout << " --- \n";
		fl(j,0,nodes - 1)
		{
			int next = v[j];
			// cout << prev << " " << next << "\n";
			bool thisGot = 0;
			fl(i,0,edges)
			{
				if(edge[i].first == prev && edge[i].second == next)
					thisGot = 1;
				if(edge[i].second == prev && edge[i].first == next)
					thisGot = 1;
			}
			if(!thisGot)
			{
				got = 0;
				break;
			}
			prev = next;
		}
		if(got)
			ans++;

	}while(next_permutation(v.begin(), v.end()));

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


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
work = []
ans = 0
if N % 2 == 1:
    before = A[:N // 2]
    after = A[N // 2 + 1:]
    median = A[N // 2]
    for i in range(N // 2):
        work.append(after[i])
        work.append(before[i])
    work.append(median)
    tmp1 = 0
    tmp2 = 0
    for i in range(N - 1):
        tmp1 += abs(work[i] - work[i + 1])
    t = work.pop()
    work.insert(0, t)
    for i in range(N - 1):
        tmp2 += abs(work[i] - work[i + 1])
    ans = max(tmp1, tmp2)

else:
    before = A[:N // 2]
    after = A[N // 2:]
    for i in range(N // 2):
        work.append(after[i])
        work.append(before[i])
    for i in range(N - 1):
        ans += abs(work[i] - work[i + 1])
print(ans)




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

vector<pair<int,int> > nei[1000005];
vector<int> cit[1000005];
vector<int>comp;
int col[1000005];
bool vis[1000005];
vector<int>newnei[1000005];
int dp[1000005];
int poi[1000005];
int main()
{
	int n,m;
	cin>>n>>m;
	memset(col,-1,sizeof col);
	for(int i=0;i<m;i++)
	{
		int x,y,c;
		cin>>x>>y>>c;
		x--,y--,c--;
		nei[x].push_back(make_pair(c,y));
		nei[y].push_back(make_pair(c,x));
		cit[c].push_back(x);
		cit[c].push_back(y);
		comp.push_back(c);
	}
	sort(comp.begin(),comp.end());
	comp.erase(unique(comp.begin(),comp.end()),comp.end());
	for(int i=0;i<n;i++)
	{
		sort(nei[i].begin(),nei[i].end());
	}
	int newci=n;
	for(int i=0;i<comp.size();i++)
	{
		int cmp=comp[i];
		for(int j=0;j<cit[comp[i]].size();j++)
		{
			int v=cit[comp[i]][j];
			if(col[v]==cmp) continue;
			queue<int> q;
			q.push(v);
			col[v]=cmp;
			vector<int> ciin;
			while(!q.empty())
			{
				v=q.front();
				ciin.push_back(v);
				q.pop();
				int k=0;
				for(;poi[v]<nei[v].size();poi[v]++)
				{
					k=poi[v];
					if(nei[v][k].first!=cmp) break;
					int u=nei[v][k].second;
					if(col[u]==cmp) continue;
					col[u]=cmp;
					q.push(u);
				}
			}
			for(int k=0;k<ciin.size();k++)
			{
				int v=ciin[k];
				newnei[v].push_back(newci);
				newnei[newci].push_back(v);
			}
			newci++;
		}
	}
	queue<int>q;
	for(int i=0;i<newci;i++) dp[i]=-2;
	dp[0]=1;
	q.push(0);
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int k=0;k<newnei[v].size();k++)
		{
			int u=newnei[v][k];
			if(dp[u]==-2)
			{
				dp[u]=dp[v]+1;q.push(u);
			}
			
		}
	}
	cout<<dp[n-1]/2;
}

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

struct Edge {
    int from;
    int to;
    int cost;
};

class BellmanFord {
public:
    BellmanFord(int v, int e) : vnum(v) {
        this->edges.reserve(e);       
    }
    
    ~BellmanFord() = default;

    void addEdge(int f, int t, int c) noexcept {
        this->edges.push_back({f, t, c});
    }

    // - return the shortest path lengths from s to each vertex
    // - if a vertex is unreachable from s, the value is INT32_MAX  
    // - return empty vector if this graph contains negative loop
    std::vector<int> shortestPath(int s) const noexcept {
        std::vector<int> d(vnum, INT32_MAX);

        d[s] = 0;
        for (int i = 0; i < this->vnum - 1; ++i) {
            bool update = false;
            for (const Edge& e : this->edges) {
                if (d[e.from] == INT32_MAX) {
                    continue;
                }

                if (d[e.from] + e.cost < d[e.to]) {
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                }
            }

            if (update == false) {
                break;
            }
        }

        for (const Edge& e : this->edges) {
            if (d[e.from] == INT32_MAX) {
                continue;
            }
       
            if ((d[e.from] + e.cost) < d[e.to]) {
                return std::vector<int>();
            }
        }

        return d;
    }

private:
    std::vector<Edge> edges;
    int vnum;
};


int main() {
    int V, E, r;
    std::cin >> V >> E >> r;

    int s, t, d;
    BellmanFord bf(V, E);
    for (int i = 0; i < E; ++i) {
        std::cin >> s >> t >> d;
        bf.addEdge(s, t, d);
    }


    const std::vector<int> paths = bf.shortestPath(r);
    if (paths.size() == 0) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
        return 0;
    }

    for (int p : paths) {
        if (p == INT32_MAX) {
            std::cout << "INF" << std::endl;
        } else {
            std::cout << p << std::endl;
        }
    }

    return 0;
}



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

void solver(){
	int n;
	scanf("%d",&n);
	vector<int> v(n);
	for(int i = 0 ; i < n ; ++i){
		scanf("%d",&v[i]);
	}
	bool prev = true;//if set true curr ele can be decreased else it can't be decreased.
	for(int i = 1 ; i < n ;++i){
		if(v[i] - v[i-1] < -1){
			printf("No\n");
			return;
		}
		else if(v[i] - v[i-1] == -1 && prev == true){
			prev = false;
		}
		else if(v[i] - v[i-1] == -1 && prev == false){
			printf("No\n");
			return;
		}
		else if(v[i] - v[i-1] > 0){
			prev = true;
		}
	}
	printf("Yes\n");
	return;
}

int main(){
	int q = 1;
	//scanf("%d",&q);
	while(q--){
		solver();
	}
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
  int a,b,c;

  cin>>a>>b;

  if(a<b)
    swap(a,b);
  
  while(a%b!=0){
    c=a%b;
    a=b;
    b=c;
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 0
n,m,l=map(int,input().split())
A=[]
for i in range(0,n):
    A.append(list(map(int,input().split())))
B=[]
for i in range(0,m):
    B.append(list(map(int,input().split())))
C=[]
for i in range(0,n):
    D=[]
    for k in range(0,l):
        x=0
        for j in range(0,m):
            x+=A[i][j]*B[j][k]
        D.append(x)
    C.append(D)
for i in range(0,n):
    print(" ".join(map(str,C[i])))


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	else if (b == c)cout << a << endl;
	else cout << b << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int N; cin >> N;
VS s(N); VI t(N); rep(i, 0, N) cin >> s[i] >> t[i];
string X; cin >> X;


int cnt = 0;
bool f = false;
rep(i, 0, N){
    if (f) cnt += t[i];
    if (s[i] == X) f = true;
}
cout << cnt << "\n";
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    int sum = 0;
    repi(i, s){
        if(*i == '1')
            sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    int a,b,ans;cin>>a>>b;
    if(b%a==0){
        ans=a+b;
    }
    else{
        ans=b-a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  string s;
  cin>>s;
  if(s.size() % 2==1){cout<<"No"<<endl;return 0;}
  rep(i,s.size() ){
    if(i%2==0 && s[i]!='h'){cout<<"No"<<endl;return 0;}
    if(i%2==1 && s[i]!='i'){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N_ = 200100;
vector<int> V[N_];
int N, Co[N_], Res[N_];
void Haku(int s, int e) {
	Co[s] = Co[e] ^ 1;
	for (auto &u : V[s]) if (u != e) Haku(u, s);
}
int main() {
	int i;
	scanf("%d", &N);
	for (i = 1; i + 1 <= N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		V[a].push_back(b);
		V[b].push_back(a);
	}
	Haku(1, 1);
	int u[2] = {0, 0}, A = N / 3;
	for (i = 1; i <= N; ++i) u[Co[i]]++;
	if (u[1] < u[0]) {
		swap(u[0], u[1]);
		for (i = 1; i <= N; ++i) Co[i] ^= 1;
	}
	if (u[0] <= A) {
		vector<int> L;
		for (i = 3; i <= N; i += 3) L.push_back(i);
		for (i = 1; i <= N; ++i) if (!Co[i]) {
			Res[i] = L.back();
			L.pop_back();
		}
		int it = 0;
		for (i = 1; i <= N; ++i) if (Co[i]) {
			while (it % 3 == 0) ++it;
			Res[i] = it++;
			if (Res[i] > N) Res[i] = 0;
		}
		for (i = 1; i <= N; ++i) if (!Res[i]) {
			Res[i] = L.back();
			L.pop_back();
		}
	} else {
		int it = 0;
		for (i = 1; i <= N; ++i) if (!Co[i]) {
			Res[i] = it++ * 3 + 1;
			if (Res[i] > N) Res[i] = 0;
		}
		it = 0;
		for (i = 1; i <= N; ++i) if (Co[i]) {
			Res[i] = it++ * 3 + 2;
			if (Res[i] > N) Res[i] = 0;
		}
		it = 0;
		for (i = 1; i <= N; ++i) if (!Res[i]) {
			Res[i] = ++it * 3;
		}
	}
	for (i = 1; i <= N; ++i) printf("%d ", Res[i]);
	puts("");
}


Measured memory_bytes: 19072
n,m = map(int,input().split())
tbl=[[] for i in range(n)]
for i in range(n):
    tbl[i] = list(map(int,input().split()))
tbl2=[[]*1 for i in range(m)]
for i in range(m):
    tbl2[i] = int(input())
for k in range(n):
    x=0
    for l in range(m):
        x +=tbl[k][l]*tbl2[l]
    print("%d"%(x))


Measured memory_bytes: 6020
#include <stdio.h>
#define MAX 100000
#define N 2000000000
struct Card {
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];
void kansuu1(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int a=mid-left;
  int b=right-mid;
  for(i=0;i<a;i++) L[i]=A[left+i];
  for(i=0;i<b;i++) R[i]=A[mid+i];
  L[a].value=R[b].value=N;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}
void kansuu2(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    kansuu2(A,n,left,mid);
    kansuu2(A,n,mid,right);
    kansuu1(A,n,left,mid,right);
  }
}
int kansuu3(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      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;
}
void kansuu4(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=kansuu3(A,n,p,r);
    kansuu4(A,n,p,q-1);
    kansuu4(A,n,q+1,r);
  }
}
int main(void){
  int n,i,v;
  int stable=1;
  struct Card A[MAX],B[MAX];
  char C[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",C,&v);
    A[i].suit=B[i].suit=C[0];
    A[i].value=B[i].value=v;
  }
  kansuu2(A,n,0,n);
  kansuu4(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4124
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;
    cin>>N;
    VI A(N+1),B(N);
    REP(i,N+1)
    {
        cin>>A[i];
    }
    REP(i,N)
    {
        cin>>B[i];
    }
    //1人ずつ見ていく
    
    ll ans=0;
    REP(i,N)
    {
        if (A[i]>=B[i])
        {
            ans+=B[i];
            A[i]-=B[i];
            B[i]=0;
        }
        else
        {
            ans+=A[i];
            B[i]-=A[i];
            A[i]=0;
            if (A[i+1]>=B[i])
            {
                ans+=B[i];
                A[i+1]-=B[i];
                B[i]=0;
            }
            else
            {
                ans+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
    }
    cout<<ans<<endl;
  
    return 0;
}



Measured memory_bytes: 1024
# Author: cr4zjh0bp
# Created: Thu Mar 12 07:45:44 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N, X = na()
m = nin(N)

ans = N
X -= sum(m)
ans += X // min(m)

print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;

    cout << x / 500 * 1000 + x % 500 / 5 * 5 << '\n';

    return 0;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
X = int(input())

r = [0,1,1,1,1,1,1,2,2,2,2]
print(X//11*2 + r[X%11])

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  LL n;
  int k;
  cin >> n >> k;
  LL ans = 0;

  REP(i, n) {
    int tmp;
    cin >> tmp;
    if(tmp >= k) {
      ans += 1;
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

vector<ll> x,y;
ll solve(vector<ll> v){
    int n=v.size();
    ll ret=0;

    vector<ll> w;
    for(int i=1;i<n;i++){
        w.push_back(v[i]-v[i-1]);
    }
    n--;
    
    rep(i,n){
        ll l=i+1,r=n-i;
        ret+=w[i]*((l*r)%mod)%mod;
        ret%=mod;
    }
    return ret;
}

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

    ll n,m;
    cin>>n>>m;
    x.resize(n);y.resize(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    ll a=solve(x);
    ll b=solve(y);
    ll ans=a*b%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4436
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int a[MAXN];

int main()
{
	
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[2]*10+a[1]+a[0] << endl;
	
	return 0;
}


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

int main(){
  int a, b, c, d,train,bus;
  cin>>a>>b>>c>>d;
  if(a>=b){
   train=b;
  }else{
  train=a;
  }
  if(c>=d){
   bus=d;
  }else{
  bus=c;
  }
  cout<<bus+train<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int m,n,x,y;
	int x1 = -999,y1 =999;
	int a[105],b[105];
	int cnt = 0;
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		x1 = max(x1,a[i]);
		}
	for(int j = 1;j <= m;j++){
		scanf("%d",&b[j]);
		y1 = min(y1,b[j]);
		}
		for(x = x+1;x <= y;x++){
			if(x > x1&&x <= y1)
			{
				cnt = 1;
				printf("No War");
				break;
				}
			}
			if(cnt == 0) printf("War");
	return 0;
	}

Measured memory_bytes: 128
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	static int array[][]= new int[10][10];
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line;
		StringTokenizer tokenizer1,tokenizer2;
		int a[] = new int[3];
		int max=0, sum=0;
		
		while ((line = input.readLine()) != null && !line.isEmpty()) {
			tokenizer1 = new StringTokenizer(line,",");
			for(int i=0;i<3;i++){
				a[i]=Integer.parseInt(tokenizer1.nextToken());
			}
			if(a[2]==1){
				small(a[0],a[1]);
			}
			if(a[2]==2){
				mid(a[0],a[1]);
			}
			if(a[2]==3){
				big(a[0],a[1]);
			}
		}
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){			
				max=Math.max(max, array[i][j]);
				if(array[i][j]==0){
					sum++;	
				}
			}
		}
		System.out.println(sum);
		System.out.println(max);
	}
	public static void small (int a, int b){
		int a2,b2;
		for(int i=0;i<3;i++){
			a2=a+i-1;			
			if (a2 > -1 && a2<10 ){
				array[a2][b]++;							
			}
		}
		for(int i=0;i<3;i++){
			b2=b+i-1;			
			if (b2 > -1 && b2<10 ){
				array[a][b2]++;							
			}
		}
		array[a][b]--;
	}
	public static void mid (int a, int b){
		int a2,b2;
		for(int i=0;i<3;i++){
			a2=a+i-1;			
			for(int j=0;j<3;j++){
				b2=b+j-1;
				if (a2 > -1 && a2< 10 && b2 > -1 && b2 < 10){
					array[a2][b2]++;	
				}
			}
		}
	}
	public static void big (int a, int b){
		mid(a,b);
		int i=2;
		int a2,b2;
		a2=i+a;
		if (a2 > -1 && a2<10){
			array[a2][b]++;	
		}
		a2=-i+a;
		if (a2 > -1 && a2<10){
			array[a2][b]++;	
		}
		b2=i+b;
		if (b2 > -1 && b2<10){
			array[a][b2]++;	
		}
		b2=-i+b;
		if (b2 > -1 && b2<10){
			array[a][b2]++;	
		}
	}
}	

Measured memory_bytes: 16872
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto h = vector<int>(n);
    for (auto& h_i : h)
        cin >> h_i;

    auto h_max = 0;
    auto cnt = 0;
    for (auto h_i : h) {
        if (h_i >= h_max)
            cnt++;
        h_max = max(h_max, h_i);
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long long r, D, x;
  cin >> r >> D >> x;
  for(int i = 0; i < 10; i++){
    x = r * x - D;
    cout << x <<endl;
  }
}

Measured memory_bytes: 3612
inpt = map(int, raw_input().split())
inpt.sort()
A = inpt[0]
B = inpt[1]
C = inpt[2]
tmp1 = (C-A)/2
tmp2 = (C-B)/2
A += tmp1*2
B += tmp2*2
memo = []
queue = [[tmp1+tmp2, [A, B, C]]]
while queue != []:
	now = queue.pop(0)
	if now[1][0] == now[1][1] and now[1][0] == now[1][2]:
		print now[0]
		break
	next = []
	for i in range(0, 3):
		lst1 = [now[1][0], now[1][1], now[1][2]]
		lst2 = [now[1][0]+1, now[1][1]+1, now[1][2]+1]
		lst1[i] += 2
		lst2[i] -= 1
		next.append(lst1)
		next.append(lst2)
	for i in range(0, 6):
		if next[i] not in memo:
			queue.append([now[0]+1, next[i]])

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin >> s >> t;

    vector<int> tempdp(s.length()+1, 0);
    vector<vector<int>> dp(t.length()+1, tempdp);
    int maxWeHaveSeen = 0;
    string finalStr = "";

    for (int i = 0; i < dp.size(); i++)
    {
        for (int j = 0; j < dp[0].size(); j++)
        {
            //cout << i << ", " << j << endl;
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }else{
                if(s[s.length()-j] == t[t.length()-i]){
                    int diag = dp[i-1][j-1] + 1;
                    dp[i][j] = max(max(diag, dp[i-1][j]), dp[i][j-1]);
                }else{
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
    }

    int i = dp.size() - 1 ,j = dp[0].size() - 1;
    while(i > 0 && j > 0){
        if(s[s.length() - j] == t[t.length() - i]){
            finalStr += s[s.length() - j];
            i--;
            j--;
        }else{
            if(dp[i-1][j] < dp[i][j-1]){
                j--;
            }else{
                i--;
            }
        }
    }

    /*for (int i = 0; i < dp.size(); i++)
    {
        for (int j = 0; j < dp[0].size(); j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << finalStr << endl;

}

Measured memory_bytes: 35584
import sys
input = sys.stdin.readline

def main():

    S = ["a"]
    N = int(input())
    m = 97

    def add_str(S,m):
        if len(S)==N:
            print("".join(S))
        else:
            for j in range(97,m+2):
                add_str(S+[chr(j)], max(m,j))

    add_str(S,m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4412
n = gets.to_i
words = []
word = gets.chomp
preChar = word[-1]
words.push(word)
result = true
1.upto n-1 do|i|
  word = gets.chomp
  if preChar != word[0] then
    result = false
    break
  end
  preChar = word[-1]
  words.push(word)
end
if words.size != words.uniq.size then
  result = false
end
if result then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;


template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< mod >;

int main(){
    ll l,r;cin>>l>>r;
    modint dp[61][2][2][2];
    dp[0][0][0][0]=1;
    rep(i,60) {
        ll lb=l&(1ll<<(59-i));
        ll rb=r&(1ll<<(59-i));
        rep(j,2) rep(k,2) rep(s,2){
            rep(x,2) rep(y,2){
                if(x&&!y)continue;
                int ni,nj,nk,ns;
                ni=i;nj=j;nk=k;ns=s;
                if(!s&&(x!=y))continue;
                if(!s&&x&&y)ns=1;
                if(!j&&lb&&!x)continue;
                if(!j&&!lb&&x)nj=1;
                if(!k&&!rb&&y)continue;
                if(!k&&rb&&!y)nk=1;
                dp[i+1][nj][nk][ns]+=dp[i][j][k][s];
            }
            
        }
    }
    modint ans=0;
    rep(j,2) rep(k,2) rep(s,2) ans+=dp[60][j][k][s];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int maxtime(int x)
{
    return (x + 9) / 10 * 10;
}

int remtime(int x)
{
    return maxtime(x) - x;
}

int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
    sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

ans = Array.new(10 ** 5 + 1, 0)
min = 0

a.each do |i|
  ans[i] += 1
  ans[i + 1] += 1
  if i.zero?
    min += 1
  else
    ans[i - 1] += 1
  end
end

p [ans.max, min].max

Measured memory_bytes: 9476
N,M = map(int,input().split())
num_AC,num_WA = 0,0
res = [list(input().split()) for i in range(M)]
check = ['v']*N
WA_check = [0]*N
for i,j in res:
  i = int(i)
  if check[i-1] == 'v':
    if j == 'WA':
      WA_check[i-1] += 1
    if j == 'AC':
      num_AC += 1
      num_WA += WA_check[i-1]
      check[i-1] = '.'
print(num_AC,num_WA)

Measured memory_bytes: 31928
#include <stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[105];
    int b[105];
    int sum=0,ans=0;
    for(int x=0;x<n;x++)
    {
        scanf("%d",&a[x]);
        sum+=a[x];
    }
    for(int x=0;x<n;x++)
    {
        b[x]=abs(sum-ans);
        sum-=a[x];
        ans+=a[x];
    }
    b[n]=abs(sum-ans);
    sort(b,b+n+1);
    printf("%d\n",b[0]);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main() {
	int N,M,X;
	cin >> N >> M >> X;
	int a1= 0,a2=0;
	for(int i = 1,j; i <= M; i ++) {
		cin >> j;
		if(j >= 1 && j <= X) a1++;
		else a2++;
	}
	cout << min(a1,a2) << endl;
	return 0;
}

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

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q);
    vector<int> b(q);
    vector<int> c(q);
    vector<int> d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int maximum = 0;
    for (int a1 = 1; a1 <= m; a1++) {
        for (int a2 = a1; a2 <= m; a2++) {
            for (int a3 = a2; a3 <= m; a3++) {
                for (int a4 = a3; a4 <= m; a4++) {
                    for (int a5 = a4; a5 <= m; a5++) {
                        for (int a6 = a5; a6 <= m; a6++) {
                            for (int a7 = a6; a7 <= m; a7++) {
                                for (int a8 = a7; a8 <= m; a8++) {
                                    for (int a9 = a8; a9 <= m; a9++) {
                                        for (int a10 = a9; a10 <= m; a10++) {
                                            vector<int> array = {a1, a2, a3, a4,
                                                                 a5, a6, a7, a8,
                                                                 a9, a10};
                                            int sum = 0;
                                            for (int i = 0; i < q; i++) {
                                                if (array[b[i] - 1] -
                                                        array[a[i] - 1] ==
                                                    c[i]) {
                                                    sum += d[i];
                                                }
                                            }
                                            maximum = max(maximum, sum);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << maximum << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int c = min(a,b);
    string ca = to_string(c);
    string s = "";
    rep(i,a+b-c){
        s += ca;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return find(par[x])
        
def union(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if rank[x]>rank[y]:
        par[y]=x
        size[x]+=size[y]
    else:
        par[x]=y
        size[y]+=size[x]
        if rank[x]==rank[y]:
            rank[y]+=1


n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
l.reverse()
ans=[0]*(m+1)
par=[i for i in range(n+1)]
rank=[0 for _ in range(n+1)]
size=[1 for _ in range(n+1)]
for i in range(m):
    a,b=l[i]
    a,b=find(a),find(b)
    if a==b:
        ans[i+1]=ans[i]
    else:
        ans[i+1]=ans[i]+size[a]*size[b]
        union(a,b)
    #print(par,a,b,ans)
#print(l,find(4),par,rank)
for i in range(m-1,-1,-1):
    print(n*(n-1)//2-ans[i])

Measured memory_bytes: 37112
import Data.List
import Data.Ord
main=do
    [a,b]<-map read.words<$>getLine::IO[Int]
    putStrLn $ f a b
f a b
    | a<0 && b>0 = "Zero"
    | a>0 = "Positive"
    | even (b-a+1) = "Positive"
    | otherwise = "Negative"


Measured memory_bytes: 508
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 2050
struct edge{int t,next,v,c;}ed[N*30];
int n,a,b,c,head[N],ct,cnt,vis2[N],vis3[N],vis[N];
long long dis[N],as;
void adde(int f,int t,int w,int c){ed[++cnt]=(edge){t,head[f],w,c};head[f]=cnt;ed[++cnt]=(edge){f,head[t],0,-c};head[t]=cnt;}
void bfs2(int t)
{
	memset(vis2,0,sizeof(vis2));
	queue<int> tp;
	tp.push(t);
	vis2[t]=1;
	while(!tp.empty())
	{
		int x=tp.front();tp.pop();
		for(int i=head[x];i;i=ed[i].next)
		if(ed[i^1].v)
		if(!vis2[ed[i].t])vis2[ed[i].t]=1,tp.push(ed[i].t);
	}
}
bool spfa_is_dead(int s,int t)
{
	bfs2(t);
	memset(vis,0,sizeof(vis));
	memset(vis3,0,sizeof(vis3));
	memset(dis,0x3f,sizeof(dis));
	queue<int> tp;
	tp.push(s);
	dis[s]=0;vis[s]=1;
	while(!tp.empty())
	{
		int x=tp.front();tp.pop();
		vis[x]=0;
		for(int i=head[x];i;i=ed[i].next)
		if(ed[i].v&&vis2[ed[i].t])
		if(dis[ed[i].t]>dis[x]+ed[i].c)
		{
			dis[ed[i].t]=dis[x]+ed[i].c;
			if(!vis[ed[i].t])vis[ed[i].t]=1,tp.push(ed[i].t);
		}
	}
	return dis[t]<=1e15;
}
int dfs(int u,int t,int f)
{
	if(u==t||!f)return f;
	vis3[u]=1;
	int as1=0,tp;
	for(int i=head[u];i;i=ed[i].next)
	if(!vis3[ed[i].t]&&vis2[ed[i].t]&&ed[i].v&&dis[ed[i].t]==dis[u]+ed[i].c&&(tp=dfs(ed[i].t,t,min(ed[i].v,f))))
	{
		as1+=tp,f-=tp;
		ed[i].v-=tp,ed[i^1].v+=tp;
		as+=1ll*ed[i].c*tp;
		if(!f)return as1;
	}
	return as1;
}
long long dinic(int s,int t)
{
	while(spfa_is_dead(s,t))
	dfs(s,t,1e8);
	return as;
}
int main()
{
	scanf("%d",&n);
	ct=6;cnt=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		++ct;
		adde(1,ct,c,0);
		adde(ct,3,c,a+b);
		adde(ct,4,c,a-b);
		adde(ct,5,c,-a+b);
		adde(ct,6,c,-a-b);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		++ct;
		adde(ct,2,c,0);
		adde(3,ct,c,-a-b);
		adde(4,ct,c,-a+b);
		adde(5,ct,c,a-b);
		adde(6,ct,c,a+b);
	}
	printf("%lld\n",-dinic(1,2));
}

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

using namespace std;

int main(void) {
  long long A, B, N;
  cin >> A >> B >> N;
  
  long long x = (B%N == 0) ? ((B != 1) ? N-1 : N) : N;
  long long y = N/B*B - 1;

  if (y <= 0) {
    cout << A*x/B - x/B * A << endl;
  } else {
    cout << max(A*x/B - x/B * A, A*y/B - y/B * A) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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 (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
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 dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll n;
vll a;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, n) {
      ll x; cin >> x;
      a.pb(x);
    }
    sort(ALL(a));
    ll ans = 0; 
    rep(i, 0, n / 2 - 1) {
      ans += a[n - 1 - i - 1] - a[i];
      ans += a[n - 1 - i] - a[i+1];
    }
    if (n % 2) 
        ans += max(a[n/2] - a[n/2-1], a[n/2+1] - a[n/2]);
    cout << ans + a[n-1] - a[0] << endl;
    return 0;
}



Measured memory_bytes: 1400
import collections
N = int(input())
s = [input() for i in range(N)]
s = collections.Counter(s)
s = list(s.items())
M = int(input())
t = [input() for i in range(M)]
ans = 0
for i in s:
  count = 0
  for j in t:
    if i[0] == j:
      count += 1
  if ans <= i[1] - count:
    ans = i[1] - count
print(ans)

Measured memory_bytes: 3316