akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

bool sol(string& str1, string& str2){
    if(str1 == str2.substr(0,str1.size()))
        return true;
    return false;
}

int main(){
    string str1, str2;
    cin >> str1 >> str2;
    cout << (sol(str1,str2) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll p[111];


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


  ll a, b;
  cin >> n;
  cin >> a >> b;
  rep(i, n) cin >> p[i];
  ll x = 0, y = 0, z = 0;
  rep(i, n) {
    if (p[i] <= a) x++;
    else if (p[i] > a&& p[i] <= b) y++;
    else z++;
  }

  cout << min(x, min(y, z)) << endl;


  return 0;
}

Measured memory_bytes: 256
range = xrange
input = raw_input
MOD = 10**9+7
 
n = int(input())

dp = [0] * (1 << n)
for i in [i for i, x in enumerate(input().split()) if x == '1']:
    dp[1 << i] = 1

npow = 1 << n

for i in range(n - 1):
    _dp = [0] * npow
    for j in [i for i, x in enumerate(input().split()) if x == '1']:
        jpow = 1 << j
        mask = 0
        while mask < npow:
            _dp[mask + jpow] += dp[mask]
            mask += 1 + ((mask+1) & jpow)
    for mask in range(npow):
        _dp[mask] %= MOD
    dp = _dp
 
print(sum(dp) % MOD)

Measured memory_bytes: 196572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (U == S)
    --A;
  else
    --B;
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 768
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
-- end of templete

modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f


main = do
    [m, n] <- replicateM 2 getInt
    arr <- newArray (1,m) [] :: IO (IOArray Int [Int])
    replicateM_ n $ do
        [a, b] <- getInts
        modifyArray arr a (b:)
    stack <- newIORef []
    forM_ [1..m] $ \i -> do
        c <- null <$> readArray arr i
        when c $ do
            modifyIORef stack (i:)
    result <- newIORef []
    replicateM_ m $ do
        x <- head <$> readIORef stack
        modifyIORef stack tail
        modifyIORef result (x:)
        forM_ [1..m] $ \i -> do
            c <- elem x <$> readArray arr i
            when c $ do
                modifyArray arr i $ delete x
                d <- null <$> readArray arr i
                when d $ modifyIORef stack (i:)
    readIORef result >>= mapM_ print
    return ()

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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int> > change(10, vector<int>(10, 0));
    vector<vector<int> > lis(h, vector<int>(w, 0));
    for(int i = 0; i <= 9; i++){
        for(int l = 0; l <= 9; l++){
            cin >> change[i][l];
        }
    }
    for (int k = 0; k < 10; k++){
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                change[i][j] = min(change[i][j], change[i][k] + change[k][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int l = 0; l < w; l++){
            int a; cin >> a;
            if(a == 1 || a == -1){
                continue;
            }else{
                ans += change[a][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
	int H,W;
	cin>>H>>W;
	int mat[H][W][3];

	rep(i,H){
		rep(j,W){
			char tmp;
			cin>>tmp;
			if(tmp == '.')mat[i][j][1]=1;
			else mat[i][j][1]=0;
		}
	}


	int ans=0;
	rep(i,H){
		rep(j,W){
			mat[i][j][2]=0;
			mat[i][j][3]=0;
			if(mat[i][j][1] == 0)mat[i][j][2] = 0;
			else if(i-1 > -1 && mat[i-1][j][1] == 1)mat[i][j][2] = mat[i-1][j][2];
			else{
				mat[i][j][2]=1;
				for(int k=i+1;k<H;k++){
					if(mat[k][j][1] == 0)break;
					mat[i][j][2]++;
				}
			}
			if(mat[i][j][1] == 0)mat[i][j][3] = 0;
			else if(j-1 > -1 && mat[i][j-1][1] == 1)mat[i][j][3] = mat[i][j-1][3];
			else{
				mat[i][j][3]=1;
				for(int k=j+1;k<W;k++){
					if(mat[i][k][1] == 0)break;
					mat[i][j][3]++;
				}	
			}
			if(ans < mat[i][j][2]+mat[i][j][3])ans = mat[i][j][2]+mat[i][j][3];
		}
	}
	////////debug////////////
	/*rep(i,H){
		rep(j,W)cout<<mat[i][j][1];
		cout<<endl;
	}
	/////////////////////////
	////////debug////////////
	rep(i,H){
		rep(j,W)cout<<mat[i][j][2]<<"|";
		cout<<endl;
	}
	/////////////////////////
		////////debug////////////
	rep(i,H){
		rep(j,W)cout<<mat[i][j][3]<<"|";
		cout<<endl;
	}
	/////////////////////////*/
	cout<<ans-1<<endl;
	return 0;
}


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

int dp[50001], coin[21];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        cin >>coin[i];
    }
    for (int i = 1; i <= n; ++i)dp[i] = 1 << 29;
    dp[0] = 0;
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 0; j + coin[i] <= n; ++j)
        {
            dp[j + coin[i]] = min(dp[j +coin[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	double l;
	cin>>l;
	
	l/=3;
	double ans=l*l*l;
	
	printf("%.10f\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() 
{
// your code goes here

int counts[30]={0};

char cs[1201];
while(scanf("%[^\n]\n",cs)!=EOF){
	for(int i=0;cs[i]!='\0';i++){
		if(isalpha(cs[i])){
			counts[tolower(cs[i])-'a']++;
		}
	}
}

for(char c='a';c<='z';c++){
	printf("%c : %d\n",c,counts[c-'a']);
}
return 0;
}


Measured memory_bytes: 3188
#include <iostream>




using namespace std;

int main() {

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


    for(int i = 0; i < M; i++){
        N -= a[i];
    }

    if(N >= 0) {
        cout << N << endl;
    } else {
        cout << -1 << endl;
    }
    
}

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

int main(){
  vector<int> xt(5);
    rep(i,5){
  cin >> xt.at(i);
  }

  int rt = 1;
 
  rep(i,5){
  if(xt.at(i) == 0){
  rt = rt + i;
  }
  }
 
cout << rt << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	long long t,n,s=0;
	cin>>n;
	t=n;
	while(n>0){
		s+=n%10;
		n/=10;
	}
	if(t%s==0)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] ar){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a>b&&b>c)
            System.out.println(c+" "+b+" "+a);
        if(a<b&&b<c||a==b&&a<c||a<b&&b==c)
            System.out.println(a+" "+b+" "+c);
        if(c>a&&a>b||a>b&&a==c)
            System.out.println(b+" "+a+" "+c);
        if(b>a&&a>c||a==b&&a>c)
            System.out.println(c+" "+a+" "+b);
        if(b>c&&c>a||a<b&&a==c)
            System.out.println(a+" "+c+" "+b);
        if(a>c&&c>b||a>b&&b==c)
            System.out.println(b+" "+c+" "+a);
        if(a==b&&b==c)
            System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26400
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
int arr[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    while(cin>>n) {
        for(int i=1;i<=n;i++)cin>>arr[i];
        sort(arr+1,arr+1+n);
        int num=n-(int)(unique(arr+1,arr+1+n)-arr-1);
        //cout<<num<<endl;
        int ans=num/2*2;
        if(num&1)ans+=2;
        ans=n-ans;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
from collections import deque
N, Q = map(int, input().split())
brunch = [[] for _ in range(N)]
value = [0 for _ in range(N)]

for _ in range(N-1):
  a, b = map(int, input().split())
  brunch[a-1].append(b-1)
  brunch[b-1].append(a-1)
  
for _ in range(Q):
  f, val = map(int, input().split())
  value[f-1] += val

d = deque()
d.append((0, -1))
while len(d):
  root, from_root = d.popleft()
  for to in brunch[root]:
    if to == from_root:
      continue
    value[to] += value[root]
    d.append((to, root))
print(' '.join(map(str, value)))

Measured memory_bytes: 65668
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


void dfs(ll n,vector<bool> &check,vector<vector<ll>> &fri){
    check[n]=1;
for(ll i=0;i<fri[n].size();i++){
    if(!check[fri[n][i]])
    dfs(fri[n][i],check,fri)
;}
return;
}

int main(){
    ll N;
    cin >> N;   
    ll M;
    cin >> M;
    
vector<bool> check(N+1,0);
vector<vector<ll>> fri(N+1, vector<ll>(0));
    vector<ll> X(M,0);
    vector<ll> Y(M,0);
    vector<ll> Z(M,0);
    for(ll i=0;i<M;i++){
        cin>>X[i]>>Y[i]>>Z[i]
    ;}
    for(ll i=0;i<M;i++){
        fri[X[i]].emplace_back(Y[i]);
        fri[Y[i]].emplace_back(X[i]);
    ;}
    
    ll counter=0;
    for(ll i=1;i<N+1;i++){
        if(!check[i]){counter++;
        dfs(i,check,fri);}
    ;}
    ll ccounter=0;
    for(ll i=1;i<N+1;i++){
        if(!check[i]){
            ccounter++;
        }
    ;}

    cout<<ccounter+counter<<endl;


return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N, K;
    cin >> N >> K;

    cout << (N - 1 + K - 2) / (K - 1) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t) puts("Yes");
  else puts("No");

  return 0;
}


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

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

	size_t cg = std::count(s.begin(), s.end(), 'g');
	size_t cp = s.length() - cg;

	std::cout << (cp + cg) / 2 - cp << std::endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  ll c=10;
  for(ll i=1;i<7;i++){
    if(a<c){
      b=i;
      break;
    }
    c=c*10;
  }
  
  ll d=0;
  if(b==1){
    d=a;
  }
  else{
    ll e=9;
    for(ll i=1;i<=b-1;){
      d+=e;
      e=e*100;
      i=i+2;
    }
    if(b%2==1){
      d+=a-c/10+1;
    }
  }
  cout<<d<<endl;
  return 0;
}
  
    
  


Measured memory_bytes: 3536
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

x = [0] * (N + 1)
for i in range(N):
    x[i + 1] = x[i] + A[i]
    
y = [0] * (M + 1)
for i in range(M):
    y[i + 1] = y[i] + B[i]

ans = 0
for i in range(N + 1):
    res = K - x[i]
    if res > 0:
        j = bisect_right(y, res)
        j -= 1
    elif res == 0:
        j = 0
    else:
        continue

    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 111000
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    import numpy as np
    A = [list(map(int,readline().split())) for _ in range(3)]
    N, *b = map(int, read().split())
    A = np.array(A)
    B = np.zeros(A.shape)
    for i in A.reshape(-1):
        if i in b:
            B[np.where(A == i)] = 1
    for i in range(3):
        if np.all(B[i, :] == 1):
            print('Yes')
            break
        if np.all(B[:, i] == 1):
            print('Yes')
            break
    else:
        if B[0,0]==B[1,1]==B[2,2]==1:
            print('Yes')
        elif B[0,2]==B[1,1]==B[2,0]==1:
            print('Yes')
        else:
            print('No')
    return
if __name__ == '__main__':
    main()



Measured memory_bytes: 12232
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int gcd(int n,int m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

int N,A[100010];
int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    sort(A+1,A+N+1);
    int g = A[2];
    for(int i=3;i<=N;i++) g = gcd(g,A[i]);
    map<int,int> m,m2;
    int n = A[1];
    for(int i=2;i*i<=A[1];i++){
        while(n%i==0){
            n /= i;
            m[i]++;
        }
    }
    if(n!=1) m[n]++;
    int good = 1;
    for(auto x:m){
        bool judge = true;
        int num = -1;
        for(int i=2;i<=N;i++){
            if(A[i]%x.first!=0){
                if(num==-1) num = A[i];
                else if(num!=A[i]){
                    judge = false;
                    break;
                }
            }
        }
        if(judge){
            if(num==-1) good *= x.first;
            else if(!m2.count(num)) m2[num] = x.first;
            else m2[num] *= x.first;
        }
    }
    int ans = g;
    for(auto x:m2) ans = max(ans,good*x.second);
    cout << ans << endl;
}

Measured memory_bytes: 640
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
     int n, k;
     string s;
     cin >> n >> s >> k;
     if(k > n)
     {
         cout << s;
         return 0;
         }
    for(int i = 0;i<n;i++)
    {
        if(s[i] == s[k-1])
        cout << s[i];
        else
        cout << "*";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const int M = 42;
int main()
{
  int n,k;cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];
  vector<ll> v;
  rep(i,n){
    for(int j = i+1;j <= n;++j){
      v.push_back(sum[j] - sum[i]);
    }
  }
  ll res = 0;
  vector<ll> pow2(M+1);
  pow2[0] = 1;
  rep(i,M) pow2[i+1] = pow2[i] * 2;
  for(int i = M;i >= 0;--i){
    // rep(j,v.size()) cout << v[j] << " ";
    // cout << "\n";
    int cnt = 0;
    rep(j,v.size()){
      if( ( v[j] >> i ) & 1 ) cnt++;
    }
    if(cnt >= k){
      res += pow2[i];
      vector<ll> tmp;
      rep(j,v.size()){
	if( ( v[j] >> i ) & 1 ) tmp.push_back(v[j]);
      }
      v = tmp;
    }
  }
  cout << res << "\n";
  
  return 0;
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
    std::ios_base::sync_with_stdio(0);

    u32 m1, d1, m2, d2;
    std::cin >> m1 >> d1 >> m2 >> d2;

    if (m1 != m2)
        std::cout << "1";
    else
        std::cout << "0";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,d1[101],d2[101],d3[101],d4[101],d5[101],sum[101],max=0,min=500,i;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d%d%d%d%d",&d1[i],&d2[i],&d3[i],&d4[i],&d5[i]);
	sum[i]=d1[i]+d2[i]+d3[i]+d4[i]+d5[i];
      if(max<sum[i]){
	max=sum[i];
      }
       if(min>sum[i]){
	min=sum[i];
      }
    }
    printf("%d %d\n",max,min);
    max=0;
    min=500;
  }
  return 0;
}

Measured memory_bytes: 600
def main(n: int, a: list):
    t = [0 for _ in range(n)]

    for i in a:
        t[i - 1] += 1

    print("\n".join(map(str, t)))


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 33516
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int q;
		double x0, y0, x1, y1, x2, y2, x3, y3;
		
		q = scan.nextInt();
		
		for(int i = 0; i < q; i++) {
			x0 = scan.nextDouble();
			y0 = scan.nextDouble();
			x1 = scan.nextDouble();
			y1 = scan.nextDouble();
			x2 = scan.nextDouble();
			y2 = scan.nextDouble();
			x3 = scan.nextDouble();
			y3 = scan.nextDouble();
			
			if(y0 == y1) {
				if(y2 == y3) {
					System.out.println(2);
					
				} else if(x2 == x3) {
					System.out.println(1);
					
				} else {
					System.out.println(0);
					
				}
			} else if(x0 == x1) {
				if(x2 == x3) {
					System.out.println(2);
					
				} else if(y2 == y3) {
					System.out.println(1);
					
				} else {
					System.out.println(0);
					
				}
			} else {				
				if(((y1 - y0) / (x1 - x0)) == ((y3 - y2) / (x3 - x2))) {
					System.out.println(2);
					
				} else if(((y1 - y0) / (x1 - x0) * (y3 - y2) / (x3 - x2)) == -1) {
					System.out.println(1);
					
				} else {
					System.out.println(0);
					
				}
			}
		}
		
		scan.close();
	}
}

Measured memory_bytes: 57336
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 1e5+1;

vector<int> adj[N];
int vis[N];
int dp[N];
int n, u, v;

// int dp[N][N];

int dfs(int u){

    if(vis[u] == 1){
        return dp[u];
    }
    vis[u] = 1;
    for(int v: adj[u]){
        dp[u] = max(dp[u], dfs(v)+1);
    }
    return dp[u];
}

void solve(){
    
    int m;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> u >> v;
        adj[u].push_back(v);
    }
    for(int i=1; i<=n; i++){
        if(vis[i] == 0){
            dfs(i);
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, dp[i]);
        // cout << dp[i] << " ";
    }
    // cout << endl;
    cout << ans;

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 12596
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl



const int MAX_ROW = 310; // to be set appropriately
const int MAX_COL = 310; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

ostream& operator << (ostream& s, BitMatrix A) {
    s << endl; 
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << endl;
    }
    return s;
}

inline BitMatrix operator * (BitMatrix A, BitMatrix B) {
    BitMatrix R(A.H, B.W);
    BitMatrix tB(B.W, B.H);
    for (int i = 0; i < tB.H; ++i) for (int j = 0; j < tB.W; ++j) tB[i][j] = B[j][i];
    for (int i = 0; i < R.H; ++i) for (int j = 0; j < R.W; ++j) R[i][j] = ((A[i] & tB[j]).count() & 1);
    return R;
}

inline BitMatrix pow(BitMatrix A, long long n) {
    BitMatrix R(A.H, A.H);
    for (int i = 0; i < A.H; ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}




int main() {
    int N; cin >> N;
    BitMatrix A(N, N);
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j) {
            int a; cin >> a;
            A[i][j] = a;
        }
    vector<int> v(N), res;
    for (int i = 0; i < N; ++i) cin >> v[i];
    long long T; cin >> T;

    BitMatrix P = pow(A, T);
    int rank = linear_equation(P, v, res);
    int jiyudo = N - rank;

    if (rank == -1) puts("none");
    else if (jiyudo > 0) puts("ambiguous");
    else {
        for (int i = 0; i < N; ++i) {
            cout << res[i];
            if (i != N-1) cout << " ";
        }
        cout << endl;
    }
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;
  if(x % y == 0)
    cout << -1 << endl;
  else {
    while(true) {
      if( x%y != 0) {
        cout << x << endl;
        break;
      }
      x+= x;
    }
  }
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
count = 0
for x in range(N+1):
    i = 10000 * x
    for y in range(N-x+1):
        j = 5000 * y
        if((Y-i-j)/1000+x+y == N and i+j+(N-x-y)*1000 == Y):
            count = 1
            z = N - x - y
            f_x=x
            f_y=y
            f_z=z
                
if(count == 1):
    print(str(f_x)+" "+str(f_y)+" "+str(f_z))
if(count == 0):
    print("-1 -1 -1")
    

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    cin >> a;
    int s = accumulate(a.begin(), a.end(), 0);
    int tot = 0;
    for(int x : a) {
        tot += 4 * m * x >= s;
    }
    cout << (tot >= m ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S.at(0)!=S.at(1) && S.at(1)!=S.at(2) && S.at(2)!=S.at(0)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d" @@ fun a b ->
  Printf.printf "%d\n" @@ List.length @@
    List.filter (fun s ->
      s = String.init (String.length s) (fun i -> s.[String.length s - 1 - i])) @@ Array.to_list @@ Array.init (b - a + 1) @@ fun i -> string_of_int @@ i + a

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int bit[60] = {};
    for(int i = 0;i < n;i++)
    {
        long long int a;
        cin >> a;
        int j = 0;
        while(a > 0)
        {
            if(a % 2 == 1)
            {
                bit[j]++;
            }
            a /= 2;
            j++;
        }
    }
    long long int ans = 0;
    long long int p =1;
    for(int i = 0;i < 60;i++)
    {
        ans = (ans + ((((bit[i] * (n - bit[i]))%MOD)*p)%MOD))%MOD;
        p = p*2 %MOD;
    }
    cout << ans;
    
    return 0;
}

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

typedef long long int ll;

int main()
{
    ll n, asum = 0;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
        if(i != 0){
            b[i] = b[i - 1];
        }
        b[i] += a[i];
        asum += a[i];
    }
    for(ll i = n - 1;i >= 0;i--){
        if(i != n - 1){
            c[i] += c[i + 1];
        }
        c[i] += a[i];
    }

    ll ans = 0, min = abs(b[0] - c[1]);
    for(ll i = 1;i < n;i++){
        if(abs(b[i - 1] - c[i]) < min){
            min = abs(b[i - 1] - c[i]);
        }
    }

    cout << min;

    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
static const int N = 36;

int isStable(char [N][3],char [N][3]);
int n;

int main(){
  int i,j,a,b,stable[2];
  char A[N][3];
  char B[N][3];
  char C[N][3];
  char swap[3];
  int minj;

  scanf("%d",&n); /*Input an integer n, the number of elements in sequence*/

  for(i=0;i<n;i++){
    scanf("%s",A[i]);/* Input N elements of the sequence*/
  }
  for(i=0;i<n;i++){
    strcpy(B[i],A[i]);
    strcpy(C[i],A[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(B[j][1]<B[j-1][1]){
	strcpy(swap,B[j]);
        strcpy(B[j],B[j-1]);
        strcpy(B[j-1],swap);
      }
     }
    }
  for(i=0;i<n;i++){
      if(i<n-1) printf("%s ",B[i]);/*Output the sorted sequence*/
      else printf("%s\n",B[i]);
    }
  
  stable[0]=isStable(A,B);
  if(stable[0]==1) printf("Not stable\n");
  else printf("Stable\n");

  for(i=0;i<n;i++){
      minj = i;
     for(j=i;j<n;j++){
       if(C[j][1]<C[minj][1])
	minj = j;
     }
     if(i!=minj){
        strcpy(swap,C[i]);
        strcpy(C[i],C[minj]);
        strcpy(C[minj],swap);
       }
      }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%s ",C[i]);/*Output the sorted sequence*/
      else printf("%s\n",C[i]);
    }
     stable[1]=isStable(A,C);
     if(stable[1]==1) printf("Not stable\n");
     else printf("Stable\n");

    return 0;
   } 

int isStable(char in[N][3], char out[N][3]){
  int i,j,a,b;
   for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if((in[i][1]== in[j][1]) && (strcmp(in[i],out[b])==0)&& (strcmp(in[j],out[a])==0)) return 1;
          
	}
       }
      }
     }
      return 0;
}

Measured memory_bytes: 624
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 9;
const int INF = 1 << 29;

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int x = 0; x <= N; x++) {
    int res = Y - 10000 * x;
    if (res < 0) break;
    for (int y = 0; y <= N - x; y++) {
      res = Y - 10000 * x - 5000 * y;
      if (res < 0) break;
      if (res == (1000 * (N - x - y))) {
        cout << x << ' ' << y << ' ' << (N - x - y) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(j = 2; j <= n; j++){
    key = A[j];
    i = j - 1;
    while(i > 0 && A[i] > key){
      A[i+1] = A[i];
      i = i - 1;
    }
    A[i+1] = key;
    trace(A, n);
  }
    return 0;
}

Measured memory_bytes: 608
import sys
sys.setrecursionlimit(1000000)
n=input()
graph=[[] for i in range(n+1)]
for i in range(n-1):
    v,u=list(map(int,raw_input().split()))
    graph[v].append(u)
    graph[u].append(v)

dist= [-1 for i in range(n+1)]
dist[1]=0
son=[[] for i in range(n+1)]
queue=[1]
father=[0 for i in range(n+1)]
def bfs(u):
    for v in graph[u]:
        if dist[v]==-1:
            dist[v]=dist[u]+1
            son[u].append(v)
            father[v]=u
            queue.append(v)
    queue.pop(0)
    if len(queue)!=0:
        bfs(queue[0])

bfs(1)
road=[n]
tempfather=n
for i in range(dist[n]):
    road.append(father[tempfather])
    tempfather=father[tempfather]

di=len(road)
k=road[(di-2)/2]

def countson(u):
  count=0
  if len(son[u])==0:return 1
  for v in son[u]:
      count+=countson(v)
  return count+1

cs=countson(k)
cf=n-cs

if cs>=cf:print 'Snuke'
else:
    print 'Fennec'


Measured memory_bytes: 117756
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

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

    int ans = 0;
    bool ok = false;
    for(int i = 1; i < n.size(); i++){
        if(n[i]-'0' != 9) ok =true;
    }
    if(n.size() == 1){
        ans = n[0]-'0';
    }else if(ok){
        ans = (n.size()-1) * 9 + (n[0] - '0')-1;
    }else{
        ans = (n.size()-1) * 9 + (n[0] - '0');
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n = [int(x) for x in input()]
k=len(n)-1
for i in range(2**k):
    op=["-"]*(k)
    for j in range(k):
        if ((i>>j)&1):
            op[k-1-j]="+"
    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (str(p_n) + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

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

int main() {
    int k;
    cin >> k;
    vector<int> a(k);
    int ans = 1;
    int amari = 7%k;
    while (1) {
        if (amari == 0) {
            cout << ans << endl;
            return 0;
        }
        if (a[amari] == 1) {
            cout << -1 << endl;
            return 0;
        }
        a[amari] = 1;
        amari *= 10;
        amari += 7; 
        amari %= k;
        ans++;
    }


    return 0;
}

Measured memory_bytes: 7204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC144_a solver = new ABC144_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC144_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            if ((A > 9) || (A < 1)) {
                out.println("-1");

                return;

            }
            if ((B > 9) || (B < 1)) {
                out.println("-1");

                return;

            }
            out.println(A * B);

        }

    }
}



Measured memory_bytes: 21844
# https://atcoder.jp/contests/abc168/tasks/abc168_a

N = int(input())

last_num = int(str(N)[-1])

if last_num in {2, 4, 5, 7, 9}:
    print('hon')

elif last_num in {0, 1, 6, 8}:
    print('pon')

else:
    print('bon')

Measured memory_bytes: 9160
# B - YYMM or MMYY

s = str(input()) # 長さ４の数字列

def check(n):
    if n > 0 and n <= 12:
        return True
    else:
        return False

mae = check(int(s[0:2]))
ato = check(int(s[2:4]))

if mae and ato:
    print('AMBIGUOUS')
elif mae and not ato:
    print('MMYY')
elif not mae and ato:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
//JAI SAI RAM.//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll P=1000000007;
int main()
{
    ll i,j,k,l,m,n,o,p,q,r,s,t,a,b,c;
    
    cin>>m>>n;
    if(m==1||n==1)
    {
        cout<<1<<endl;
        return 0;
    }
    t=(m*n)/2;
    if(m%2==1&&n%2==1)
    {
        t++;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    long double a,b;
    cin>>a>>b;
    cout<<(ll)trunc(a*b);
}


Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <tuple>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}



int main(void){
	int n, k;
	cin >> n >> k;

	k--;

	string s;
	cin >> s;

	for (int i = 0; i < n; i++){
		if (i == k){
			if (s[i] == 'A'){
				s[i] = 'a';
			}
			else if (s[i] == 'B'){
				s[i] = 'b';
			}
			else if (s[i] == 'C'){
				s[i] = 'c';
			}
		}
	}

	cout << s << endl;
}


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

Measured memory_bytes: 768
from collections import Counter
n = int(input())
*v, = map(int, input().split())
v_even, v_odd = v[::2], v[1::2]
even = Counter(v_even).most_common(2)
odd = Counter(v_odd).most_common(2)

ans = 0

if even[0][0] != odd[0][0]:
    ans = n - odd[0][1] - even[0][1]

else:
    if len(even) == 1 and len(odd) == 1:
        ans = n // 2
        
    elif len(even) == 1:
        ans = n - even[0][1] - odd[1][1]
        
    elif len(odd) == 1:
        ans = n - even[1][1] - odd[0][1]
        
    else:
        ans = min(n - even[0][1] - odd[1][1], 
                  n - even[1][1] - odd[0][1])
                  
print(ans)

Measured memory_bytes: 15972
using System;
using System.Collections.Generic;


namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            string[] str2 = Console.ReadLine().Split(' ');

            long total = 0;
            int min = int.Parse(str2[0]);
            int max = int.Parse(str2[0]);

            for (int i = 0; i < n; i++)
            {
               
                int num = int.Parse(str2[i]);
                total = total + num;
                if (max < num)
                {
                    max = num;
                }
                if (min > num)
                {
                    min = num;
                }
            }

            Console.WriteLine("{0} {1} {2}",min,max,total);
        }

    }
}

Measured memory_bytes: 9864
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const long long mod=1000000007;
int n;
char s[2][55];
long long dp[55];

int main()
{
    scanf("%d%s%s",&n,s[0],s[1]);
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(s[0][0]==s[1][0])dp[0]=3;
            else
            {
                dp[0]=dp[1]=6;
                i++;
            }
        }
        else
        {
            if(s[0][i-1]==s[1][i-1])
            {
                if(s[0][i]==s[1][i]){dp[i]=dp[i-1]*2;dp[i]%=mod;}
                else
                {
                    i++;
                    dp[i]=dp[i-2]*2;
                    dp[i]%=mod;
                }
            }
            else
            {
                if(s[0][i]==s[1][i]) dp[i]=dp[i-1];
                else
                {
                    i++;
                    dp[i]=dp[i-2]*3;
                    dp[i]%=mod;
                }
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    before = set()
    for _ in range(N):
        s,t = input().split()
        if s == 'insert':
            before.add(t)
        else:
            if t in before:
                print('yes')
            else:
                print('no')
if __name__ == '__main__':
    main()


Measured memory_bytes: 30996
from collections import defaultdict
d = defaultdict(int)

n,x,m= map(int, input().split())
ans=0
v=[]
cnt=x
for i in range(m+10):
    if cnt==0 or i==n:
        print(ans)
        exit()

    elif d[cnt]==0:
        v.append(cnt)
        ans += cnt
        d[cnt]=i
        cnt = pow(cnt, 2, m)
    else:
        # 周期の始まり
        y=d[cnt]
        break
u=0
for i in range(y,len(v)):
    u+=v[i]
l=len(v)-y
xx=(n-len(v))//l
yy=(n-len(v))%l
ans+=xx*u+sum(v[y:y+yy])
print(ans)

Measured memory_bytes: 77352
# abs(a-k)==abs(b-k)
# a-k+b-k=0 or a-k-b+k=0
# a!=bから左
# a+b==2k

a,b=map(int,input().split())

c=a+b

if c%2==1:
  print("IMPOSSIBLE")
else:
  print(c//2)

Measured memory_bytes: 9152
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e10
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 13,M=1005;
ll n,m;
vi a(M);
vi dp(1<<N,-1);
vvi b(M,vi ());
ll tot_mask;
ll fun(ll mask)
{
	if(mask == tot_mask) return  dp[mask] = 0;

	if(dp[mask]!=-1) return dp[mask];

	ll ans = inf;
	rep(i,0,m)
	{
		ll new_mask  = mask;
		rep(j,0,sz(b[i])) new_mask|=(1<<b[i][j]);
		if(mask!=new_mask)	ans=min(ans,fun(new_mask)+a[i]);
		// cout<<new_mask<<"\n";
	}
	return dp[mask] = ans;
}


int solve()
{
	cin>>n>>m;
	tot_mask = (1<<n)-1;
	rep(i,0,m)
	{
		ll k;
		cin>>a[i]>>k;
		b[i].assign(k,0);
		rep(j,0,k) cin>>b[i][j];
		rep(j,0,k) b[i][j]--;
		// ,open[b[i][j]]=1;
		// rep(j,0,k) cout<<b[i][j]<<" ";
		// cout<<"\n";
	}
	// rep(i,0,n) if(open[i]==0) {cout<<"-1\n"; return 0;}
	ll ans = fun(0);
	if(ans>=inf) ans=-1;
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 512
def main():
  num = int(input())
  result = []
  for i in range(num):
    result.append(input())
  print(f'AC x {result.count("AC")}')
  print(f'WA x {result.count("WA")}')
  print(f'TLE x {result.count("TLE")}')
  print(f'RE x {result.count("RE")}')
  return

main()

Measured memory_bytes: 16288
#include <iostream>

using namespace std;
using LL = long long;

int main() {

    int N;
    cin >> N;

    LL A[N + 1];
    fill(A, A + N + 1, 0);

    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        A[i] = A[i - 1] + a;
    }

    LL min_ = INT64_MAX;

    for (int i = 1; i < N; i++) {
        min_ = min(min_, abs(A[N] - A[i] * 2));
    }

    cout << min_ << endl;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int d;
    cin >> d;
    ll tols = 0;
    vector<int> c(26), lastc(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<int> u(26);
    vector<vector<int>> s(d);
    rep(i, d) {
        rep(j, 26) {
            cin >> u[j];
        }
        s[i] = u;
    }
    vector<int> t(d);
    rep(i, d) {
        cin >> t[i];
        t[i]--;
    }

    rep(i, d) {
        lastc[t[i]] = i + 1;
        tols += s[i][t[i]];
        rep(j, 26) {
            if(j == t[i]) continue;
            tols -= c[j] * (i - lastc[j] + 1);
        }
        cout << tols << endl;
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(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;
}


Measured memory_bytes: 3676
#include <stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if (a >= b && a >= c)
  {
    printf("%d",(a+b+c) - a);
  }
  else if (b >= a && b >= c)
  {
    printf("%d",(a+b+c) - b);
  }
  else if (c >= b && a <= c)
  {
    printf("%d",(a+b+c) - c);
  }
}

Measured memory_bytes: 128
using System;

namespace B___I_miss_you
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            for (var i = 0; i < s.Length; i++)
            {
                Console.Write ("x");
                if (i == s.Length - 1)
                    Console.WriteLine ();
            }
        }
    }
}

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

bool used[100000];
vector<int> G[100000];
bool flag;

void dfs(int v,int prev){
	used[v] = true;
	if(G[v].size() >= 3) flag = false;
	for(int to : G[v]){
		if(to == prev) continue;
		if(used[to]) flag = false;
		else dfs(to,v);
	}
}

int main(){
	int n,m;
	while(cin >> n >> m,n){
		flag = true;
		for(int i = 0;i < m;i++){
			int a,b;
			cin >> a >> b; a--;b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		for(int i = 0;i < n;i++){
			if(!used[i]) dfs(i,-1);
		}
		if(flag) cout << "yes" << endl;
		else cout << "no" << endl;
		for(int i = 0;i < n;i++){
			G[i].clear();
			used[i] = false;
		}
	}
}

Measured memory_bytes: 8808