akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;

bool f[100005];
int  g[100005];
int main() {
	
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		g[i] = 1;

	f[1] = 1;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if (g[a]) {
			g[a]--;
			g[b]++;
			if (f[a])f[b] = 1;
			if (!g[a]) {
				f[a] = 0;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (f[i])ans++;
	}
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int n;

int main(void){
    // Your code here!
    string S, T;
    int dp[1001][1001];
    cin >> n;
    for(int c = 0; c < n; c++){
        cin >> S >> T;
        
        for(int i = 0; i <= S.size(); i++){
            dp[i][0] = 0;
        }
        for(int j = 0; j <= T.size(); j++){
            dp[0][j] = 0;
        }
        
        for(int i = 0; i < S.size(); i++){
            for(int j = 0; j < T.size(); j++){
                if(S[i]==T[j]) dp[i+1][j+1] = max({dp[i][j] + 1, dp[i][j+1], dp[i+1][j]});
                else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
        
        cout << dp[S.size()][T.size()] << endl;
    }
}



Measured memory_bytes: 7116
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    abs <- replicateM n $ do
        [a,b] <- getIntList
        return (a, b)
    let (as,bs) = unzip $ sort abs
    print . (as !!) . pred . length . takeWhile (<k) $ scanl' (+) 0 bs

Measured memory_bytes: 55676
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
A.sort()
c = Counter(A)

if c[1]==1:
    print(1)
elif c[1] > 1:
    print(0)
else:
    mx = 10**6+10
    ok = [True]*mx
    ans = 0
    for a in A:
        if ok[a]:
            if c[a] == 1:
                ans += 1
            for i in range(mx):
                if i*a >= mx:
                    break
                ok[i*a] = False
        else:
            continue
    print(ans) 

Measured memory_bytes: 133452
#include <stdio.h>

#define N 10000
int isPrime(int);

int main()
{
  int i,count=0,n,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    if(isPrime(k)==1)
      count++;
  }
  printf("%d\n",count);
  return 0;
}

int isPrime(int x){
  int i;
  if(x==2)
    return 1;
  else if(x<2 ||x%2==0)
    return 0;

  i = 3;

  while (i*i<=x){
    if(x%i==0)
      return 0;
    i = i+2;
  }
  return 1;
}
    



Measured memory_bytes: 2104
alice = list(input())#aca
bob = list(input())#accc
charlie = list(input())#ca

current = alice
while(len(alice) >= 0 and len(bob) >= 0 and len(charlie) >= 0):
  # if(len(current) == 0):
  #   if(current is alice):
  #     print('A')
  #     break
  #   elif(current is bob):
  #     print('B')
  #     break
  #   elif(current is charlie):
  #     print('C')
  #     break
  if(current[0] == 'a'):
    del current[0]
    current = alice
    if(len(current) == 0):
      print('A')
      break
  elif(current[0] == 'b'):
    del current[0]
    current = bob
    if(len(current) == 0):
      print('B')
      break
  elif(current[0] == 'c'):
    del current[0]
    current = charlie
    if(len(current) == 0):
      print('C')
      break

Measured memory_bytes: 9016
a = [[[0 for i in range(10)]for i in range(3)]for i in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    a[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        ans = ""
        for k in range(10):
            ans += " "
            ans += str(a[i][j][k])
        print(ans)
    if i != 3:
        print("####################")


Measured memory_bytes: 5608
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string N;
    cin >> N;
    for (int i = 0; i < N.length(); i++)
    {
        if (N[i] == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define lli long long int


using namespace std;

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

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

int main(){
    int H, W;
    cin >> H >> W;
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        cnt += count(s.begin(), s.end(), '#');
    }
    if (cnt == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

ld V(ll a,ll b,ld arg){
    if(tan(arg)<(ld)b/a){
        return a*a*b-a*a*a*tan(arg)/2.0;
    }else{
        return a*b*b/tan(arg)/2.0;
    }
}

int main(){
    ll a,b,x;
    ld pi=3.1415926535;
    cin>>a>>b>>x;
    ld ub=pi/2.0;
    ld lb=0.0;
    while(ub-lb>0.000000001){
        ld m=(ub+lb)/2;
        if(V(a,b,m)<x){
            ub=m;
        }else{
            lb=m;
        }
    }
    cout<<setprecision(10)<<lb*180/pi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

int dist[100][100];
const int INF = pow(10,9);


int main() {
  int n,m;
  cin >> n >> m;
  int a[m],b[m],c[m];
  FOR(i,0,n-1){
    FOR(j,0,n-1){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = INF;
    }
  }
  FOR(i,0,m-1){
    cin >> a[i] >> b[i] >> c[i];
    --a[i]; --b[i];
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  
  FOR(k,0,n-1){
    FOR(i,0,n-1){
      FOR(j,0,n-1){
        if(i==j) continue;
        if(i==k) continue;
        if(j==k) continue;
        if(dist[i][j]>dist[i][k]+dist[k][j]){
          dist[i][j] = dist[i][k]+dist[k][j];
        }
      }
    }
  }

  int ans = 0;

  FOR(i,0,m-1){
    bool ok = false;
    FOR(j,0,n-1){
      FOR(k,0,n-1){
        if(j==k) continue;

        if(dist[j][a[i]]+c[i]+dist[b[i]][k]==dist[j][k]) {
          ok = true;
        }
      }
    }
    if(!ok) ++ans;
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int a,b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
B=list(map(int,input().split()))
n=1
ans=[]
l=len(B)
while B:
    l=len(B)
    for i in range(len(B)):
        if B[::-1][i]==l:
            ans.append(l)
            del B[len(B)-1-i]
            break
        else:
            l-=1
    else:
        print(-1)
        exit()
print(*reversed(ans),sep="\n")

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

using namespace std;

int main()
{
    unsigned long long int a,b,x,cont,p,q;

    while(scanf("%llu%llu%llu",&a,&b,&x)==3){
        p=(a+x-1)/x;
        q=b/x;
        cont=q-p+1;
        printf("%llu\n",cont);
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N, P;
    P = 0;
    vector<int> V, C;
    cin >> N;
    for(int i = 0; i <= N - 1; i++){
        int t;
        cin >> t;
        V.push_back(t);
    }
    for(int i = 0; i <= N - 1; i++){
        int t;
        cin >> t;
        C.push_back(t);
    }
    for(int i = 0; i <= N - 1; i++){
        if(V[i] > C[i]){
            P += V[i] - C[i];
        }
    }
    cout << P;
    return 0;
};


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

int main(){
int x,y,a;
string g;
for( ; ; ){
cin>>x>>g>>y;
if(g=="+"){a=x+y;}
if(g=="-"){a=x-y;}
if(g=="*"){a=x*y;}
if(g=="/"){a=x/y;}
if(g=="?"){break;}
cout<<a<<endl;
}
return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10005];
int main()
{
    int n,m,sum=0;
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(sum>n)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d\n",n-sum);
    }
    return 0;
}


Measured memory_bytes: 3796
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


int n;
string s;
	
void solve() {
    cin>>n;
    cin>>s;
    int len=sz(s);
    
    int cw=0,cr=0;
    
    rep(i,0,len) {
		   if(s[i]=='W') cw++;
		   else cr++;
		}
	int ans=min(cr,cw);
	
	string p="";
	rep(i,0,cr)
	  p+='R'; 	 
    rep(i,0,cw)
	  p+='W';
	
	int ct=0;
	rep(i,0,len) {
		   if(s[i]!=p[i]) ct++;
 		}
 	ans=min(ans,ct/2);	
	cout<<ans<<endl; 
	  
 }

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


Measured memory_bytes: 3824
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int a[SIZE]={};
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int b;
		cin>>b;
		b++;
		a[b-1]++;
		a[b]++;
		a[b+1]++;
	}
	int maxi=0;
	for(int i=0;i<SIZE;i++){
		maxi=max(maxi,a[i]);
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 768
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }
#define INF (ll)1000000007

long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long pow_modp(long long a, long long n, long long p){
    // a^n mod p
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}

int main(void){

    int N;
    cin >> N;
    VI A(N);
    REP(i,N) cin >> A[i];
    SORT(A);

    ll ans = 0;
    bool flag = true;
    if(N%2 == 1){
        if(A[0] != 0) flag = false;
        else{
            for(int i=2; i<N; i+=2){
                if(A[i] == i && A[i-1] == i) continue;
                flag = false; break;
            }
        }
    }
    else{
        for(int i=1; i<N-1; i+=2){
            if(A[i] == i && A[i-1] == i) continue;
            flag = false; break;
        }
    }

    if(flag) ans = pow_modp(2, N/2, INF);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6

int main()
{
	int x,n;sca(x);sca(n);
	int vis[105];
	mem(vis);
	for(int i=0;i<n;i++)
	{
		int y;sca(y);
		vis[y]=1;
	}
	int flag=0,minn=inf;
	for(int i=0;i<=101;i++)
	{
		if(vis[i]==0)
		{
			if(abs(i-x)<minn)
			{
				minn=abs(i-x);
				flag=i;
			}
		}
	}
	cout<<flag<<endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C;
  cin >> A >> B >> C;
  string ans = "No";
  if(A + B + C == 2 * max({A, B, C})) ans = "Yes";
  cout << ans << endl;
}


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

class Program{


  static int Main() {

    int a = 0;
    string nyu = Console.ReadLine();

    for(int i = 0; i < nyu.Length-1; i++){
      if (nyu[i] != nyu[i+1]) a ++;
    }

    Console.WriteLine("{0}", a);

    return 0;
  }

}


Measured memory_bytes: 13280
#include <iostream>
using namespace std;
int main(void){
    int h,w,k;
    cin >> h >> w >> k;
    char grid[h][w];
    int nblack=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char t;
            cin >> t;
            if(t=='.'){ grid[i][j]=0; }
            if(t=='#'){ grid[i][j]=1; nblack++; }
        }
    }
    //cerr << nblack << endl;
    int counter=0;
    //2^12 = 4096
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int nmasked=0;
            // 6*6 = 36
            for(int y=0;y<h;y++){
                for(int x=0;x<w;x++){
                    if(((i & (1<<y)) || (j & (1<<x))) && grid[y][x]==1){
                        nmasked++;
                    }
                }
            }
            if(nblack-nmasked==k){
                //cerr << i << ", " << j << endl;
                counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

vector<string> split(string str, char del)
{
    int first = 0;
    int last = str.find_first_of(del);

    vector<string> result;

    while (first < str.size())
    {
        string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == string::npos)
        {
            last = str.size();
        }
    }

    return result;
}

void solve(long long K)
{
    string str =
      "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,"
      "15,2,2,5,4,1,4,1,51";
    char del = ',';

    int count = 0;
    for (const auto sub : split(str, del))
    {
        if (count + 1 == K)
            cout << sub << endl;
        count++;
    }
}
int main()
{
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  int m = 0, s_size = s.size();
  rep(i,s_size){
    int cnt = 0;
    for(int j = i; j < s_size; j++){
      if(s[j] == 'A'|| s[j]=='C'||s[j]=='G'||s[j]=='T')
        cnt++;
      else
        break;
    }
    if(m < cnt)
      m = cnt;
  }

  std::cout << m << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a * b == 15) cout << "*" << endl;
	else cout << "x" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
using P = pair<int, int>;

const int MOD = 1000000007;
int mod_pow(int n, int p, int MOD = 1000000007){
  int r = 1;
  for(; p > 0; p >>= 1){
    if(p & 1LL) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r; // r = n^p % MOD
}

signed main(){

  int n; cin >> n;
  map<P, int> mp;
  int zero = 0, azero = 0, bzero = 0;
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    if(a == 0 && b == 0){
      zero++;
    }else if(a == 0){
      azero++;
    }else if(b == 0){
      bzero++;
    }else{
      if(b < 0) a *= -1, b *= -1;
      int g = __gcd(abs(a), abs(b));
      mp[{a/g, b/g}]++;
    }
  }

  int ans = 1;
  for(auto &p : mp){
    int a = p.first.first, b = p.first.second;
    int t = mod_pow(2, p.second);
    a *= -1;
    if(a < 0) a *= -1, b *= -1;
    if(mp.find({b, a}) != mp.end()){
      t += mod_pow(2, mp[{b, a}]) - 1 % MOD;
      mp.erase({b, a});
    }
    ans = (ans * t) % MOD;
  }
  int t = (mod_pow(2, azero) + mod_pow(2, bzero) - 1) % MOD;
  ans = (ans * t) % MOD;
  ans = (ans + zero + MOD-1) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16028
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];

    sort(h.begin(),h.end(),greater<int>() );

    ll ans = 0;
    rep(i,n){
        if(k==0){
            ans += h[i];
        }else{
            k--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e3 + 100, MOD = 1e9 + 7;

int A, B, C[MAX_N][MAX_N], Sum[MAX_N][MAX_N];
void add(int &a, int b) {
	if((a+=b) >= MOD) a -= MOD;
	if(a < 0) a += MOD;
}
int Pow2[MAX_N];
int main() {
	cin >> A >> B;
	for(int i=0, j; i<MAX_N; i++) for(C[i][0]=1, j=1; j<=i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
	Pow2[0] = 1;
	for(int i=1; i<MAX_N; i++) Pow2[i] = Pow2[i-1] * 2 % MOD;
	for(int x=0; x<MAX_N; x++) {
		Sum[x][0] = 1;
		int sum = 1;
		for(int y=1; y<=x; y++) {
			add(sum, C[x][y]);
			Sum[x][y] = Sum[x][y-1];
			add(Sum[x][y], sum);
		}
	}

	int ans = 0;
	for(int pq=0; pq<=A; pq++) {
		for(int p=0, q=pq; p<=pq; p++, q--) {
			int fv = C[B-1][q];
			int sv = 1;
			if(q > 0) {
				sv = Sum[q-1][min(q-1, p)];
				add(sv, 1ll * max(0, p - (q-1)) * Pow2[q-1] % MOD);
			}
			add(ans, 1ll * fv * sv % MOD);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#define ll long long
const ll INF=1e9+7;

int n;
int p[1001];

int c(int i){
	int a=0,b=n;
	while (b>=i){
		b/=i;
		a+=b;
	}
	return a;
}

int main(){
	cin>>n;
	for (int i=2;i<=1000;i++)
		if (!p[i])
			for (int j=i+i;j<=1000;j+=i)
				p[j]=1;
	ll ans=1;
	for (int i=2;i<=n;i++)
		if (!p[i]){
			ans*=c(i)+1;
			ans%=INF;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
int a[200005];
int b[200005];

set <pair<int,int> >squ;

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		if(a[i]==b[i]) cnt++;else squ.insert(mp(-b[i],i));
	}
	ll res=0;
	while(cnt<n)
	{
		int x=squ.begin()->first;
		int id=squ.begin()->second;
		int pre=(id-1+n)%n;
		int nxt=(id+1)%n;
		squ.erase(mp(x,id));
		if(b[id]-b[pre]-b[nxt]<a[id]) over("-1");
		int k=(b[id]-(max(b[pre],b[nxt])+1))/(b[pre]+b[nxt])+1;
		k=min(k,(b[id]-a[id])/(b[pre]+b[nxt]));
		res+=k;
		b[id]-=k*(b[pre]+b[nxt]);
		if(b[id]==a[id]) cnt++;else	squ.insert(mp(-b[id],id));
//		for(int i=0;i<n;i++)
//		{
//			cout<<b[i]<<' ';
//		}
//		cout<<endl;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 13184
dp = [[0]*3 for i in range(3)]
L = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
L = [a,b,c]
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

flag = 0 

for i in range(3):
    for j in range(3):
        if L[i][j] in l:
            dp[i][j] = 1
# dp = [[1,1,0],[0,1,0],[1,0,1]]
for i in range(3):
    if sum(dp[i]) ==3:
        flag = 1

for j in range(3):
    s = 0
    for i in range(3):
        s+= dp[i][j]
    if s == 3:
        flag = 1
s = 0
t = 0
for i in range(3):
    s+=  dp[i][i]
    t+= dp[i][2-i]
if s==3 or t == 3:
    flag = 1
    
if flag:
    print('Yes')
else:
    print('No')
# print(dp)

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

int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;++i){
        cin>>l[i];
    }
    sort(l.begin(), l.end());
    ll sum=0;
    for(ll i=0;i<n-1;++i){
        sum+=l[i];
    }
    if(sum>l[n-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int main(void)
{
    char str[10005];
    while (scanf("%s", str) != EOF){
        int len = (int)strlen(str);
        
        int ioi = 0, joi = 0;
        
        for (int i = 0; i < len; i++){
            if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
                joi++;
                i++;
            }
            if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
                ioi++;
                i++;
            } 
        }
        
        printf("%d\n", joi);
        printf("%d\n", ioi);
    }
    
    return (0);
}

Measured memory_bytes: 0
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 
 
inline void solve(){ 
    int a,b,ans=0; cin>>a>>b; 
    if (a<b) { 
        if (a<0 and b>0 and abs(a)<=b) ans = b+a+1; 
        else if (a<0 and b>0 and abs(a)>=b) ans = abs(a)-b+1; 
        else {ans = b-a; }
    } 
    if (a>b) { 
        if (a>0 and b>0) ans = a-b+2;
        else if (a<0) ans = (abs(b)-abs(a)) + 2 ; 
        else { 
            if (abs(b)>=a) 
                ans = abs(b)-a+1; 
            else 
                ans = a+b+1; 
        } 
    } 
    cout << ans << endl; 
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
  ll H, A;
  

  scanf("%lld%lld", &H, &A);

  
    printf("%lld\n", (H+A-1)/A);
  
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] T = new int[n];
        int ans = 0;
        Arrays.setAll(T, i -> Integer.parseInt(sc.next()));
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) ans += T[i] * T[j];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26836
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define INF 1L << 50

signed main() {
  int d, g;
  cin >> d >> g;
  int p[d], c[d];
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = INF;
  for (int bit = 0; bit < (1 << d); bit++) {
    int problem = 0;
    int point = 0;
    for (int i = 0; i < d; i++) {
      if ((bit >> i) & 1) {
        problem += p[i];
        point += (1 + i) * 100 * p[i] + c[i];
      }
    }
    if (point >= g) {
      ans = min(ans, problem);
      continue;
    }
    for (int i = 0; i < d; i++) {
      if ((bit >> i) & 1) continue;
      if ((g - point) / ((i + 1) * 100) <= p[i]) {
        problem += (g - point) / ((i + 1) * 100);
        ans = min(ans, problem);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);


        int N = scanner.nextInt();
        int K = scanner.nextInt();

        HashMap<Integer, Integer> hashMap = new HashMap<>();

        for(int i=0; i<N; i++){
            int tmp = scanner.nextInt();
            if(hashMap.containsKey(tmp)){
                int cur = hashMap.get(tmp);
                cur++;
                hashMap.put(tmp, cur);
            }else{
                hashMap.put(tmp, 1);
            }
        }

        ArrayList<Integer> arrayList = new ArrayList<>();
        for(int key: hashMap.keySet()){
            arrayList.add(hashMap.get(key));
        }

        Collections.sort(arrayList);

        int delete = arrayList.size() - K;

        if(delete <= 0){
            System.out.println(0);
            return;
        }

        int cnt = 0;

        for(int i=0; i<delete; i++){
            cnt += arrayList.get(i);
        }

        System.out.println(cnt);

    }
}


Measured memory_bytes: 100640
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main(){
	int n;cin>>n;
	cout<<(n+1)/2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	setvbuf(stdout,NULL,_IONBF,0);

	int n,m,l,i,j,k;
	scanf("%d %d %d",&n,&m,&l);
	long int num1[n][m];
	long int num2[m][l];
	long int num3[n][l];

	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			num1[i][j] = 0;
		}
	}
	for(i = 0;i < m;i++){
		for(j = 0;j < l;j++){
			num2[i][j] = 0;
		}
	}
	for(i = 0;i < n;i++){
		for(j = 0;j < l;j++){
			num3[i][j] = 0;
		}
	}
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%ld",&num1[i][j]);
		}
	}
	for(i = 0;i < m;i++){
		for(j = 0;j < l;j++){
			scanf("%ld",&num2[i][j]);
		}
	}
	for(i = 0;i < n;i++){
		for(j = 0;j < l;j++){
			for(k = 0;k < m;k++){
				num3[i][j] += num1[i][k] * num2[k][j];
			}
		}
	}
	for(i = 0;i < n;i++){
		for(j = 0;j < l - 1;j++){
			printf("%ld ",num3[i][j]);
		}
		printf("%ld\n",num3[i][j]);
	}

	return 0;
}

Measured memory_bytes: 836
#include<bits/stdc++.h>
const int md = 1e9+7;
long long n, a = 1, b, c;

int main(){
	scanf("%lld", &n);
	for(int i = 60; i >= 0; i--){
		((c *= 3) += b*(1+(n>>i&1))) %= md;
		(n>>i&1 ? b:a) = (b+a) % md;
	}
	printf("%lld\n", (a+b+c)%md);
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=rd();
	for(int i=1;i<=9;++i) {
		if(i*111>=n) {
			printf("%d\n",i*111);
			break;
		}
	}
	return 0;
}


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

int main() {
  int64_t N,A=1;
  cin>>N;
  vector<int64_t> B(N);
  for(int64_t &i:B){
    cin>>i;
    if(i==0){
      cout<<0<<endl;
      return 0;
    }
  }
  for(int64_t &j:B){
    if(1000000000000000000<j*A || 1000000000000000000/A<j){
      cout<<-1<<endl;
      return 0;
    }
    A*=j;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int n, k, ans = 0; scanf("%d\n", &n);
  std::map<int, int> dt;
  REP(_, n){scanf("%d", &k); dt[k]++;}
  for(auto ele :dt){
    if(ele.first <= ele.second) ans += ele.second - ele.first;
    else ans += ele.second;
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(){
  int n,k;
  cin>> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++){ cin>> h[i];}
  sort(h.begin(),h.end()); reverse(h.begin(),h.end());
  
  int64_t ans=0;
  for(int i=k; i<n; i++) ans+=h[i];
  cout<< ans <<endl;
}

Measured memory_bytes: 4052
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
char s[1000010];
int to[1000010][26], par[1000010], f[1000010], c;
int b[200010];
vector<string> v;
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		string a(s);
		v.push_back(a);
		reverse(a.begin(), a.end());
		int r = 0;
		for (int j = 0; j < a.size(); j++) {
			int t = a[j] - 'a';
			if (!to[r][t]) {
				to[r][t] = ++c;
				par[c] = r;
			}
			r = to[r][t];
		}
		b[i] = r;
		f[r]++;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int r = par[b[i]], x = 1 << (v[i][0] - 'a');
		for (int j = 1; j < v[i].size(); j++) {
			x |= 1 << (v[i][j] - 'a');
			r = par[r];
			for (int k = 0; k < 26; k++) {
				if ((x >> k & 1) && f[to[r][k]]) ans++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 112776
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

vector<int> split(string delim,string str){
	vector<int> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				//cout << str.substr(i,j) << endl;
				int num;
				sscanf(str.substr(i,j-1).c_str(),"%d",&num);
				if(str.substr(i,j-1).size() > 0 ) res.push_back(num);
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){
	string str;

	vector<vector<int> > table;

	while(getline(cin,str)){
		vector<int> tmp = split(",",str);
		table.push_back(tmp);
	}


	for(int i=0;i+1<table.size();i++){
		if(table[i].size() < table[i+1].size()){
			for(int j=0;j<table[i+1].size();j++){
				if(j==0){
					table[i+1][j]=table[i][j] + table[i+1][j];
				}
				else if(j==table[i+1].size()-1){
					table[i+1][j]=table[i][j-1] + table[i+1][j];
				}
				else{
					table[i+1][j]=max(table[i][j-1]+table[i+1][j],table[i][j]+table[i+1][j]);
				}			
			}
		}
		else{
			for(int j=0;j<table[i+1].size();j++){
				table[i+1][j]=max(table[i][j]+table[i+1][j],table[i][j+1]+table[i+1][j]);
			}
		}
	}

	cout << table[table.size()-1][0] << endl;
}

Measured memory_bytes: 0
def solver():
    N = int(input())
    h = list(map(int, input().split()))
    dp = [0 for _ in range(N)]
    for i in range(1,N):
        if(i==1):
            dp[i] = dp[i-1]+abs(h[i]-h[i-1])
        else:
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[N-1])
solver()

Measured memory_bytes: 13976
#include <stdio.h>
#include <vector>
#include <queue>
struct str{
	int x0;
	int cost;
	int time;
};
std::vector<str> V[60];
struct str2{
	int x0;
	int coin;
	long long int dist;
};
bool operator<(str2 a, str2 b)
{
	return a.dist>b.dist;
}
std::priority_queue<str2> Q;
std::pair<int,int> x[60];
long long int check[60][3000];

long long int MAX = 1;
int main()
{
	for(int i=1;i<=15;i++) MAX*=10;
	
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=b;i++)
	{
		int d,e,f,g;
		scanf("%d%d%d%d",&d,&e,&f,&g);
		V[d].push_back({e,f,g});
		V[e].push_back({d,f,g});
	}
	for(int i=1;i<=a;i++)
	{
		int d,e;
		scanf("%d%d",&d,&e);
		x[i]=std::make_pair(d,e);
	}
	
	if(c>2500) c = 2500;
	Q.push({1,c,1});
	while(!Q.empty())
	{
		int x0 = Q.top().x0;
		int coin = Q.top().coin;
		long long int dist = Q.top().dist;
		Q.pop();
		
		if(check[x0][coin]) continue;
		check[x0][coin] = dist;
		
		if(coin+x[x0].first <= 2500) Q.push({x0,coin+x[x0].first,dist+x[x0].second});
		for(int i=0;i<V[x0].size();i++) if(V[x0][i].cost<=coin) Q.push({V[x0][i].x0,coin-V[x0][i].cost,dist+V[x0][i].time});
	}
	
	for(int i=2;i<=a;i++)
	{
		long long int ans = MAX;
		for(int j=0;j<=2500;j++)
		{
			if(check[i][j]>0) ans = ans<check[i][j]?ans:check[i][j];
		}
		printf("%lld\n",ans-1);
	}
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
// 貪欲法
int main() {
    int N;
    cin >> N;
    i64 last = 0;
    int pm = 0;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        i64 A;
        cin >> A;
        if(pm == 0) {
            if(last == 0) last = A;
            else {
                pm = last == A ? 0 : (last < A ? 1 : -1);
                last = A;
            }
        } else if(pm == 1) {
            if(last > A) {
                ans++;
                pm = 0;
            }
        } else if(pm == -1) {
            if(last < A) {
                ans++;
                pm = 0;
            }
        }
        last = A;
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;    
     
class sample10{    
    static void Main(string[] args){    
        int[] sort_number = new int[2]; 
     
        for(int case_number = 0; case_number < 3000; case_number++){  
                string[] str_number = Console.ReadLine().Split(' '); 
                
                for(int i = 0 ; i < 2; i++){
                    sort_number[i] = int.Parse(str_number[i]);
                    
                }
                
                Array.Sort(sort_number);
                
                if(sort_number[0] < 0 || sort_number[0] > 10000 || sort_number[1] < 0 || sort_number[1] > 10000){ 
                    Console.WriteLine("xは1以上10000以下の数字で入力してください。"); 
                    Environment.Exit(0);    
                }else if( sort_number[0] == 0 && sort_number[1] == 0){ 
                    break; 
                } 
                Console.WriteLine("{0} {1}",sort_number[0],sort_number[1]);    
        }   
    }    
}   


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

int main() {
	long a,b,c,d;
	cin >> a >> b >> c >> d;
	vector<long> v;
	if((0 >= a && 0 <= b) || (0 >= c && 0 <= d)) {
		v.push_back(0);
	}
	v.push_back(a*c); v.push_back(a*d);
	v.push_back(b*c); v.push_back(b*d);
	cout << *max_element(v.begin(),v.end());
	return 0;
}

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

int main()
{
    int N, M;
    string S;
    cin >> N >> M >> S;
    vector<int> nex(N + 1);
    for(int i = N;i >= 0;i--){
        if(S[i] == '0'){
            nex[i] = i;
        }
        else{
            nex[i] = nex[i + 1];
        }
    }
    int idx = N;
    bool ng = false;
    vector<int> res;
    while(idx > 0){
        int to = nex[max(0, idx - M)];
        if(to == idx){
            ng = true;
            break;
        }
        res.push_back(idx - to);
        idx = to;
    }
    if(ng){
        cout << -1 << endl;
        return 0;
    }
    reverse(res.begin(), res.end());
    for(int i = 0;i < (int)res.size();i++){
        cout << res[i] << " \n"[i + 1 == (int)res.size()];
    }
    return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
#define MAXN 100001
typedef pair<int,int> P;
int main(){
    cin >> N;
    vector<P> VP(N);
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        VP[i] = P(A,i+1);
    }
    sort(VP.begin(),VP.end());
    for(int i=0;i<N;i++){
        cout << VP[i].second <<" ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	int a[N];
	int b[N];
	vector<int>c;
	int n, x, y;
	f(i, N)b[i] = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &a[i]);
	}
	for (int i = n - 1; i >= 0; i--) {
		x = 2 * i + 1;
		y = 0;
		while (x < n) {
			y = (y + b[x]) % 2;
			x += (i + 1);
		}
		if (y != a[i])b[i] = 1;
}
	f(i, n)if (b[i] == 1)c.push_back(i + 1);
	printf("%d\n", c.size());
	f(i, c.size()) {
		printf("%d", c[i]);
		if (i < c.size() - 1)printf(" ");
		else printf("\n");
	}

	return 0;
}

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

int N;
int A[210];

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    int res = 0;

    //操作が行える限り操作を繰り返す
   while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

Measured memory_bytes: 256
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ret = 0
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
    ret += min(T,diff)
print(ret+T)


Measured memory_bytes: 25200