akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c)
      co(rM(a*b,c))
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.util.function.Function;

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

        String string = sc.next();
        String[] strings = string.split("");

        String ss = strings[0];

        Map<String,Integer> map = Arrays.asList(strings)
                .stream()
                .collect(Collectors.groupingBy(
                        Function.identity(),
                        Collectors.summingInt( s -> 1)));
        
        if (map.size() == 2 && map.get(ss) == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 28884
#include<bits/stdc++.h>
using namespace std;
int im[100010]={};
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    im[a]++;
    im[b+1]--;
  }
  int ans;
  for(int i=1;i<=n+2;i++){
    im[i]+=im[i-1];
    if(im[i-1]>=i-2)ans=i-2;
  }
  cout<<ans<<endl;
  return 0;
}



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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
priority_queue<LL>d,x;
LL q;
LL sta,pre,vis;
LL b,suX,suD,mid;
int main(){
	ios::sync_with_stdio(false);
	cin>>q;
	for(int i=1;i<=q;i++){
		LL opt,l,r;
		cin>>opt;
		if(opt==1){
			cin>>l>>r;
			b+=r;
			if(!sta)sta=1,pre=l,mid=l;
			else{
				if(!vis){
					vis=1;
					if(l>pre){
						x.push(-l);
						suX=l;
						mid=pre;
					}else{
						x.push(-pre);
						suX=pre;
						mid=l;
					} 
				}else{
					int ca=0;
					if(l<mid)d.push(l),suD+=l,ca=1;
					else x.push(-l),suX+=l,ca=2;
					if(ca==1){
						if(d.size()-x.size()>=1){
							int now=d.top();
							d.pop();
							suD-=now;
							x.push(-mid);
							suX+=mid;
							mid=now;
						}
					}else{
						if(x.size()-d.size()>=2){
							int now=x.top();
							x.pop();
							suX+=now;
							d.push(mid);
							suD+=mid;
							mid=-now;
						}
					}
				}
			}
		}else{
			if(!vis)cout<<pre<<' '<<b<<endl;
			else{
				cout<<mid<<' '<<suX-mid*(LL)x.size()+mid*(LL)d.size()-suD+b<<endl;
			}
		}
	}	
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e13+5;
const int maxn=1e6+8;
const double PI=acos(-1);
const ll mod=1e9+7;
ll n,m;
char str[maxn];
string s[100005];
vector<ll>num[100005];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",str);
        int len=strlen(str);
        for(int k=0;k<len;k++)
            num[i].push_back(str[k]);
        sort(num[i].begin(),num[i].end());
        int sz=num[i].size();
        for(int k=0;k<sz;k++)
        {
            char ch[1];
            ch[0]=num[i][k];
            string te=ch;
            s[i]+=te;
        }
    }
    sort(s+1,s+1+n);
    ll sum=0,cot=1;
    for(int i=1;i<=n;i++)
    {
        if(s[i]==s[i-1])
            cot++;
        else
        {
            sum+=cot*(cot-1)/2;
            cot=1;
        }
    }
    sum+=cot*(cot-1)/2;
    printf("%lld\n",sum);
    return 0;
}


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

const int N = 1e5 + 1;

set < int > e, o;
vector < pair < int, int > > anse, anso;
int a[N][2];

main() {
	int n; cin >> n;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
	  a[x][i % 2]++;
	  if(i % 2 == 0) {
	  	e.insert(x);
	  } else {
	  	o.insert(x);
	  }
	}
	
	for(int i = 0; i <= 1e5; i++) {
		anse.push_back( { n / 2 - a[i][0], i } );
	}
	

	for(int i = 0; i <= 1e5; i++) {
		anso.push_back( { n / 2 - a[i][1], i } );
	}

	sort(anse.begin(), anse.end());	
	sort(anso.begin(), anso.end());

	if(anse[0].second == anso[0].second) {
		cout << min(anse[0].first + anso[1].first, anse[1].first + anso[0].first) << endl;
	} else {
		cout << anse[0].first + anso[0].first << endl;
	}
}

Measured memory_bytes: 8052
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = A * B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
    
using namespace std;
ll bin(ll a[],ll s,ll e,ll x){
    ll m=(s+e)/2;
if(s==e){if(a[s]<=x) return s;else return s-1;}
else if(m==s){
    if(a[s]<=x&&a[e]<=x) return s+1;
    else if(a[s]<=x&&a[e]>x) return s;
    else return s-1;
}
else if(a[m]<=x) return bin(a,m+1,e,x);
else return bin(a,s,m-1,x);
}  

int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
   h1=h1*60+m1;h2=h2*60+m2;
   if(h2-h1<k) cout<<"0\n";
   else cout<<h2-h1-k<<"\n";
 
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
 
    return 0;
}   

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        private struct Process { 
            public string name { get; set; }
            public int time{ get; set; }
        }
        public void Solve(ConsoleInput cin) {
            var Q = new Queue<Process>();
            var n = cin.ReadInt;
            var quantum = cin.ReadInt;
            for(int i = 0; i < n; i++) {
                Q.Enqueue(new Process { name = cin.Read, time = cin.ReadInt });
            }
            var elapsedTime = 0;
            while(Q.Any()) {
                var current = Q.Dequeue();
                if(current.time <= quantum) {
                    Console.WriteLine($"{current.name} {elapsedTime + current.time}");
                    elapsedTime += current.time;
                } else {
                    current.time -= quantum;
                    Q.Enqueue(current);
                    elapsedTime += quantum;
                }
            }
        }
    }

    static class ExtendClass {
        public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



Measured memory_bytes: 28264
#![allow(dead_code)]
use std::io;

fn main() {
    solve_c();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i64>().unwrap())
        .collect();

    let mut max = -1 * 1_000_000_i64;
    let mut min = 1_000_000_i64;
    let mut sum = 0;

    for i in v {
        if max < i {
            max = i;
        }
        if i < min {
            min = i;
        }
        sum += i;
    }
    println!("{} {} {}", min, max, sum);
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                if i % 2 == 0 {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!("#");
                        } else {
                            print!(".");
                        }
                    }
                } else {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!(".");
                        } else {
                            print!("#");
                        }
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_b() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                for j in 0..w {
                    if 1 <= i && i < h - 1 && 1 <= j && j < w - 1 {
                        print!(".");
                    } else {
                        print!("#");
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_a() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for _i in 0..h {
                for _j in 0..w {
                    print!("#");
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
long long divi(long long a, long long b, long long c){
	int bad = a % c;
	if(bad) a += c - bad;
	bad = b % c;
	if(bad) b -= bad;
	if(a <= b) return b/c - a/c + 1;
	else return 0;
}
long long gcd(long long a, long long b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}
int main(){
	long long a, b, c, d; cin >> a >> b >> c >> d;
	cout << b - a + 1 - divi(a, b, c) - divi(a, b, d) + divi(a, b, c / gcd(c, d) * d) << endl;
	return 0;
}


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

int main(){
	string str;
	int n;
	cin >> str >> n;
	char x = 'x';
	int f = 0, s = 0;
	int num[20];
	bool used[20];
	for(int i = 0; i < 20; i++) used[i] = false;
	char ope[20];
	for(int i = 0; i < str.size(); i++){
		if(i%2 == 0){
			num[i/2] = str[i]-'0';
		} else{
			ope[i/2] = str[i];
		}
	}
	int t = -1;
	for(int i = 0; i < str.size()/2; i++){
		if(ope[i] == '*'){
			if(t == -1){
				t = num[i]*num[i+1];
				used[i] = true;
				used[i+1] = true;
			} else{
				t *= num[i+1];
				used[i+1] = true;
			}
		} else{
			if(t != -1) f += t;
			t = -1;
		}
	}
	if(t > 0) f += t;
	for(int i = 0; i < (str.size()+1)/2; i++){
		if(!used[i]) f += num[i];
	}
	for(int i = 0; i < str.size(); i++){
		if(i%2 == 0){
			if(x == 'x') s = str[i]-'0';
			if(x == '+') s += str[i]-'0';
			if(x == '*') s *= str[i]-'0';
		} else{
			x = str[i];
		}
	}
	if(s == n){
		if(f == n) cout << "U" << endl;
		else cout << "L" << endl;
	} else{
		if(f == n) cout << "M" << endl;
		else cout << "I" << endl;
	}
}

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

int main() {

	int n, p1 = 0, p2 = 0, duel;
	string c1, c2;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> c1 >> c2;
		duel = c1.compare(c2);
		if (duel > 0) {
			p1 += 3;
		} else if (duel < 0) {
			p2 += 3;
		} else {
			p1++;
			p2++;
		}
	}
	cout << p1 << " " << p2 << endl;

	return 0;
}

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

/*
int main(){
	int a,b; cin >> a >> b;
	int tmp=b; int b_digit=0;
	while(tmp!=0){
		++b_digit;
		if(tmp%10!=0) {
			tmp/=10; continue;
		} else break;
	}
	a*=pow(10,b_digit);

	for(int i=1;i<=1000;++i){
		if( i * i == a + b ) { cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl;
}
*/

int main(){
	string a,b;cin>>a>>b;
	int n=stoi(a+b);
	for(int i=0;i<=317;++i){
		if( i * i == n ) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long long ll;
ll mod=1e9+7;
int N,M;
vector<int> G[1000],rG[1000],vs;
bool used[1000];
int cmp[1000];
void add_edge(int from,int to){
	G[from].pb(to);
	rG[to].pb(from);
}
void dfs(int v){
	used[v]=1;
	for(int a:G[v]) if(!used[a]) dfs(a);
	vs.pb(v);
}
void rdfs(int v,int k){
	used[v]=1;
	cmp[v]=k;
	for(int a:rG[v]) if(!used[a]) rdfs(a,k);
}
int scc(){
	memset(used,0,sizeof(used));
	vs.clear();
	rep(v,N) if(!used[v]) dfs(v);
	memset(used,0,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]]) rdfs(vs[i],k++);
	}
	return k;
}
vector<int> gg[1000];
bool vis[1000];
int deg[1000];
ll ddfs(int i){
	ll ret=1;
	for(int v:gg[i]) ret=ret*ddfs(v)%mod;
	return (ret+1)%mod;
}
int main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		add_edge(a-1,b-1);
	}
	int k=scc();
	rep(i,N) for(int a:G[i]){
		if(cmp[i]!=cmp[a]){
			gg[cmp[a]].pb(cmp[i]);
			deg[cmp[i]]++;
		}
	}
	rep(i,k){
		sort(all(gg[i]));
		gg[i].erase(unique(all(gg[i])),gg[i].end());
	}
	ll ans=1;
	rep(i,k) if(deg[i]==0){
		ans*=ddfs(i);
		ans%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1368
#include <iostream>
#include <vector>
#include <deque>
#include <cstdio>

using namespace std;

int main(){
	int N, L;
	while(cin >> N >> L){
		deque< pair<double, double> > dq;
		int t, v; cin >> t >> v;
		dq.push_back(make_pair(t, v));
		printf("%.8lf\n", (double)t);
		double sumT = t * (double)v;
		for(int i=1;i<N;i++){
			cin >> t >> v;
			double sub = v;
			for(int j=0;j<dq.size();j++){
				if(dq[j].second <= sub){
					sumT -= dq[j].first * dq[j].second;
					sub -= dq[j].second;
					dq[j].second = 0;
				} else {
					sumT -= dq[j].first * sub;
					dq[j].second -= sub;
					break;
				}
			}
			sumT += t * (double)v;
			printf("%.8lf\n", sumT/L);
			while(!dq.empty() && dq[0].second < 1e-8) dq.pop_front();
			pair<double, double> p = make_pair(t, v);
			while(!dq.empty()){
				if(dq.back().first < p.first) break;
				double nt = dq.back().first * dq.back().second + p.first * p.second;
				double nv = dq.back().second + p.second;
				p.first = nt/nv;
				p.second = nv;
				dq.pop_back();
			}
			dq.push_back(p);
		}
	}
}



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

int main() {
    int K, S;
    cin >> K >> S;

    int ans = 0;

    for (int i = 0; i <= K; ++i){
        for (int j = 0; j <= K; ++j) {
            int z = S - i - j;
            if (0 <= z && z <= K) ans ++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def check_bracket(str)
  stack = []
  str.split('').each do |st|
    if st == '[' or st == '('
      stack.push(st)
    elsif st == ']' and stack.pop != '['
      return false
    elsif st == ')' and stack.pop != '('
      return false
    end
  end
  return stack.empty?
end

while gets do
  str = $_.chomp
  break if str == '.'
  puts check_bracket(str) ? 'yes' : 'no'
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int mid = n/2;
    cout << d[mid] - d[mid-1];
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int sum = 1;
	int n;
	cin >> n;
	int k = 0;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		if (a == 0) {
			cout << 0;
			return 0;
		}
		if (sum > (1000000000000000000)/a) {
			k = 1;
		}
		else {
			sum = sum * a;
		}
	}
	if (k == 1) {
		cout << -1;
		return 0;
	}
	cout << sum;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<vector>
#include<algorithm> // sort
#include<functional> // pair


using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n);
		ll ans=0;

		for(int i=0;i<n;i++)
		{
			scanf("%lld", &a[i]);
			ans+=a[i]-1;
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val a    = inputs(0).toInt
  val b    = inputs(1).toInt
  val c    = inputs(2).toInt
  val x    = inputs(3).toInt

  println(solve(a, b, c, x))

  def solve(a: Int, b: Int, c: Int, x: Int): Int = {
    var ans = 0
    (0 to a).foreach { i =>
      (0 to b).foreach { j =>
        (0 to c).foreach { k =>
          val price = 500 * i + 100 * j + 50 * k
          if (x == price) {
            ans = ans + 1
          }
        }
      }
    }

    ans
  }
}

Measured memory_bytes: 54780
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

int gogo[300000];

void solve() {
	int n, m;
	cin >> n >> m;
	stack<int> next;
	REP(i, m) {
		int a;
		cin >> a;
		next.push(a);
	}
	while (next.empty() == false) {
		int now = next.top();
		next.pop();
		if (gogo[now] == 0) {
			gogo[now] = 1;
			cout << now << endl;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (gogo[i] == 0) {
			cout << i << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 5424
def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b


if __name__ == "__main__":
    a, b = map(int,input().split())
    print(a * b // gcd(a,b))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
  int n;
  cin>>n;
  ll vec[n][3];
  ll minabs[n];
  for(int i=0;i<n;i++){
    cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
    minabs[i]=min(abs(vec[i][0]),abs(vec[i][1]));
  }
  ll ans[n+1];
  for(int i=0;i<=n;i++){
    ans[i]=1e13;
  }
  int vecc[n];
  ll cost[n];
  ll sum;
  int x=100;
  for(int bit=0;bit<(1<<n);bit++){
    int t=0;
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        vecc[t]=i;
        t++;
      }
    }
    if(t==n){
      ans[t]=0;
      continue;
    }
    if(t>=x){
      continue;
    }
    for(int i=0;i<n;i++){
      cost[i]=minabs[i];
    }
    for(int bitb=0;bitb<(1<<t);bitb++){
      for(int i=0;i<t;i++){
        if(bitb&(1<<i)){ //縦に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][0]-vec[vecc[i]][0]));
          }
        }
        else{ //横に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][1]-vec[vecc[i]][1]));
          }
        }
      }
      sum=0;
      for(int i=0;i<n;i++){
        sum+=cost[i]*vec[i][2];
        cost[i]=minabs[i];
      }
      ans[t]=min(ans[t],sum);
      if(ans[t]==0){
        x=min(x,t);
      }
    }
  }
  
  for(int i=0;i<n+1;i++){
    if(i>=x){
      cout<<0<<endl;
    }
    else{
      cout<<ans[i]<<endl;
    }
  }
}

Measured memory_bytes: 3652
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

ans = 'War'

for z in range(X+1, Y+1):
    if len(list(filter(lambda x: x < z, x))) == N and len(list(filter(lambda x: x >= z, y))) == M:
        ans = 'No War'
        break

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void) {
  int i,x,y,ans,turu,kame;
  i=0;
  x=0;
  y=0;
  kame=0;
  turu=0;
  ans=0;
  scanf("%d",&x);
  scanf("%d",&y);
  kame=(y-2*x)*4/2;
  turu=(4*x-y)*2/2;
  if(4*x>=y&&2*x<=y&&y%2==0)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 1684
X = set()
for x in input():
  X.add(x)
X = sorted(X)
codeA = "a".encode("sjis")[0]
codes = [bytes([codeA + i]).decode("sjis") for i in range(26)]
codes.append("None")
print(codes[sum([1 for i, x in enumerate(X) if x == codes[i]])])



Measured memory_bytes: 3316
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int x = sc.nextInt();
        out.println(10 - x / 200);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32956
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    int D;cin>>D;
    int c[26],last[26]={},s[365][26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    REP(i,D){
        int tmp = -1e9,res = 0;
        REP(j,26){
            int up = 0;
            REP(k,26){
                if(j==k) up += s[i][k];
                else up -= c[k]*(i-last[k]);
            }
            if(tmp < up){
                tmp = up;
                res = j;
            }
        }
        cout<<res+1<<"\n";
    }
}


Measured memory_bytes: 3676
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long H=sc.nextLong();
		long W=sc.nextLong();
		if(H>W) {
			H^=W;W^=H;H^=W;
		}
		if(H!=1) {
			System.out.println(((W+1)/2)*((H+1)/2)+(W/2)*(H/2));
		}else {
			System.out.println(1);
		}
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;
  int d;
  cin >> a >> b >> c >> d;
  
  if ( a+b > c+d){
    cout << "Left" << endl;
  } else if ( a+b == c+d){
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

int main(void) {
	string str;
	cin >> str;
	bool ac = (str[0] == 'A');
	bool ec = false;
	for (int i = 1; ac && i < str.length(); ++i) {
		if (i > 1 && i < str.length()-1) {
			if (str[i] == 'C') {
				if (!ec) {
					ec = true;
				}
				else {
					ac = false;
				}
			}
			else if (str[i] < 'a' || str[i] > 'z') {
				ac = false;
			}
		}
		else {
			if (str[i] < 'a' || str[i] > 'z') {
				ac = false;
			}
		}
	}
	if (ac && ec) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

//?\????????????????
public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int year;
		int month;
		int day;
		String era = null;
		int eraYear = 0;


		while(sc.hasNext()) {
			boolean flag = false;
			year = sc.nextInt();
			month = sc.nextInt();
			day = sc.nextInt();


			if((year == 1989 && month == 1 && day >= 8) || (year == 1989 && month >= 2)  || (year >= 1990)) {
				era = "heisei";
				eraYear = year - 1989 + 1;
			} else if((year == 1926 && month == 12 && day >= 25) || (year >= 1927)) {
				era = "showa";
				eraYear = year - 1926 + 1;
			} else if((year == 1912 && month == 7 && day >= 30) || (year == 1912 && month >= 8)  || (year >= 1913)) {
				era = "taisho";
				eraYear = year - 1912 + 1;
			} else if((year == 1868 && month == 9 && day >= 8) || (year == 1868 && month >= 10)  || (year >= 1869)) {
				era = "meiji";
				eraYear = year - 1868 + 1;
			} else {
				flag = true;
			}

			if(flag) {
				System.out.println("pre-meiji");
			} else {
				System.out.println(era + " " + eraYear + " " + month + " " + day);
			}

		}
	}

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

auto main() -> int
{
	int N, i, min = 0, ans = 1;
    
    cin >> N;
    
    if(N > 1)
    {
    	cin >> i;
        min = i;
        
    	REP(a, N-1)
        {
            cin >> i;
            if(i <= min)
            {
            	min = i;
                ans++;
            }
        }
    }
    
    else cin >> i;
    
    cout << ans << endl;

}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second 
#define pb push_back
#define all(x) x.begin(),x.end()
#define fileoi freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;
const ll maxn=2e5+5,inf=1e18+18,mod=1e9+7;
ll n,m,ans;
vector <ll> adj[maxn];
bool mark[maxn];
ll dfs(int u){
	mark[u]=1;
	ll x=1;
	for(int j:adj[u]){
		if(!mark[j]){
			x+=dfs(j);
		}
	}
	return x;
}
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		adj[b].pb(a);
		adj[a].pb(b);
	}
	for(int i=1;i<=n;i++){
		if(!mark[i]){
			ans=max(ans,dfs(i));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 24108
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	s := nextWord()
	var i, j int

	var dp [][]int
	for i = 0; i <= n; i++ {
		var dpj []int
		for j = 0; j <= n; j++ {
			dpj = append(dpj, 0)
		}
		dp = append(dp, dpj)
	}

	var ans int
	for j = n - 1; j >= 0; j-- {
		for i = j - 1; i >= 0; i-- {
			if s[i] == s[j] {
				dp[i][j] = dp[i+1][j+1] + 1
				if i+dp[i][j] <= j && ans < dp[i][j] {
					ans = dp[i][j]
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 331720
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int mat[305][305];

int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= N; j++)
			scanf("%d", &mat[i][j]);
	ll ans = 0;
	for(int i=1;i<=N;i++)
		for (int j = i + 1; j <= N; j++)
		{
			int flag = 0;
			for (int k = 1; k <= N; k++)
			{
				if (k == i || k == j) continue;
				if (mat[i][k] + mat[k][j] < mat[i][j]) { printf("-1"); return 0; }
				if (mat[i][k] + mat[k][j] == mat[i][j]) flag = 1;
			}
			if (!flag) ans += mat[i][j];
		}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
template <typename T>
class SegTree{ //区間での最小値を求めることを想定
  vector<T> dat;
  int n;

  public:
  SegTree(vector<T> d){
    int n_=d.size();
    n=1;while(n<n_)n*=2; //nを2の冪乗に拡張する
    dat=vector<T>(2*n-1,T());
    for(int i=0;i<n_;i++)update(i,d[i]);
  }
  
  void update(int k,T a){ //k番目をaに変更
    k+=n-1; //(k=2*n-1)-n+kの意味
    dat[k]=a;
    while(k>0){ 
      k=(k-1)/2;
      dat[k]=(dat[2*k+1]|dat[2*k+2]);
    }
  }
  //区間[a,b)での最小値を返す. 外から呼ぶときはquery(a,b,0,0,n)みたいになる
  T query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return T(); //ここでINT_MAXを使用していることに注意
    if(a<=l && r<=b)return dat[k];
    return (query(a,b,2*k+1,l,(l+r)/2)|query(a,b,2*k+2,(l+r)/2,r));
  }

  int getn(){return n;}
};
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<bitset<26>>A(N);
  for(int i=0;i<N;i++){
    A[i].set(S[i]-97);
  }
  SegTree<bitset<26>> st(A);
  int N_=st.getn();
    
  int Q;cin>>Q;
  for(int q=0;q<Q;q++){
    int x;cin>>x;
    if(x==1){
      int a;char b;cin>>a>>b;
      bitset<26> t;t.set(b-97);
      st.update(a-1,t);
    }
    else{
      int a,b;cin>>a>>b;
    
      cout<<st.query(a-1,b,0,0,N_).count()<<endl;
    }
  }
  
}

/*
segtreeで文字の配列を持たせる
bitsetで26個


abcdefg

3,6->[4,5,6]になる
   ->[5,6,7](1-index)
a-2,b-1にすればいい?




*/

Measured memory_bytes: 16900
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	ll n,k,s;
	cin >>n>>k>>s;
	if (s != inf) {
		for (int i = 0; i < k; i++) {
			cout << s <<" ";
		}
		for (int i = 0; i < n - k; i++) {
			cout << s + 1 << " ";
			
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s << " ";
		}
		for (int i = 0; i < n - k; i++) {
			cout << 1 << " ";

		}
		cout << endl;
	}
}


Measured memory_bytes: 1280
from heapq import heapify,heappop,heappush

X,Y,Z,K=map(int,input().split())
A=sorted(map(int,input().split()),reverse=True)
B=sorted(map(int,input().split()),reverse=True)
C=sorted(map(int,input().split()),reverse=True)
que=[[-(A[0]+B[0]+C[0]),0,0,0]];heapify(que)
s=set()

for i in range(K):
    p=heappop(que)
    print(-p[0])
    if p[1]<X-1 and not (p[1]+1,p[2],p[3]) in s:
        heappush(que,[-sum([A[p[1]+1],B[p[2]],C[p[3]]]),p[1]+1,p[2],p[3]])
        s.add((p[1]+1,p[2],p[3]))
    if p[2]<Y-1 and not (p[1],p[2]+1,p[3]) in s:
        heappush(que,[-sum([A[p[1]],B[p[2]+1],C[p[3]]]),p[1],p[2]+1,p[3]])
        s.add((p[1],p[2]+1,p[3]))
    if p[3]<Z-1 and not (p[1],p[2],p[3]+1) in s:
        heappush(que,[-sum([A[p[1]],B[p[2]],C[p[3]+1]]),p[1],p[2],p[3]+1])
        s.add((p[1],p[2],p[3]+1))

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


int main() {
  while (1) {  
    int cnt = 0;
    int n;
    int x;
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++ ) {
        for (int k = j + 1; k <= n; k++) {
          if (i + j + k == x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
} 


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;

int main() {
  ll N;
  cin >> N;
  ll M;
  M = pow(N, 0.5);
  rep(i, M){
    if (N%(M-i) == 0){
      print(M-i+N/(M-i) -2);
      return 0 ;
    }
  }
  print(N-1);
}



Measured memory_bytes: 4056
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};


int b_to_w[200010];
int w_to_b[200010];

int main() {
    int N;
    Fill(b_to_w, 0);
    Fill(w_to_b, 0);

    string S;
    cin >> N;
    cin >> S;

    rep(i,N){
        if(S[i]=='#'){
            b_to_w[i+1]=b_to_w[i]+1;
        }else{
            b_to_w[i+1]=b_to_w[i];
        }
    }

    for(int i=N-1; i>=0; i--){
        if(S[i]=='.'){
            w_to_b[i]=w_to_b[i+1]+1;
        }else{
            w_to_b[i]=w_to_b[i+1];
        }
    }


    int minimum=INFint;

    for(int i=0; i<=N; i++){
        minimum=min(minimum, b_to_w[i]+w_to_b[i]);
    }

    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 2180
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = input()
ans = 0
for n in N:
    if n == "2":
        ans += 1

print(ans)


Measured memory_bytes: 5048
#include"bits/stdc++.h"
using namespace std;
int main(){
	string a[3]={"Sunny","Cloudy","Rainy"};
	string ch;
	cin>>ch;
	for(int i=0;i<3;i++){
		if(ch==a[i])cout<<a[(i+1)%3]<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000
#define E -1
#define A 0
#define B 1
#define C 2

int n;
int M[100][100];

void dkr(){
  int d[100];
  int alph[100];
  int min,u;
  int i,v;

  for(i = 0 ; i < n ; i++){
    d[i] = MAX;
    alph[i] = A;
  }

  d[0] = 0;
  alph[0] = B;

  while(1){
    min = MAX;
    u = E;
    for(i = 0 ; i < n ; i++){
      if(alph[i] != C && d[i] < min){
        min = d[i];
        u = i;
      }
    }

    if(u == E)break;
    alph[u] = C;

    for(v=0;v<n;v++){
      if(alph[v] != C && M[u][v] != MAX){
        if(d[u] + M[u][v] < d[v]){
          d[v] = d[u] + M[u][v];
          alph[v] = B;
        }
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i,(d[i] == MAX? -1 : d[i]));
  }
}

int main(){
  int k,u,c,v;
  int i,j;


  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = MAX;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dkr();

  return 0;
}



Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        double a2 = (double) a / 0.08;
        double b2 = (double) b / 0.1;

        double result = Math.ceil(Math.max(a2, b2));
        boolean isMatch = Math.floor(result * 0.08) == a && Math.floor(result * 0.1) == b;

        System.out.println(isMatch ? (int) result : -1);
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		sc.close();

		long cnt = 0;
		if(c >= 1) {
			cnt ++;
			c -= 1;
		}

		if(b >= c) {
			cnt += b + c;
		}else if(b < c) {
			cnt += b*2;
			c -= b;
			if(a >= 1) {
				if(a >= c) {
					cnt += c;
				}else if(a < c) {
					cnt += a;
				}
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23508
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k,s;
	cin>>k>>s;
	int ans=0;
	for(int i=0;i<=k;++i)
    {
	    for(int j=0;j<=k;++j)
	        if(s-i-j<=k && s-i-j>=0) {
                ans++;
                //cout<<i<<' '<<j<<' '<<s-i-j<<endl;
            }
    }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
p = 10**9+7
DP = [[0 for j in range(w+1)] for i in range(h+1)]
DP[0][0] = 1
F = [1, 2, 3, 5, 8, 13, 21][:w]+[1]
for i in range(h):
    for j in range(w):
        a = DP[i][j-1]*F[j-2]*F[w-2-j]
        b = DP[i][j]*F[j-1]*F[w-2-j]
        c = DP[i][j+1]*F[j-1]*F[w-3-j]
        DP[i+1][j] = (a+b+c) % p
print(DP[h][k-1])

Measured memory_bytes: 3064