akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)
 
typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct Dinic {
    int n, s, t;
    vector<int> level, prog, que;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n_) : n(n_), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
                   g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        for(int i = 0; i < n; i++) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
    Capacity solve(int s_, int t_){
        this->t = t_, this->s = s_;
        que.resize(n+1);
        Capacity res = 0;
        while(levelize()){ prog.assign(n, 0); res += augment(s, inf); }
        return res;
    }
    bool levelize(){
        int l = 0, r = 0;
        level.assign(n, -1); level[s] = 0;
        que[r++] = s;
        while(l != r){
            int v = que[l++];
            if(v == t) break;
            for(const int &d : g[v]){
                if(level[d] != -1 || residue(v,d) == 0) continue;
                level[d] = level[v] + 1; que[r++] = d;
            }
        }
        return level[t] != -1;
    }
    Capacity augment(int v, Capacity lim){
        Capacity res = 0;
        if(v == t) return lim;
        for(int &i = prog[v]; i < (int)g[v].size(); i++){
            const int &d = g[v][i];
            if(residue(v,d) == 0 || level[v] >= level[d]) continue;
            const Capacity aug = augment(d, min(lim, residue(v,d)));
            flow[v][d] += aug; flow[d][v] -= aug;
            res += aug; lim -= aug;
            if(lim == 0) break;
        }
        return res;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic ek(g);
    cout << ek.solve(0,N-1) << endl;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int A, B, C;
    cin >> A >> B >>C;
    string ans;
    if(A + B + C >= 22) ans = "bust";
    else ans = "win";
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    private static int MAX = 300;
    private static int MIN = 3;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                int[] h_w = Stream.of(sc.nextLine().split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray();
                if (h_w.length != 2) {
                    throw new IllegalTestCaseException();
                }
                int h = h_w[0];
                int w = h_w[1];
                if (h ==0 && w == 0) {
                    break;
                }
                if (h > MAX || h < MIN || w > MAX || w < MIN) {
                    throw new IllegalTestCaseException();
                }
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
        } catch (IllegalTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Illegal condition.");
        }
    }
}



Measured memory_bytes: 38024
#include <iostream>
using namespace std;
int a[105];
int main(int argc, const char * argv[])
{
    int n,ans=0,amax,amin;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)
        {
            amax=a[i];
            amin=a[i];
        }
        else
        {
            if(amax<a[i])
                amax=a[i];
            if(amin>a[i])
                amin=a[i];
        }
    }
    ans=amax-amin;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  string s; cin >> s;
  int sl = s.length();
  int x, y; cin >> x >> y;
  
  int len = 0;
  string dir = "x";
  vector<int> xl, yl;
  for (int i=0; i<sl; i++) {
    if (s[i]=='F') len++;
    else {
      if (dir=="x") xl.push_back(len);
      else yl.push_back(len);
      dir = (dir=="x") ? "y" : "x";
      len = 0;
    }
  }
  if (dir=="x") xl.push_back(len);
  else yl.push_back(len);
  x -= xl[0]; xl.erase(xl.begin());

  map<int, map<int, int>> xpos; xpos[0][0] = 1;
  rep(i,xl.size()) {
    for (auto xx: xpos[i]) {
      xpos[i+1][xx.first+xl[i]] = 1;
      xpos[i+1][xx.first-xl[i]] = 1;
    }
  }
  map<int, map<int, int>> ypos; ypos[0][0] = 1;
  rep(i,yl.size()) {
    for (auto yy: ypos[i]) {
      ypos[i+1][yy.first+yl[i]] = 1;
      ypos[i+1][yy.first-yl[i]] = 1;
    }
  }

  map<int, int> rx = xpos[xl.size()], ry = ypos[yl.size()];
  string result = (rx[x]==1&&ry[y]==1) ? "Yes" : "No";
  cout << result << endl;
  // for (auto xx: rx) cout << xx.first << " "; cout << endl;
  // for (auto yy: ry) cout << yy.first << " "; cout << endl;
  // cout << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 232576
import math
a,b,x=map(int, input().split())

v=x/a
if v>a*b/2:
    r=(a*b-v)/a*2
    r1=math.sqrt(a**2+r**2)
    w=math.asin(r/r1)
    print(math.degrees(w))

else:
    r=v/b*2
    r1=math.sqrt(b**2+r**2)
    w=math.asin(b/r1)
    print(math.degrees(w))
    
    
    
    





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

int main(){
    int n,x,b,ans;
    cin>>n>>x;
    int m[n];
    for(int i=0;i<n;i++){
    cin>>m[i];
    x-=m[i];
    }
    b=m[0];
    for(int i=0;i<n-1;i++){
        b=min(b,m[i+1]);
    }
    ans=n+x/b;
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main() { 
	int n;
	cin >> n;
	int p = n;
	int sum = 0;
	while (p > 0) {
		sum += p % 10;
		p = p / 10;
	}
	if (n % sum == 0) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !

process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var A =parseInt(lines[0]);
    var B =parseInt(lines[1]);
    var C =parseInt(lines[2]);
    
    if (C >= A && C <= B){
        console.log("Yes");
    }else{
        console.log("No");
    }
    
});



Measured memory_bytes: 20936
#include <stdio.h>
int main()
{
    int n, m, i, j;
    while (1)
    {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0)
        {
            break;
        }

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (i % 2 != 0)
                {
                    if ((i + j) % 2 == 0)
                    {
                        printf("#");
                    }
                    else
                    {
                        printf(".");
                    }
                }
                else
                {
                    if ((i + j) % 2 == 0)
                    {
                        printf("#");
                    }
                    else
                    {
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#define N 25
#define NIL -1
struct Point {
  int P,L,R;
};
struct Point tree[N];
int n;

void preorder(int st);
void inorder(int st);
void postorder(int st);

int main()
{
  int i,p,l,r,squrt;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    tree[i].P=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&p,&l,&r);
    tree[p].L=l;
    tree[p].R=r;

    if(l!=-1)
      tree[l].P=p;
    
    if(r!=-1)
      tree[r].P=p;
  }

  for(i=0;i<n;i++){
    if(tree[i].P ==-1)
      squrt=i;
  }

  printf("Preorder\n");
  preorder(squrt);
  printf("\n");
    
  printf("Inorder\n");
  inorder(squrt);
  printf("\n");
  
  printf("Postorder\n");
  postorder(squrt);
  printf("\n");

  return 0;
}


void preorder(int st){
  
  if(st==-1)
    return;
  
  printf(" %d",st);

  preorder(tree[st].L);
  preorder(tree[st].R);
  
}

void inorder(int st){
  
  if(st==-1)
    return;
 
  inorder(tree[st].L);
  printf(" %d",st);
  inorder(tree[st].R);
  
}

void postorder(int st){
  
  if(st==-1)
    return;
  
  postorder(tree[st].L);
  postorder(tree[st].R);

  printf(" %d",st);
  
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
struct UnionFind
{
  vector< int > data;
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
  int find(int x)
  {
    if(data[x] < 0) return(x);
    return(data[x] = find(data[x]));
  }
  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(-data[x] == data.size());
  }
};
  
struct edge
{
  int u, v, cost;
  bool operator<(const edge& e) const
  {
    return(cost < e.cost);
  }
};

int main()
{
  int N, M;
  while(scanf("%d %d", &N, &M), N) {
    vector< edge > edges;
    for(int i = 0; i < M; i++) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      --u, --v;
      edges.push_back((edge){u, v, w});
    }
    sort(edges.begin(), edges.end());
    int ret = INF;
    for(int i = 0; i <= M - N + 1; i++) {
      UnionFind uf(N);
      for(int j = i; j < M && edges[j].cost - edges[i].cost < ret; j++) {
        if(uf.unite(edges[j].u, edges[j].v)) {
          ret = min(ret, edges[j].cost - edges[i].cost);
          break;
        }
      }
    }
    if(ret == INF) printf("-1\n");
    else printf("%d\n", ret);
  }
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	vi v;
	v.pb(0);

	zip(i, 0, n)
	{
		cin >> a[i];
		v.pb(a[i]);
	}
	v.pb(0);
	int cnt = 0;
	zip(i, 1, n + 2)
	{
		cnt += abs(v[i] - v[i - 1]);
	}
	zip(i, 1, n + 1)
	{
		int x = v[i];
		int y = cnt - abs(v[i + 1] - v[i]) - abs(v[i] - v[i - 1]) + abs(v[i + 1] - v[i - 1]);
		cout << y << en;
	}


	return 0;
}



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

using namespace std;
typedef long long int ll;

int main(){
	// freopen("testIn.txt","r",stdin);
	// freopen("testOut.txt","w",stdout);
	ll n,val;
	cin>>n;
	vector<ll> v;
	for(ll i=0;i<n;i++){
		cin>>val;
		v.push_back(val);
	}
	sort(v.begin(),v.end());
	cout<<v[n-1]-v[0]<<endl;


    

    
    return 0;
}                               

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

int main(){
    
    int N,K;
    cin >> N >> K;
    int A[N];
    for(int i = 0; i < N;i++)cin >> A[i];
    
    
    int sum = 0;
    int ans = 0;
    while(true){
        if(ans == 0)sum += K;
        else sum += K - 1;
        
        ans++;
        if(sum>=N)break;
    }
    cout << ans <<endl;
}

    
    



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int N, T, c, t, m = 100000000;
int main() {
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if (t <= T && m > c) {
      m = c;
    }
  }
  if (m > 10000) {
    cout << "TLE" << endl;
    return 0;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
void main(){
	ulong x = _scan!ulong();
	ulong dep = 100;
	ulong yy = 0;
	while( 1 ){
		if( dep >= x ){
			yy.writeln();
			return;
		}
		yy++;
		dep += dep/100;
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

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

  vector<long double> a;
  for (int i = 0; i < n; i++)
  {
    long double b;
    cin >> b;
    b -= i + 1;
    a.push_back(b);
  }

  sort(a.begin(), a.end());
  ll median = a[(a.size() / 2)];

  ll res = 0;
  for (int i = 0; i < n; i++)
  {
    res += abs(a[i] - median);
  }

  cout << res << endl;
}

Measured memory_bytes: 6256
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
c=3.times.map{gsmi}
#sum=sum c.map{|i|sum(i)}

can=false
-200.upto c[0][0] do |a1|
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  a2=c[1][0]-b1
  a3=c[2][0]-b1
  #残り4つが正しければいい
  if c[1][1]==a2+b2 && c[1][2]==a2+b3 && c[2][1]==a3+b2 && c[2][2]==a3+b3
    can=true
    break
  end
end

puts_yesno can

Measured memory_bytes: 4092
line=input()
line=line.rstrip().split(" ")
line1=int(line[0])
line2=int(line[1])

count=0
for i in range(line1,line2+1):
    i=str(i)
    if i[0]==i[4] and i[1]==i[3]:
        count+=1
        
print(count)

Measured memory_bytes: 3060
N = int(input())

if 64 <= N:
   print(64)
elif 32 <= N:
   print(32)
elif 16 <= N:
   print(16)
elif 8 <= N:
   print(8)
elif 4 <= N:
   print(4)
elif 2 <= N:
   print(2)
else:
   print(1)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include<cctype>
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 rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int D, T, S; cin >> D >> T >> S;
  if (S*T>=D) cout << "Yes" << endl;
  else cout << "No" << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}

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

int main(){
  
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<n-1;i++){
    cin >> c.at(i);
  }
  int ans=0;
  for(int j=0;j<n;j++){
    ans+=b.at(j);
  }
  for(int k=0;k<n-1;k++){
    if(a.at(k+1)-a.at(k)==1){
      ans+=c.at(a.at(k)-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    if (n == 3) {
        cout << 2 << endl;
        cout << 1 << " " << 3 << endl
             << 3 << " " << 2 << endl;
    } else if (n == 4) {
        cout << 4 << endl;
        cout << 1 << " " << 2 << endl
             << 1 << " " << 3 << endl
             << 4 << " " << 2 << endl
             << 4 << " " << 3 << endl;
    } else if (n % 2 == 0) {
        cout << 2 * n << endl;
        rep(i, n / 2)
        {
            int ls = i + 1, ld = (i + 1) % (n / 2) + 1;
            int us = n - i, ud = n - (i + 1) % (n / 2);
            cout << ls << " " << ld << endl
                 << ls << " " << ud << endl
                 << us << " " << ld << endl
                 << us << " " << ud << endl;
        }
    } else {
        cout << n / 2 * 4 << endl;
        rep(i, n / 2 - 1)
        {
            int ls = i + 1, ld = i + 1 + 1;
            int us = n - 1 - i, ud = n - 1 - (i + 1);
            cout << ls << " " << ld << endl
                 << ls << " " << ud << endl
                 << us << " " << ld << endl
                 << us << " " << ud << endl;
        }
        int mid = n / 2;
        cout << mid << " " << n << endl
             << mid + 1 << " " << n << endl
             << n << " " << 1 << endl
             << n << " " << n - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	char S[100000];
	cin >> S;
	int ans = N;
	for (int i = 0;i < N - 1;i++) {
		if (S[i] == S[i + 1]) {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int i;
	int mount[10];
	int high1, high2, high3;
	
	for (i = 0; i < 10; i++) {
		scanf("%d", &mount[i]);
	}
	
	high1 = mount[0];
	
	for (i = 1; i < 10; i++) {
		if (high1 < mount[i]) {
			high3 = high2;
			high2 = high1;
			high1 = mount[i];
		} else if (high2 < mount[i]) {
			high3 = high2;
			high2 = mount[i];
		} else if (high3 < mount[i]) {
			high3 = mount[i];
		}
	}
	printf("%d\n", high1);
	printf("%d\n", high2);
	printf("%d\n", high3);
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

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

    for(int i=2;i<=N-1;i++){
        if(a[i-1]==a[i]
        &&a[i]==a[i+1]){
            a[i]++;
            ans++;
        }
    }

    for(int i=1;i<N;i++){
        if(a[i]==a[i+1])ans++;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main(){
  
  vector<char> dai(26);
  dai = {'A','B','C','D','E','F','G','H','I','J','K',
                          'L','M','N','O','P','Q','R','S','T','U','V',
                          'W','X','Y','Z'};
  vector<char> shou(26);
  shou = {'a','b','c','d','e','f','g','h','i','j','k',
                          'l','m','n','o','p','q','r','s','t','u','v',
                          'w','x','y','z'};                      
  
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  for(int i=0; i<N; i++) {
    if(i != K-1) cout << S.at(i);
    else {
      for(int j=0; j<26; j++) {
        if(S.at(i) == dai.at(j)) cout << shou.at(j);
      }
    }
  }
      
  cout << endl;
  
}

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

int main(){
    int N;
    cin>>N;
    vector<int> Da(N);
    vector<int> Db(N);
    for(int i=0;i<N;i++){
        cin>>Da.at(i)>>Db.at(i);
    }
    int tmp = 0;
    vector<int> ans(N,0);
    if(Da.at(0)==Db.at(0)){
        ans.at(0)=1;
    }
    for(int i=1;i<N;i++){
        if(Da.at(i)==Db.at(i)){
            ans.at(i)=ans.at(i-1)+1;
        }
        else{
            ans.at(i)=0;
        }
        if(ans.at(i)==3){
            tmp++;
            break;
        }
    }
    if(tmp>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>

using namespace std;

bool is_prime(int x)
{
	if (x == 2)
		return true;

	if (x % 2 == 0)
		return false;

	for (int i = 3; i*i <= x; i += 2)
		if (x % i == 0)
			return false;

	return true;
}

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

	int n;
	cin >> n;

	int count = 0, x;
	while (n--)
	{
		cin >> x;
		count += is_prime(x);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	ll d,n;
	cin >> d >> n;
	if(n==100) n++;
	if(d==0) cout << n << endl;
	else if(d==1) cout << n*100 << endl;
	else cout << n*10000 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
        int a,b,c;
        int x=0;
	
        scanf("%d%d%d",&a,&b,&c);
        
	//aからbの間
        for(;a <= b;a++){
        	//cの約数があったとき
        	if(c % a == 0){
        		x++;
        	}
        }
        	printf("%d\n",x);
        
        return 0;
}



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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector<int> a(n);

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

    int c = 0, s = accumulate(a.begin(), a.end(), 0);

    for(int i = 0; i < n; i++) {
        if(a.at(i) * 4 * m >= s) c++;
    }

    if(c >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int s[16];
    int tmp[16];
    int bucket[128];
    int cnt;
    int i;

    while (scanf("%d", &n) * n != 0){
        for (i = 0; i < n; i++){
            scanf("%d", &s[i]);
        }

        cnt = 0;
        while (1){
            for (i = 0; i < 128; i++){
                bucket[i] = 0;
            }

            for (i = 0; i < n; i++){
                bucket[s[i]]++;
            }
            for (i = 0; i < n; i++){
                tmp[i] = bucket[s[i]];
            }

            for (i = 0; i < n; i++){
                if (tmp[i] != s[i]){
                    break;
                }
            }
            if (i < n){
                for (i = 0; i < n; i++){
                    s[i] = tmp[i];
                }
                cnt++;
            }
            else {
                break;
            }
        }

        printf("%d\n", cnt);
        printf("%d", s[0]);
        for (i = 1; i < n; i++){
            printf(" %d", s[i]);
        }
        printf("\n");
    }

    return (0);
}

Measured memory_bytes: 604
import sys
sys.setrecursionlimit(500*500)


N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]

for edge in edges:
  A[edge[0]].append([edge[1],edge[2]])
  A[edge[1]].append([edge[0],edge[2]])
  
depth = [-1] * (N+1)
depth[1] = 0

def dfs(A,s):
  for v in A[s]:
    if depth[v[0]] == -1:
      depth[v[0]] = depth[s] + v[1]
      dfs(A,v[0])
      
dfs(A,1)

for d in depth[1:]:
  if d % 2 == 0:
    print(0)
  else:
    print(1)





Measured memory_bytes: 102104
#include <bits/stdc++.h>
#define ll long long 
#define endl '\n'
#define debug(x)  cout<<x<<" ";
#define for(i,n) for(i=0;i<n;i++)
#define fastInOut   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    fastInOut
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
      cout<<"bust";
      else 
      cout<<"win";
    return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int M;
int D[200200], C[200200];
int loop[10];

signed main() {
    cin >> M;
    //loop[0] = 1;
    //loop[1] = 9;
    //loop[2]=9;

    int ans = 0;
    rep(i, M) {
        cin >> D[i] >> C[i];
        ans += C[i];
        ans += C[i] / 9 * D[i];
        C[i] %= 9;
        if (C[i] == 0) {
            C[i] = 9;
            ans -= D[i];
        }
    }
    ans -= 1;
    int d = D[0];
    C[0]--;
    rep(i, M) {
        rep(j, C[i]) {
            d += D[i];
            if (d >= 10) {
                d = d / 10 + d % 10;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    string str[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"}; 
    string s;
    cin >> s;
    for(int i=0;i<7;i++){
        if(s==str[i])   cout << 7-i;
    }
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int amount = 0;
		int kaihuku = 0;
		Integer Array[] = new Integer[N];

		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
			if(i!=0){
				for(int j = 0; j < i; j ++){
					kaihuku =  Array[i]*Array[j];
					amount += kaihuku;
				}
			}
		}
		System.out.println(amount);
		sc.close();
	}
};

Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		StringBuffer S = new StringBuffer(sc.next());
		String t="keyence";
		boolean xx=true;
		
		
		for(int a=0;a<t.length();a++) {
			if(S.charAt(a)!=t.charAt(a)) {
				int g=7-a;
				String t1=S.substring(S.length()-g,S.length());
				String t2=t.substring(7-g,7);
				if(!(t1.equals(t2))) {
					xx=false;
				}
			}
			
			
		}
		
		
		
		
		
		if(xx)p("YES");
		else p("NO");
		
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
    int n,cnt=0,i,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&temp);
        while(temp%2==0){
            temp/=2;
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<BinaryIndexedTree> dp1(n+1, BinaryIndexedTree(k+1));
    vector<BinaryIndexedTree> dp2(n+1, BinaryIndexedTree(k+1));
    dp1[0].add(0, 1);
    dp2[0].add(0, 1);
    for(int i=0; i<n; ++i){
        for(int j=0; j<=k; ++j){
            if(dp1[i].sum(j, j) > 0){
                dp1[i+1].add(j, 1);
                int j2 = min(k, j + a[i]);
                dp1[i+1].add(j2, 1);
            }
            if(dp2[i].sum(j, j) > 0){
                dp2[i+1].add(j, 1);
                int j2 = min(k, j + a[n-1-i]);
                dp2[i+1].add(j2, 1);
            }
        }
    }

    int ans = n;
    for(int i=0; i<n; ++i){
        for(int x=0; x<k; ++x){
            if(dp1[i].sum(x, x) > 0 && dp2[n-1-i].sum(k-x-a[i], k-x-1)){
                -- ans;
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int a,b,c,d;
	std::cin >> a>>b>>c>>d;
	std::cout << (a-c)*(b-d) << std::endl;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;
   int n,a,b,c;
int main()
{
    cin>>n>>a>>b;
 
     c  = min(a*n,b);
     cout<<c;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using Graph = vector< vector< int > > ;
 
const int64_t smax = 1001001 * 3; 
vector<int64_t> seen(100002*3, smax);

 
int main() {
  int N,M,S,T;
  cin >> N >> M;
 
  Graph G((N+1)*3);
  for (int i=0;i<M;++i ) {
    int a,b;
    cin >> a >> b;
//    --a; --b;
    G[3*a].push_back(3*b+1);
    G[3*a+1].push_back(3*b+2);
    G[3*a+2].push_back(3*b);
  }
  cin >> S >> T;
//  --S; --T;
  queue<int> q;
  q.push(S*3);
  seen[S*3] = 0;
  while( !q.empty() ) {
    int v = q.front();
    q.pop();
    for( auto next_v : G[v] ) {
      if (seen[next_v] != smax) continue;
      seen[next_v] = seen[v] + 1;
      q.push(next_v);
    }
  }
  if (seen[T*3] != smax) cout << seen[T*3]/3 << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 18944
// E - Red and Green Apples
#include <bits/stdc++.h>
using namespace std;
#define allr(x) (x).rbegin(),(x).rend()

int main(){
	int X, Y, A, B, C; cin>>X>>Y>>A>>B>>C;
	vector<int> E(A);
	while(A--) cin>>E[A];
	sort(allr(E));
	E.resize(X+B);
	while(B--) cin>>E[X+B];
	sort(E.rbegin(), E.rend()-X);
	E.resize(X+Y+C);
	while(C--) cin>>E[X+Y+C];
	sort(allr(E));
	cout<< accumulate(E.begin(), E.begin()+X+Y, 0LL) <<endl;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
 ll n,m;
 
 cin>>n>>m;
 
 vector<ll>adj[n+1];
 
 for(ll i=0;i<m;i++){
     ll x,y;
     cin>>x>>y;
     
     adj[x].pb(y);
     adj[y].pb(x);
 }
 
 
 //ll cnt=(n-1)-m;
 bool mark[n+1];
 memset(mark,false,sizeof(mark));
 
 ll cnt=0;
 
 
 function<void(ll,ll)>dfs=[&](ll s,ll p){
     mark[s]=true;
     
     for(auto a:adj[s]){
         if(!mark[a])
         dfs(a,s);
     }
 };
 
 for(ll i=1;i<=n;i++){
     if(!mark[i]){
         cnt++;
         dfs(i,-1);
     }
 }
 
 cnt--;
 
 cout<<cnt<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}


Measured memory_bytes: 11628
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;
constexpr ll MOD = 1e9+7;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

// ax + by = d
template <class T>
T ext_gcd(T a, T b, T& x, T& y)
{
    x = 1; y = 0;
    T xb = 0, yb = 1;
    T xr, yr, q, r;
    while(b != 0){
        q = a/b;
        xr = x - q * xb;
        yr = y - q * yb;
        r = a - q * b;

        x = xb;
        y = yb;
        a = b;
        xb = xr;
        yb = yr;
        b = r;
    }
    return a;
}

ll modinv(ll a){
    ll x, y;
    ext_gcd(a, MOD, x, y);
    x = (x < 0) ? (MOD - (-x) % MOD) : x % MOD;
    if(x >= MOD) x -= MOD;
    return x;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto& x: A) cin >> x;

    vector<ll> inv(N+2);
    for(int i=1; i<=N+1; i++) inv[i] = modinv(i);

    ll p=0, ans=0;
    for(int i=1; i<=N; i++){
        p += inv[i]; p %= MOD;
    } 
    for(int i=0; i<N; i++){
        ans += p * A[i];
        ans %= MOD;
        p += inv[i+2] - inv[N-i];
        if(p<0) p += MOD;
        p %= MOD;
    }

    for(int i=1; i<=N; i++){
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: Z[i]=sとs[i..]の最長共通部分列の長さ
// TimeComplexity: $\mathcal{O}(N)$ 
// Verifyed: ARC 060 D

auto z_algorithm(const string &s){
	int n=s.size(),i=1,j=0,k;
	vector<int> z(n,n);
	while(i<n){
		while(i+j<n&&s[i+j]==s[j]) j++;
		z[i]=j,k=!!j;
		while(i+k<n&&k+z[k]<j) z[i+k]=z[k],k++;
		i+=k+!j,j-=k;
	}
	return z;
}

int main(void){
	string s;
	cin >> s;
	const int n=s.size();

	bool same=true;
	for(auto &c:s) if(s[0]!=c) same=false;
	if(same){
		cout << int(s.size()) << endl;
		cout << 1 << endl;
		return 0;
	}

	auto Z1=z_algorithm(s);
	reverse(_all(s));
	auto Z2=z_algorithm(s);

	vector<int> G1(n+1,true),G2(n+1,true);

	for(int p=1;p<n;++p){
		if(G1[p]==false) continue;
		for(int k=2;(k-1)*p<=Z1[p];++k)
			G1[k*p]=false;
	}

	for(int p=1;p<n;++p){
		if(G2[p]==false) continue;
		for(int k=2;(k-1)*p<=Z2[p];++k)
			G2[k*p]=false;
	}

	if(G1[n]){
		cout << 1 << endl;
		cout << 1 << endl;
	}else{
		cout << 2 << endl;
		int ans=0;
		rep(i,1,n) if(G1[i]&&G2[n-i]) ans++;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 8708
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 555
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

ll fac[sz],_fac[sz];
void init(){_fac[0]=fac[0]=1;rep(i,1,sz-1) _fac[i]=inv(fac[i]=fac[i-1]*i%mod);}
ll C(int n,int m){return n>=m&&m>=0?fac[n]*_fac[m]%mod*_fac[n-m]%mod:0;}

int n,X;
int L[sz],cnt[sz];

ll dp[2][sz][sz]; // 考虑了哪些长度，用了几个线段，总长度是多少 
int book[2][sz][sz],T;

int main()
{
	file();
	init();
	read(n,X);
	rep(i,1,n) read(L[i]),++cnt[L[i]];
	int cur=0;
	dp[cur][0][0]=1;book[cur][0][0]=T=1;
	drep(i,X,1)
	{
		rep(j,0,X/i) rep(k,0,X-j+5) if (dp[cur][j][k]&&book[cur][j][k]==T)
		{
			ll w=dp[cur][j][k];
			rep(l,0,(X-k-j+5)/i)
			{
				if (book[cur^1][j+l][k+i*l]!=T+1) dp[cur^1][j+l][k+i*l]=0,book[cur^1][j+l][k+i*l]=T+1;
				(dp[cur^1][j+l][k+i*l]+=w*_fac[l]%mod*ksm(k+i*l-(i-1)*(j+l),cnt[i])%mod)%=mod;
			}
		}
		++T;cur^=1;
	}
	rep(i,1,X) rep(j,1,X) if (book[cur][i][j]!=T) dp[cur][i][j]=0;
	ll ans=0;
	rep(i,1,X) rep(j,1,X)
	{
		int k=X-j;
		k-=i-1;
		(ans+=dp[cur][i][j]*fac[i]%mod*C(k+i,i)%mod*(((k+(i-1))&1)?mod-1:1ll)%mod)%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

/*ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}*/
int main()
{
    int n,i,j,k;
    cin>>n>>k;
    vi a(n),m(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];m[i]=INT_MAX;    }
    m[0]=0;
    m[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        j=1;
        while(j<=k && i-j>=0)
        {
            m[i]=min((abs(a[i-j]-a[i])+m[i-j]),m[i]);
            j++;
        }
    }
    cout<<m[n-1];
    return 0;

}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let v: Vec<i32> = (0..n).map(|_| read()).collect();
    let c: Vec<i32> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    for (x, y) in v.iter().zip(c.iter()) {
        if x > y {
            ans += x - y;
        }
    }
    println!("{}", ans);
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  int ans = 0;
  rep(i,n)
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
	int N;
  	cin >> N;
  	vector<long long> v(N);
  	for(int i=0; i<N; i++){
      cin >> v[i]; 
    }

    for(int i=0; i<N; i++){
        if(v[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }

    long long prod=1;
    for(int i=0; i<N; i++){
        if(v[i] <= 1000000000000000000/prod){
            prod *= v[i];
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout << prod <<endl;
}



Measured memory_bytes: 4052
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (N+1)
ans = 0
for i in range(N):
  cnt[A[i]] +=1
for i in range(N+1):
  ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(N):
  print(ans - cnt[A[i]] + 1)

Measured memory_bytes: 26268
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		int N = Integer.parseInt(br.readLine());
		
		int r0 = Integer.parseInt(br.readLine());
		int r1 = Integer.parseInt(br.readLine());
		int max_profit = r1 - r0;
		int min_r = Math.min(r0, r1);
		for (int i = 2; i < N; i++) {
			int r = Integer.parseInt(br.readLine());
			max_profit = Math.max(max_profit, r - min_r);
			min_r = Math.min(min_r, r);
		}
		System.out.println(max_profit);
	}
}

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

int main(){
  long long h, s, a;
  int k;
  cin >> h;
  s = 1;
  a = 1;
  k = 0;
  while(h >= s){
    s = s * 2;
    k++;
  }
  cout <<  s - 1 << endl;
}

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

#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 110000


int main(){
	int n, m, temp;
	vector<int> ve;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>temp;
		ve.push_back(temp);
	}
	cin>>m;
	
	for(int i = 0, j = 0; i < m; i++){
		cin>>temp;
		if(j >= n)continue;
		while(ve[j] < temp && j < n)j++;
		if(ve[j] == temp){
			cout<<temp<<endl;
			j++;
		}
	}
	return 0;
}


Measured memory_bytes: 3928
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    if (n%2==0) {
      System.out.println(n/2);
    }else{
      System.out.println(n/2+1);
    }
  }
}


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

int main(){
  long long int N, M, C, ans = 0;
  cin >> N >> M >> C;
  vector<long long int> b(M), c(N,0);
  vector<vector<long long int>> a(N,vector<long long int>(M));
  for(int i = 0; i < M; i++){
    cin >> b.at(i);
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> a.at(i).at(j);
    }
  }

  for(int i = 0; i < N; i++){
    for(int j = 0;j < M;j++){
      c.at(i) += a.at(i).at(j)*b.at(j);
    }
    if(c.at(i) + C > 0){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256