akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 1e5;
set<int> e[N];

int main(){
    int n;
    cin >> n;
    REP(i,n-1){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;
        e[u].insert(v);
        e[v].insert(u);
    }

    VI visit(n);
    queue<int> que;
    REP(i,n){
        if (e[i].size() == 1){
            que.push(i);
        }
    }

    while (!que.empty()){
        int x = que.front();
        que.pop();
        if (visit[x]) continue;
        // cout << "now" << x << endl;
        // REP(i,n){
        //     cout << i << "  ";
        //     for (int p : e[i]) cout << p << " ";
        //     cout << endl;
        // }
        visit[x] = 1;
        if (e[x].size() == 0){
            cout << "First" << endl;
            return 0;
        }
        int y = *e[x].begin();
        e[x].erase(y);
        e[y].erase(x);
        visit[y] = 1;
        for (int z : e[y]){
            e[z].erase(y);
            if (e[z].size() == 0){
                cout << "First" << endl;
                return 0;
            }
            if (e[z].size() == 1 && !visit[z]){
                que.push(z);
            }
        }
        e[y].clear();
    }

    cout << "Second" << endl;

    return 0;
}






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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b == 2 ? a : gcd(b, a % b);};
ll poww(ll a, ll b, ll md) {
   return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    if(n>=400 && n<=599) cout<<"8\n";
    else if(n>=600 && n<=799) cout<<"7\n";
    else if(n>=800 && n<=999) cout<<"6\n";
    else if(n>=1000 && n<=1199) cout<<"5\n";
    else if(n>=1200 && n<=1399) cout<<"4\n";
    else if(n>=1400 && n<=1599) cout<<"3\n";
    else if(n>=1600 && n<=1799) cout<<"2\n";
    else if(n>=1800 && n<=1999) cout<<"1\n";









    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ll も int も longlongにしてしまう
    #define int long long

    // intを要素に持つ優先順位付きキュー
    std::priority_queue<int> que;

    int height;
    while (cin >> height) {
        que.push(height);
    }
    
    for (int i = 0; i < 3; i++) {
        cout << que.top() << endl;
        que.pop();
    }

    return 0;
}


Measured memory_bytes: 3192
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
map<int,bool> exist;
int main()
{
    int n;
    scanf("%d",&n);
    bool ans=true;
    while(n--)
    {
        int a;
        scanf("%d",&a);
        if(exist.count(a)) ans=false;
        exist[a]=true;
    }
    puts(ans?"YES":"NO");
    return 0;
}


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

int n, k;
int a[MAXN];
ll p[MAXN], poz[MAXN];
ll reza = 0;

int main()
{
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  p[0] = a[0];
  if (a[0] > 0)
    poz[0] = a[0];
  for (int i = 1; i < n; i++) {
    p[i] = p[i - 1] + a[i];
    poz[i] = poz[i - 1];
    if (a[i] > 0)
      poz[i] += a[i];
//cout<<p[i]<<'.'<<poz[i]<<endl;
  }
  for (int i = k - 1; i < n; i++) {
    reza = max(reza, max(0LL,p[i] - (i - k < 0 ? 0 : p[i - k])) + poz[n - 1] - (poz[i] - (i - k < 0 ? 0 : poz[i - k])));
    //cout<<p[i] - (i - k < 0 ? 0 : p[i - k]) + poz[n - 1] - (poz[i] - (i - k < 0 ? 0 : poz[i - k]))<<endl;
  }
  cout << reza;
  return 0;
}


Measured memory_bytes: 2176
#!/usr/bin/env pypy3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

wa = sum([int(s) for s in str(n)])

print('Yes' if n % wa == 0 else 'No')


Measured memory_bytes: 3316
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>



using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int map[10][10000];//0????????????



int main(){
	while(1){
		int R,C;
		scanf("%d %d",&R,&C);
		if(R==0&&C==0)break;
		rep(i,R)rep(j,C){scanf("%d",&map[i][j]);}
		int ans=0;
		for(int i=0;i < 1<<R ;i++){
			int sans=0;
			rep(k,C){
				int rans=0;
				rep(j,R){if( map[j][k]==0 && (i>>j)%2==0 || map[j][k]==1&& (i>>j)%2==1)rans++;}
				sans+=max(rans,R-rans);
			}//????????¨????????°?????°????????????????????????
			ans=max(ans,sans);
		}
		printf("%d\n",ans);
	}
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;


int main(){
      int n; cin>>n;
      vll v(n);
      forn(i,n)cin>>v[i];
      sort(all(v));
      ll ans=0;
      
      
      for(int i=0;i<n-1;i++){
		  for(int j=i+1;j<n;j++){
			  ll temp=v[i]+v[j];
			  ans+= (lower_bound(v.begin()+j,v.end(),temp)-v.begin())-j-1;
		  }
		 }
		 cout<<ans;
	 } 
       
       
       
       
       
       
       
       
       
       
       
       
       
        
    


Measured memory_bytes: 256
def main():
    s = input()

    if s == 'SUN':
        print(7)
    elif s == 'MON':
        print(6)
    elif s == 'TUE':
        print(5)
    elif s == 'WED':
        print(4)
    elif s == 'THU':
        print(3)
    elif s == 'FRI':
        print(2)
    elif s == 'SAT':
        print(1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <map>
using namespace std;
int main(){
    string s;
    map<int,int> a[2];
    int now=0,n;
    while(getline(cin,s)&&now<=1){
        if(s.empty())now++;
        else{
            n=0;
            for(int i=0;s[i]!=',';i++){
                n*=10;
                n+=s[i]-'0';
            }
            if(a[now].find(n)!=a[now].end())a[now][n]++;
            else a[now].insert({n,1});
        }
    }
    for(auto u:a[0])if(a[1].find(u.first)!=a[1].end())printf("%d %d\n",u.first,u.second+a[1][u.first]);
}


Measured memory_bytes: 3320
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int sum;
        int min;
        int[] input1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        
        int N = input1[0];
        int X = input1[1];
        
        int[] input2 = new int[N];
        for(int i = 0; i < N; i++)
        {
            input2[i] = int.Parse(Console.ReadLine());
        }
        
        sum = 0;
        foreach(int x in input2) //input2のsumを求める
        {
            sum += x;
        }
        
        min = input2[0];　　　　　　　　　　　　　//nput2のminを求める
        for (int i = 0; i < input2.Length; i++)
        {
            if (input2[i] < min)
            {
                min = input2[i];
            }
        }
        Console.WriteLine(N + (X - sum)/min);
        
        
        
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<1000;i++)
    {
        int t=i;
        int digit[3];
        digit[2]=t%10;
        t/=10;
        digit[1]=t%10;
        t/=10;
        digit[0]=t%10;
        int now=0;
        for(int j=0;j<n;j++)
        {
            if(s[j]-'0'==digit[now])
            {
                now++;
                if(now==3) break;
            }
        }
        //cout<<now<<'\n';
        if(now==3) cnt++;
    }
    cout<<cnt<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  string ad;
  rep(i, w+2) {
    ad.push_back('#');
  }
  rep(i, h) {
    a[i] = '#' + a[i] + '#';
  }

  cout << ad << endl;
  rep(i, h) cout << a[i] << endl;
  cout << ad << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

double calc(int p,int a,int b,int c,int d,int e,int f,int s,int m){
    int profit=f*s*m-p;
    int time=a+b+c+(d+e)*m;
    return (double)profit/time;
}

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

    int n;
    while(cin>>n,n)
    {
        vector<pair<double,string> > vec;
        REP(i,n){
            string str;
            int p,a,b,c,d,e,f,s,m;
            cin>>str>>p>>a>>b>>c>>d>>e>>f>>s>>m;
            double x=calc(p,a,b,c,d,e,f,s,m);
            vec.push_back(make_pair(-x,str));
        }
        sort(ALL(vec));

        REP(i,n) cout<<vec[i].second<<endl;
        cout<<"#"<<endl;
    }
}


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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    deque<int> cnt;
    int len = 1;
    for(int i = 0; i < N; i++){
        if(i < N-1 && S[i] == S[i+1]){
            len++;
        }else if(i == N-1){
            cnt.push_back(len);
        }else{
            cnt.push_back(len);
            len = 1;
        }
    }


    int p;
    for(int i = 0; i < K; i++){
        if(cnt.size() == 1){
            break;
        }else{
            p = cnt[0] + cnt[1];
            cnt.pop_front();
            cnt.pop_front();
            cnt.push_front(p);
        }

        if(cnt.size() == 1){
            break;
        }else{
            p = cnt[cnt.size()-1] + cnt[cnt.size()-2];
            cnt.pop_back();
            cnt.pop_back();
            cnt.push_back(p);
        }
    }

    int ans = 0;
    for(int i = 0; i < cnt.size(); i++){
        ans += cnt[i]-1;
    }

    cout << ans << endl;


    return 0;
}

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

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

  int n;
  cin >> n;

  long long result = 0;
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    result += cnt[i - x];
    ++cnt[i + x];
  }

  cout << result << '\n';
}

Measured memory_bytes: 20572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//
int main(){
    int n,d; cin>>n>>d;
    cout<<ceil(n*1.0/(2*d+1))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int n;cin>>n;
    int a[n+1];
    int csum[n+1];
    a[0] = 0;
    csum[0] = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        csum[i] = a[i] + csum[i-1];
        }
    int dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    int row,temp;
    for(int col=2;col<=n;col++){
        row=1;
        temp=col;
        while(row<=n && temp<=n){
            dp[row][temp] = 9999999999999999;
            for(int k=row;k<temp;k++){
               dp[row][temp] = min(dp[row][temp],dp[row][k] + dp[k+1][temp] + csum[temp] - csum[row-1]); 
            }
            row++;
            temp++;
        }
    }
    cout<<dp[1][n];

}


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

int main(){
    string S1, S2;
    cin >> S1 >> S2;
    int N1, N2;
    cin >> N1 >> N2;
    string trash;
    cin >> trash;

    if(trash == S1) cout << N1 -1 << " " << N2;
    else cout << N1 << " " << N2 -1;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<ctime>
#include<cstring>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<stack>
#include<deque>
#include<list>
#include<vector>
#define LL long long
/*
#ifdef unix
#define INT64 "%lld"
#else
#define INT64 "%I64d"
#endif
*/
using namespace std;
int n,m,cnt,snt,K,times;
LL oo=1000000007;
struct dic
{
	int x,y,r;
	int c;
}p[110];
int num[110];
int ans;
bool vis[110];
bool f[16777216];
int dis(int x1,int y1,int x2,int y2)
{
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
bool cover(int pos,int state)
{
	for (int i=1;i<pos;i++)
	if (((state>>(i-1))&1)&&dis(p[i].x,p[i].y,p[pos].x,p[pos].y)<(p[i].r+p[pos].r)*(p[i].r+p[pos].r)) 
	return true;
	return false;
}
void dp(int state)
{
	int sum=0;
	for (int i=0;i<n;i++) if ((state>>i)&1) sum++;
	ans=max(ans,n-sum);
	if (f[state]) return;
	f[state]=true;
	for (int i=1;i<=n;i++)
	if (((state>>(i-1))&1)&&!cover(i,state))
	for (int j=i+1;j<=n;j++)
	if (((state>>(j-1))&1)&&p[i].c==p[j].c&&!cover(j,state))
	{
		int tstate=state^(1<<(i-1))^(1<<(j-1));
		dp(tstate);
	}
}
void work()
{
	memset(p,0,sizeof(p));
	for (int i=1;i<=n;i++)
	scanf("%d%d%d%d",&p[i].x,&p[i].y,&p[i].r,&p[i].c);
	ans=0;
	memset(f,0,sizeof(f));
	dp((1<<n)-1);
	printf("%d\n",ans);
}
int main()
{
	scanf("%d",&n);
	while (n!=0)
	{
		work();
		scanf("%d",&n);
	}
    return 0;
}

Measured memory_bytes: 17580
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;cin >> S;
    int n = S.length();
    int len = 0;
    set<char> st;
    st.insert('A');
    st.insert('C');
    st.insert('G');
    st.insert('T');
    int ans = 0;
    rep(i, n) {
        REP(j, i, n - 1) {
            bool ok = true;
            REP(k, i, j) {
                if (st.find(S[k]) == st.end()) ok = false;
            }
            if(ok) ans = max(ans, j - i  + 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };


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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	string s1, s2; cin >> s1 >> s2;
	int ans = 0;
	rep(i, 3){
		if(s1[i] == s2[i]) ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(b % a == 0 ? a + b : b - a);

		sc.close();
	}
}


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

using namespace std;

typedef pair<long long int, pair<long long int, long long int>>one;

#define mod 1000000007LL
int main() {
	long long int V, E;
	cin >> V >> E;
	vector<vector<long long int>>path( V );
	for( size_t i = 0; i < E; i++ ) {
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back( b );
		path[b].push_back( a );
	}
	vector<bool>flag( V );
	vector<pair<long long int, long long int>>two;
	vector<long long int>len( V, LLONG_MAX / 6 );
	for( size_t i = 0; i < V; i++ ) {
		if( !flag[i] ) {
			flag[i] = true;
			len[i] = 0;
			pair<long long int, long long int>memo( 1, 0 );
			queue<pair<long long int, long long int>>que;
			que.push( make_pair( 0, i ) );
			while( que.size() ) {
				auto now = que.front(); que.pop();
				for( auto x : path[now.second] ) {
					if( flag[x] ) {
						if( len[x] % 2 == now.first % 2 ) {
							cout << -1 << endl;
							return 0;
						}
					} else {
						flag[x] = true;
						len[x] = now.first + 1;
						if( len[x] % 2 ) {
							memo.second++;
						} else {
							memo.first++;
						}
						que.push( make_pair( len[x], x ) );
					}
				}
			}
			two.push_back( memo );
		}
	}
	vector<long long int>sub( two.size() );
	long long int xx = 0;

	long long int base = 0;
	map<long long int, long long int>MLL;
	for( size_t i = 0; i < two.size(); i++ ) {
		MLL[abs( two[i].first - two[i].second )]++;
		base += min( two[i].first , two[i].second );
	}
	vector<long long int>dp( V / 2 + 1, -1 );
	dp[base] = 0;
	for( auto now : MLL ) {
		//cout << now.first << " " << now.second << endl;
		for( size_t i = 0; i < V / 2 + 1; i++ ) {
			if( dp[i] >= 0 ) {
				dp[i] = now.second;
			} else if( i < now.first || dp[i - now.first] <= 0 ) {
				dp[i] = -1;
			} else {
				dp[i] = dp[i - now.first] - 1;
			}
		}
	}
	for( long long int i = 0; i < V / 2 + 1; i++ ) {
		if( dp[i] != -1 ) {
			xx = max( i, xx );
		}
	}
	cout << xx*( V - xx ) - E << endl;
}

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

int main()
{
  int n;
  int node,k,vi;
  int graph[100][100];

  cin >> n;
  memset(graph,0,sizeof(graph));
  
  for(int i=0;i < n;i++){
    cin >> node >> k;
    for(int j=0;j < k;j++){
      cin >> vi;
      graph[node-1][--vi] = 1;
    }
  }
  for(int i=0;i < n;i++){
    for(int j=0;j < n;j++){
      if(j) cout << " ";
      if(graph[i][j]) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N;
  cin >> N;
  ll ans = INF;

  for(ll i = 1; i*i <= N; i++){
    if(N % i == 0){
      chmin(ans, (N/i + i));
    }
  }

  cout << ans - 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, tmp;
    
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    
    if (a > b) {
        tmp = a; a = b; b = tmp;
    } if (b > c) {
        tmp = b; b = c; c = tmp;
    } if (a > b) {
        tmp = a; a = b; b = tmp;
    } 
    printf("%d %d %d\n", a, b, c);
    
    
    return 0;
}


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

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define mp 					make_pair
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz 					size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = (1<<30)-1+(1<<30);
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

LL n, a, b;

int main() {
	gi(n); gi(a); gi(b);
	if (n==1) {
		if (a==b) printf ("1\n");
		else printf ("0\n");
	} else {
		if (a>b) printf ("0\n");
		else {
			LL ba = (b*(n-1))+a;
			LL bb = (a*(n-1))+b;
			printf ("%lld\n", ba-bb+1);
		}
	}
	return 0;
}



Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

s=gets.chomp
if s[-1]=="s"
   s+="es"
else
   s+="s" 
end
puts s

Measured memory_bytes: 14264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    ll a = 0;
    a = 1000*(x/500) + 5*((x%500)/5);
    cout << a << endl;
}


Measured memory_bytes: 256
n=int(input())
while n:
    input()
    n-=1
    a=list(map(int,input().split()))
    u,d=0,0
    for i in range(1,len(a)):
        if a[i]-a[i-1]>0:u=max(a[i]-a[i-1],u)
        elif a[i]-a[i-1]<0:d=max(a[i-1]-a[i],d)
    print(u,d)

Measured memory_bytes: 7696
#include <iostream>

using namespace std;
long N,a[100001],b[100001],c[100001],i;
int main()
{
    cin >> N;
    for (i=1;i<=N;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    long A[N],B[N],C[N];
    A[1]=a[1];
    B[1]=b[1];
    C[1]=c[1];
    for (i=2;i<=N;i++)
    {
        A[i]=max(B[i-1],C[i-1])+a[i];
        B[i]=max(A[i-1],C[i-1])+b[i];
        C[i]=max(A[i-1],B[i-1])+c[i];
    }
    cout << max(A[N],max(B[N],C[N]));
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

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

int main() {

	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i < n+1; i++) {
		ans += i;
	}
	cout << ans <<endl;;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

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

    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n), rail(n);
    for(int i = 0; i < k; ++i){
        int p, q;
        cin >> p >> q;
        --p, --q;
        road.unite(p, q);
    }
    for(int i = 0; i < l; ++i){
        int r, s;
        cin >> r >> s;
        --r, --s;
        rail.unite(r, s);
    }
    map<P, int> mp;
    for(int i = 0; i < n; ++i)  ++mp[P(road.find(i), rail.find(i))];
    for(int i = 0; i < n; ++i){
        cout << mp[P(road.find(i), rail.find(i))];
        cout << ((i == n - 1) ? "\n" : " ");
    }
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
long double a[3001];
long double ans;
long double dp[3001][3001];
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i]; 
	}
	dp[0][0]=1.00;
	forn(i,1,n+1)
	rep(j,n+1)
	dp[i][j]=dp[i-1][j]*(1.00-a[i-1])+dp[i-1][j-1]*a[i-1];
	ans=0.00;
	for(int i=(n+1)/2;i<=n;i++)
	ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans;	
	re 0;
}

Measured memory_bytes: 140928
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
stack<char>cube;
char s[100005];
int main()
{
    int cnt=0;
    int i;
    scanf("%s",s);
    int len=strlen(s);
    for(i=0;i<=len-1;i++)
    {
        if(cube.empty()||cube.top()==s[i])cube.push(s[i]);//压栈
        else
        {
            cube.pop();//栈顶元素出栈
            cnt+=2;//成对出现
        }
    }
    printf("%d",cnt);
    return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int levenshtein_distance(string s1, string s2) {
	vector<vector<int> > dp(s1.size() + 1, vector<int>(s2.size() + 1));
	for(int i = 0; i <= s1.size(); i++) {
		for(int j = 0; j <= s2.size(); j++) {
			if(i == 0) dp[i][j] = j;
			else if(j == 0) dp[i][j] = i;
			else {
				dp[i][j] = min({dp[i][j - 1] + 1, dp[i - 1][j] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])});
			}
		}
	}
	return dp[s1.size()][s2.size()];
}
string s, t;
int main() {
	cin >> s >> t;
	cout << levenshtein_distance(s, t) << endl;
	return 0;
}

Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	int cnt=0;
	cin>>s;
	int maxv=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')cnt++;
		else cnt--;
		if(cnt>maxv)maxv=cnt;
	}
	cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=205,M=N*N<<1,inf=0x7fffffff;

int t[M],f[M],nxt[M],lst[N],l;

void add(int x,int y,int z) {
	t[++l]=y;f[l]=z;nxt[l]=lst[x];lst[x]=l;
	t[++l]=x;f[l]=0;nxt[l]=lst[y];lst[y]=l;
}

int n,m,a[N][N],b[N][N],c[N][N];
bool used[N][N];

int P(int x) {return (x-1)/m+1;}

int S,T,dis[N],q[N];

bool bfs() {
	fo(i,S,T) dis[i]=-1;dis[S]=0;
	int i=0,j=1;q[1]=S;
	while (i<j) 
		rep(k,q[++i])
			if (f[k]&&dis[t[k]]==-1) {
				dis[t[k]]=dis[q[i]]+1;
				q[++j]=t[k];
			}
	return dis[T]!=-1;
}

int dinic(int x,int y) {
	if (x==T) return y;
	int now=0;
	rep(i,x)
		if (f[i]&&dis[t[i]]==dis[x]+1) {
			int k=dinic(t[i],min(y,f[i]));
			y-=k;now+=k;f[i]-=k;f[i^1]+=k;
			if (!y) break;
		}
	if (!now) dis[x]=-1;
	return now;
}

int main() {
	n=read();m=read();
	fo(i,1,n) fo(j,1,m) a[i][j]=read();
	S=0;T=n<<1|1;
	fo(w,1,m) {
		l=1;fo(i,S,T) lst[i]=0;
		fo(i,1,n)
			fo(j,1,m)
				if (!used[i][j]) 
					add(i,n+P(a[i][j]),1);
		fo(i,1,n) add(S,i,1);
		fo(i,1,n) add(i+n,T,1);
		while (bfs()) dinic(S,inf);
		int p=2;
		fo(i,1,n)
			fo(j,1,m)
				if (!used[i][j]) {
					if (!f[p]) {
						used[i][j]=1;
						b[i][w]=a[i][j];
					}
					p+=2;
				}
	}
	fo(i,1,n) {
		fo(j,1,m) printf("%d ",b[i][j]);
		puts("");
	}
	fo(j,1,m) fo(i,1,n) c[P(b[i][j])][j]=b[i][j];
	fo(i,1,n) {
		fo(j,1,m) printf("%d ",c[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,v,j,Alice=0,Bob=0;
  cin >> N;
  vector<int>a(N);
  vector<int>A(0);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  for (int i=1;i<N;i++){
    v = a.at(i);
    j = i - 1;
    while (j >= 0 && a.at(j)>v){
      a.at(j+1) = a.at(j);
      j--;
    }
    a.at(j+1) = v;
  }
  while (a.size() > 0){
    Alice += a.at(a.size()-1);
    a.pop_back();
    if (a.size()==0){
      break;
    }
    Bob += a.at(a.size()-1);
    a.pop_back();
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "repetition"
 
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);

string s;
stack<char> q;

int main(){
	// freopen("input.txt", "r", stdin);
	cin >> s;
	for(int i = 0; i < sz(s); ++i){
		if(q.empty())
			q.push(s[i]);
		else{
			if(s[i] == 'S'){
				q.push(s[i]);
			}else{
				if(q.top() == 'S')
					q.pop();
				else
					q.push(s[i]);
			}
		}
	}
	printf("%d\n", (int)sz(q));
	return 0;
}

Measured memory_bytes: 644
p = [1] * (50000 + 1)
p[0], p[1] = 0, 0
for i in range(2, int(50000 ** 0.5) + 1):
    if not p[i]:
        continue
    for j in range(2 * i, 50000 + 1, i):
        p[j] = 0

p_num = [i for i in range(50000 + 1) if p[i] == 1]


while 1:
    n = int(input())
    if (n == 0):
        break
    cnt = 0
    for i in p_num:
        if n // 2 < i:
            break
        if p[n - i]:
            cnt += 1
    print(cnt)



Measured memory_bytes: 6216
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    char c;
    cin >> c;
    if((c == 'a')||(c == 'i')||(c == 'u')||(c == 'e')||(c == 'o'))cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,a="";
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B'){
      if(a.size()!=0)a.erase(a.size()-1);
    }
    else a+=s.at(i);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	static int yono = 0;
	static int[][] map;
	static char[][] q;
	static int h , w;
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		h = Integer.parseInt(sc.next());
		w = Integer.parseInt(sc.next());
		q = new char[h][w];
		map = new int[h][w];
		int point = 0;
		for(int i = 0 ; i < h ; i++){
			String ss = sc.next();
			for(int j = 0 ; j < w ; j++){
				q[i][j] = ss.charAt(j);
				if(q[i][j] == '.'){
					point++;
					map[i][j] = (int)Math.pow(10 , 5);
				}else{
					map[i][j] = -1;
				}
			}
		}
		sc.close();
		map[0][0] = 0;
		dfs(0 , 0 , map , 0);
		if(map[h - 1][w - 1] == Math.pow(10 , 5)) ou.println(-1);
		else ou.println(point - map[h - 1][w - 1] - 1);
		ou.flush();
	}
	static void dfs(int i , int j , int[][] ch , int where){
		yono++;
		if(i < 0 || i >= h || j < 0 || j >= w || ch[i][j] == -1 || q[i][j] == '#') return;
		if(where == 0) ch[0][0] = 0;
		if(where == 1) ch[i][j] = ch[i + 1][j] + 1;
		if(where == 2) ch[i][j] = ch[i - 1][j] + 1;
		if(where == 3) ch[i][j] = ch[i][j + 1] + 1;
		if(where == 4) ch[i][j] = ch[i][j - 1] + 1;
		if(i - 1 >= 0 && ch[i][j] + 1 < ch[i - 1][j]) dfs(i - 1 , j , ch , 1);
		if(i + 1 < h && ch[i][j] + 1 < ch[i + 1][j]) dfs(i + 1 , j , ch , 2);
		if(j - 1 >= 0 && ch[i][j] + 1 < ch[i][j - 1]) dfs(i , j - 1 , ch , 3);
		if(j + 1 < w && ch[i][j] + 1 < ch[i][j + 1]) dfs(i , j + 1 , ch , 4);
	}
}

Measured memory_bytes: 40960
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Fifty-Fifty
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[8];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  sort(s, s + 4);

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pi pair<int,int>
#define int long long
const int MOD= 1e9+7;
const int N=3e5+5;
int a[N];
int pre[N];
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<=n;i++)
    {
        if(i)
            pre[i]=pre[i-1]+a[i];
        else
            pre[i]=a[i];
    }
    int st=1;
    int cnt=1;
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        ans+=cnt;
        if(cnt<=0)
        {
            cout<<"-1"<<endl;
            return 0;
        }
        cnt-=a[i];
        cnt=min(cnt*2,pre[n]-pre[i]);

        


    }
    if(cnt!=0)
        ans=-1;
    cout<<ans<<endl;
    

    


    
    


}

Measured memory_bytes: 5152
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let S = buf_it.next().unwrap().chars().collect::<Vec<_>>();
    let N = S.len();

    let mut dp = (0..2).map(|_| (0..2019).map(|_| 0).collect::<Vec<_>>()).collect::<Vec<_>>();
    let mut ans = 0;

    for (i,&s) in S.iter().enumerate(){
        let s = s as usize - '0' as usize;
        let i = (i+1)%2;
        dp[i] = (0..2019).map(|_| 0).collect::<Vec<_>>();
        dp[i][s] += 1;
        for j in 0..2019{
            dp[i][(j*10+s)%2019] += dp[1-i][j];
        }
        ans += dp[i][0];
    }

    println!("{}",ans);

}


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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if (  a == 1 && b != 1  ){
    cout << "Alice" << endl;
  }else if ( a != 1 && b == 1 ){
    cout << "Bob" << endl;
  }else if ( a > b ){
    cout << "Alice" << endl;
  }else if ( a < b ){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
  
}



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

using namespace std;

int main()
{
  int A, B, K; cin >> A >> B >> K;

  if (B - A + 1 > 2 * K) {
    for (int i = A; i < A + K; ++i) cout << i << endl;
    for (int i = B - K + 1; i <= B; ++i) cout << i << endl;
  } else {
    for (int i = A; i <= B; ++i) cout << i << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[605][605];
int n,k;
int to[605];
bool ok[605][605];
int cnt[605][605];
ll v[605];
ll rec(int l,int r){
	if(!ok[l][r]) return dp[l][r] = 0;
	if(dp[l][r] >= 0) return dp[l][r];
	dp[l][r] = v[cnt[l][r]];
	for(int x=l+1;x<=r;x++){
		if(!ok[x][r]) continue;
		dp[l][r] -= rec(l,x-1)*v[cnt[x][r]]%mod;
	}
	return dp[l][r] = (dp[l][r]%mod+mod)%mod;
}
int main(){
	cin>>n>>k;
	rep(i,k){
		int a,b; cin>>a>>b;
		to[a] = b; to[b] = a;
	}
	for(int i=1;i<=2*n;i++) for(int j=i;j<=2*n;j++){
		for(int x=i;x<=j;x++){
			if(to[x] && !(i<=to[x] && to[x]<=j)) goto fail;
			if(!to[x]) cnt[i][j]++;
		}
		if(cnt[i][j]%2 == 0) ok[i][j] = 1;
		fail:;
	}
	for(int i=600;i>=0;i-=2){
		v[i] = 1;
		for(int j=i-1;j>=0;j-=2){
			v[i] = v[i]*1LL*j%mod;
		}
	}
	memset(dp,-1,sizeof(dp));
	ll ans = 0;
	for(int i=1;i<=2*n;i++) for(int j=i;j<=2*n;j++){
		ans += rec(i,j) * v[cnt[1][2*n]-cnt[i][j]] % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4864
a,b,c,d=map(int, input().split())

if b<=0 and d<=0:
    print(a*c)
elif a>=0 and c>=0:
    print(b*d)
elif b<=0 and c>=0:
    print(b*c)
elif a>=0 and d<=0:
    print(a*d)
else:
    if b*d>a*c:
        print(b*d)
    else:
        print(a*c)


Measured memory_bytes: 9176
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    int cnts[5];
    memset(cnts, 0, sizeof(cnts));
    for (int i = 0; i < 3; i++) {
        int u, v;
        cin >> u >> v;
        cnts[u]++;
        cnts[v]++;
    }

    int c1 = 0;
    int c2 = 0;
    for (int i = 1; i < 5; i++) {
        if (cnts[i] == 1) c1++;
        else if (cnts[i] == 2) c2++;
    }

    if (c1 == 2 && c2 == 2) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

ll f(ll x) {
    if (x%2 == 0) {
        return x/2;
    } else {
        return x*3+1;
    }
}

int main(void){
    ll cur;
    cin >> cur;
    map<ll, int> mp;
    mp[cur] = 1;
    int i = 1;
    while(true){
        i++;
        ll nxt = f(cur);
        if (mp[nxt]) {
            cout << i << endl;
            return 0;
        }
        mp[nxt] = i;
        cur = nxt;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    long i,j,t,a,b,n,c,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n;
       long arr[n];
       for(i=0;i<n;i++)cin>>arr[i];
       sort(arr,arr+n);
       cout<<arr[n-1]-arr[0];
        
    }
}

Measured memory_bytes: 256
#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);
    int n,m,k;
    cin >> n >> m >>k;
    rep(i,n+1){
        rep(j,m+1){
            if(i*(m-j)+j*(n-i)==k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
const int MAXN = 11111;
int dp[555][MAXN];
string name;
map<string, int> mp;
//dp[i][j] = max(dp[i - 1][j - 30]);
struct bit {
	int n, c[MAXN];
	void init(int _n) {
		n = _n;
		memset(c, 0, n * sizeof(int));
	}
	void update(int x, int y) {
		x+=2;
		while (x < n) {
			c[x] = max(c[x], y);
			x += x & -x;
		}
	}
	int get(int x) {
		x+=2;
		int ret = 0;
		while (x) {
			ret = max(ret, c[x]);
			x -= x & -x;
		}
		return ret;
	}
}b;

struct data {
	int id, time;
	bool over;
	friend bool operator <(const data& a, const data& b) {
		return a.time < b.time;
	}
}d[555];
int id[555], idx = 0;

bool notok(int a, int b) {
	if (d[a].time > d[b].time) {
		swap(a, b);
	}
	if (d[a].time + 30 > d[b].time) {
		return true;
	}
	return false;
}

int used[111112];

int main() {
	int n, m;
	string name;
	while (scanf("%d", &n) != EOF && n) {
		mp.clear();
		int week, hour;
		int maxv = 0;
		for (int i = 1; i <= n; i++) {
			cin >> name >> week >> hour;
			d[i].id = i - 1;
			d[i].over = false;
			d[i].time = week * 24 * 60 + ((hour / 100)) * 60 + ((hour % 100));
			maxv = max(maxv, d[i].time);
			//cout << d[i].time << endl;
			mp[name] = i;
		}
		scanf("%d", &m);
		getchar();
		idx = 0;
		for (int i = 0; i < m; i++) {
			getline(cin, name);
			d[mp[name]].over = true;
			id[idx++] = mp[name];
		}
		memset(used, 0, sizeof(used));
		bool die = false;
		int ans = 0;
		for (int i = 0; i < idx; i++) {
			for (int j = i + 1; j < idx; j++) {
				if (notok(id[i], id[j])) {
					die = true;
					break;
				}
			}
			//cout << id[i] << endl;
			for (int j = d[id[i]].time; j < d[id[i]].time + 30; j++) {
				used[j] = true;
			}
			ans++;
			if (die) break;
		}
		if (die) {
			puts("-1");
			continue;
		}
		sort(d + 1, d + n + 1);
		
		for (int i = 1; i <= n; i++) {
			bool flag = true;
			for (int j = d[i].time; j < d[i].time + 30; j++) {
				if (used[j]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				for (int j = d[i].time; j < d[i].time + 30; j++) {
					used[j] = true;
				}
				ans++;
				//cout << i << endl;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1824
#include<stdio.h>
long long abs(long long x){
	if(x<0ll) return -x;
	return x;
}
int main() {
	long long a,b,c,d,t;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&t);
	if(abs(c-a)<=t*(b-d)) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


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

    int ans = (1<<m)-1;
    vector<int> v(n);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            a--;
            v[i] |= 1<<a; 
        }
    }
    
    rep(i, n) {
        ans &= v[i];
    }
    
    int num = __builtin_popcount(ans);
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256