akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 1;
    int cnt = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]){
            ans *= a[i];
            cnt++;
            i++;
            if(cnt == 2){
                cout << ans << endl;
                return 0;
            }
        }
    }  
    cout << 0 << endl;
    return 0;  
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  ll a,b;
  cin >> a >> b;
  int ans = 0;
  if(b == 1){
    cout << 0 << endl;
    return 0;
  }
  while(1){
    b -= a;
    ans++;
    if(b<=0)break;
    else b++;
  }
  cout << ans << endl;
}

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

int main() {
    int n, k; cin >> n >> k;
    
    double sum_t = 0.0, sum = 0.0;
    for (int i = 1; i <= n; i++) {
        double tmp = 1.0 / n;
        int tmp_i = i;
        double tmp_d = 1.0;
        while (tmp_i < k) {
            tmp_d *= 0.5;
            tmp_i *= 2;
             //printf("tmp_i=%d, tmp_d= %f\n", tmp_i, tmp_d);
        }
        //printf("tmp=%f, tmp_d= %f\n", tmp, tmp_d);
        sum += tmp * tmp_d;
    }
    printf("%.12f\n", sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  SORT(a);
  ll ans = 0;
  vector<bool> check(1e6 + 100);
  rep(i, 1e6 + 100) check[i] = true;
  if(N == 1 and a[0] == 1){
    ans = 1;
  }
  if(a[0] == 1){
    if(N > 1 and a[1] > 1){
      ans = 1;
    }
  }
  else{
    rep(i,N){
      ll tmp = a[i];
      if(check[tmp]){
        ans++;
        if(i < N - 1 and(a[i] == a[i + 1])){
          ans--;
        }
      }
      while(tmp < 1e6 + 100){
        check[tmp] = false;
        tmp += a[i];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<long long,long long> P;
const int inf=400000000;
const long long infl=1ll<<60;

int N,V;
int xs[3030],ts[3030],ps[3030];
int xle,xri;

struct Mole:P{
	int cost;
	Mole(){}
	Mole(P p,int x):P(p),cost(x){}
};

vector<Mole> vec;

struct BIT{
	int N;
	int dat[3030];
	void init(int N_){
		N=N_;
		for(int i=0;i<=N;i++) dat[i]=-inf;
	}
	void update(int id,int val){
		id++;
		while(id<=N){
			dat[id]=max(dat[id],val);
			id+=(id&(-id));
		}
	}
	int get(int id){
		id++;
		int res=0;
		while(id>0){
			res=max(res,dat[id]);
			id-=(id&(-id));
		}
		return res;
	}
	int get(){
		return get(N-1);
	}
};

BIT bit[2][3030];

int dp[3030][3030];
int nxtTable[3030][3030];

vector<long long> valx,valy;

int main(){
	scanf("%d%d",&N,&V);
	scanf("%d%d",&xle,&xri);
	for(int i=0;i<N;i++){
		scanf("%d%d%d",xs+i,ts+i,ps+i);
		long long t=(long long)ts[i]*V;
		long long x=xs[i];
		//(t-x,t+x)
		vec.push_back(Mole(P(t-x,-(t+x)),ps[i]));
		valx.push_back(t-x);
		valy.push_back(t+x);
	}
	vec.push_back(Mole(P(-xle,-xle),inf));
	vec.push_back(Mole(P(-xri,-xri),inf));
	valx.push_back(-xle);
	valy.push_back(xle);
	valx.push_back(-xri);
	valy.push_back(xri);
	valx.push_back(-infl);
	valy.push_back(-infl);
	sort(valx.begin(),valx.end());
	valx.erase(unique(valx.begin(),valx.end()),valx.end());
	sort(valy.begin(),valy.end());
	valy.erase(unique(valy.begin(),valy.end()),valy.end());
	for(int i=0;i<vec.size();i++) vec[i].second*=-1;
	sort(vec.begin(),vec.end());
	N=vec.size()+1;
	for(int i=0;i<N;i++){
		for(int j=0;j<2;j++){
			bit[j][i].init(N);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<2;j++){
			bit[j][i].update(0,0);
		}
	}
	//printf("sz=%d\n",vec.size());
	for(int i=0;i<vec.size();i++){
		long long x=vec[i].first;
		long long y=vec[i].second;
		int c=vec[i].cost;
		//printf("(%lld %lld %d)\n",x,y,c);
		int cx=distance(valx.begin(),lower_bound(valx.begin(),valx.end(),x));
		int cy=distance(valy.begin(),lower_bound(valy.begin(),valy.end(),y));
		for(int l=0;l<N;l++){
		//	if(l==cy) continue;
		//	int tmp=bit[0][l].get(cy-1);
			int tmp=bit[0][l].get(cy);
			tmp+=c;
			nxtTable[l][cy]=tmp;
		//	printf("[%d][%d]=%lld\n",l,cy,tmp);
		}
		for(int r=0;r<N;r++){
		//	if(r==cy) continue;
		//	int tmp=bit[1][r].get(cy-1);
			int tmp=bit[1][r].get(cy);
			tmp+=c;
			if(r==cy) nxtTable[cy][r]=max(nxtTable[cy][r],tmp);
			else nxtTable[cy][r]=tmp;
		//	printf("[%d][%d]=%lld\n",cy,r,tmp);
		}
		for(int l=0;l<N;l++){
		//	if(l==cy) continue;
		//	if(i==1) 
			bit[0][l].update(cy,nxtTable[l][cy]);
			bit[1][cy].update(l,nxtTable[l][cy]);
		}
		for(int r=0;r<N;r++){
		//	if(r==cy) continue;
			bit[1][r].update(cy,nxtTable[cy][r]);
			bit[0][cy].update(r,nxtTable[cy][r]);
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		ans=max(ans,bit[0][i].get());
		ans=max(ans,bit[1][i].get());
	}
	ans-=inf*2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 109756
import sys
d=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
for n in iter(d,'0\n'):
 a=[1];s='123456'
 for _ in[0]*int(n):
  s=[s[e]for e in p[d()[0]]]
  a+=[s[0]]
 print(sum(map(int,a)))


Measured memory_bytes: 5716
#include <stdio.h>
#include <string.h>

int main( void ) {
	char str[ 21 ];
	int i;

	scanf( "%s", str );
	
	for ( i = strlen( str ) - 1; i >= 0; i-- )
		putchar( str[ i ] );
	putchar( '\n' );

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <sstream>
#include <iomanip>

int main(){
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    int v[11][11] = {0};
    std::cin.get();
    for(int i=0;i<n;i++){
      std::string s;
      getline(std::cin,s);
      std::stringstream ss(s);
      int num;
      for(int j=0;j<n;j++){
      ss>>num;
      v[j][i]=num;
      v[n][i]+=num;
      v[j][n]+=num;
      v[n][n]+=num;
      }
    }

    for(int y=0;y<=n;y++){
      for(int x=0;x<=n;x++){
        std::cout<<std::right<<std::setw(5)<<v[x][y];
      }
      std::cout<<std::endl;
    }
  }
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	res := "Yes"
	if a == b && b == c {
		res = "No"
	} else if a != b && b != c && c != a {
		res = "No"
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    ll ans = 0;
    for(int i = 28; i >= 0; i--)
    {
        ll tmp = 1 << i;
        for(int j = 0; j < n; j++)
        {
            b[j] &= tmp*2 - 1;
        }
        sort(b.begin(), b.end());
        ll digit = 0;
        for(int j = 0; j < n; j++)
        {
            a[j] &= tmp*2 - 1;
            digit += lower_bound(b.begin(), b.end(), 2*tmp - a[j]) - lower_bound(b.begin(), b.end(), tmp-a[j]);
            digit += lower_bound(b.begin(), b.end(), 4*tmp - a[j]) - lower_bound(b.begin(), b.end(), 3*tmp-a[j]);
        }
        if(digit % 2 == 1)
        {
            ans += tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  string s;cin>>s;
  int ans=700;
  rep(i,3)if(s[i]=='o')ans+=100;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (ll i = 2; i*i < g; i++) {
    if (g%i == 0) {
      ans++;
      while (g%i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a,b = 0,0
cards = [int(val) for val in input().split()]
 
cards = sorted(cards, reverse=True)
 
for i in range(n):
    if i % 2 == 0:
        a += cards[i]
    else:
        b += cards[i]
        
print(a - b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   long long int i,j;
 
   
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
   cin>>n>>m;
   for(i=0;i<=n;i++)
   {
       if((i*4)+(n-i)*2==m)
       {cout<<"Yes";
       break;}
   }
   if(i>n)
   cout<<"No";
   
 return 0;
}


Measured memory_bytes: 3676
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * v_num
    queue = deque()
    queue.appendleft(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            # adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(_edges):
    for edge in _edges:
        source, target, cp = map(int, edge)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(v_num)]
    adj_table = generate_adj_table(edges)
    ans = graphFordFulkerson(source=0, sink=v_num - 1)
    print(ans)

Measured memory_bytes: 8176
N = int(input())
A = list(map(int, input().split()))

B = [0 for _ in range(N)]

for i, a in enumerate(A[::-1]):
    i = N - i
    v = B[i-1]
    for j in range(i*2, N+1, i):
        v ^= B[j-1]
    if v != a:
        B[i-1] ^= 1

M = len([b for b in B if b == 1])
print(M)
for i, b in enumerate(B):
    if b == 1:
        print(i+1)


Measured memory_bytes: 72284
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.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)
-- end of templete

addSum s = s ++ [sum s]

show' s = let t = show s in replicate (mod (-length t) 5) ' ' ++ t


main = do
    n <- getInt
    when (n/=0) $ do
        a <- replicateM n getInts
        mapM_ putStrLn $ map (concat . map show') . transpose . map addSum . transpose . map addSum $ a
        main

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int s;
    cin >> s;
    vector<ll> dp(s+1);
    dp[0] = 1;
    ll x = 0;
    rep(i,s+1)
    {
        if(i - 3 >= 0){
            x += dp[i-3];
            x %= MOD;
        }
        dp[i] += x;
        dp[i] %= MOD;
    }
    cout << dp[s] % MOD << endl;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll a, b;

int main () {
    fastIO;
    cin >> a >> b;
    cout << 6 - a - b;
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cin.get();

    string str;
    getline(cin, str);

    auto valid = str[a] == '-';
    for (int i = 0; i < a; i += 1) {
        if (!isdigit(str[i])) {
            valid = false;
        }
    }
    for (int i = 0; i < b; i += 1) {
        if (!isdigit(str[a + 1 + i])) {
            valid = false;
        }
    }

    cout << (valid ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_120
{
    class A
    {
        static void Main(string[] args)
        {

            int[] n = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int A = n[0], B = n[1], C = n[2];
            int z = B / A; if (z > C) z = C;
            Console.WriteLine(z);
        }

    }
}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    long n,a,b;
    cin>>n>>a>>b;

    cout<<min(n*a,b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {

        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	string S;
	cin >> S;

	ll N = S.size();

	vector<ll> dp1(N + 1, -1);
	vector<ll> dp2(N + 1, -1);

	dp1[0] = 0;
	dp2[0] = 0;
	dp1[1] = 1;

	for (ll i = 2; i <= N; i++) {
		if (S[i - 2] != S[i - 1] && dp1[i - 1] != -1) {
			dp1[i] = dp1[i - 1] + 1;
		}
		if (dp2[i - 1] != -1) {
			dp1[i] = max(dp1[i],dp2[i - 1] + 1);
		}

		if (dp1[i - 2] != -1) {
			dp2[i] = dp1[i - 2] + 1;
		}

		if (dp2[i - 2] != -1) {
			if (i < 4 || S[i - 4] != S[i - 2] || S[i - 3] != S[i - 1]) {
				dp2[i] = max(dp2[i], dp2[i - 2] + 1);
			}
		}
	}

	cout << max(dp1[N], dp2[N]);
	
	system("PAUSE");

}





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

using namespace std;
typedef long long ll;


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

    int m = L[0];
    int sum = L[0];
    for (int i = 1; i < N; ++i) {
        if ( m < max(m, L[i])) m = max(m, L[i]);
        sum += L[i];
    }

    if (sum - m > m) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 3e6 + 5 , MOD = 1e9 + 7;
int fact[N] , invfact[N];

int mul(int a , int b , int m = MOD){
   return (1LL * (a % m) * (b % m)) % m;
}

//int add(int a , int b , int m = MOD){
//   return (1LL * (a % m) + (b % m)) % m;
//}

int powMOD(int x , int n , int m = MOD){
   if(!n)return 1;
   int ret = 1;
   if(n & 1)ret = mul(x , powMOD(x , n - 1 , m) , m);
   else{
      int y = powMOD(x , n / 2 , m);
      ret = mul(y , y , m);
   }
   return ret;
}
int nCr(int n , int r){
   if(r < 0 || r > n)return 0;
   return mul(mul(fact[n] , invfact[r] , MOD) , invfact[n - r] , MOD);
}

void pre(){
   fact[0] = invfact[0] = 1;
   for(int i = 1 ; i < N ; ++i)
      fact[i] = mul(i % MOD , fact[i - 1] , MOD);

   invfact[N - 1] = powMOD(fact[N - 1] , MOD - 2 , MOD);
   for(int i = N - 2; ~i ; --i)
      invfact[i] = mul(invfact[i + 1] , (i + 1) % MOD , MOD);
}


int add(int a , int b){
   a += b;
   while(a >= MOD) a -= MOD;
   while(a < 0)a += MOD;
   return a;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   pre();
   int r1 , c1 , r2 , c2;
   cin >> r1 >> c1 >> r2 >> c2;

   int ans = 0;
   for(int r = r1 ; r <= r2 ; ++r){
      ans = add(ans , add(nCr(c2 + r + 1 , r + 1) , -nCr(c1 + r , r + 1)));
   }
   cout << ans << "\n";
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#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())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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 mod = int(1e+9) + 7;


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

  vector<int> l(n);
  rep(i, n) {
    cin >> l[i];
  }

  sort(ALL(l));

  auto itr = l.rbegin();
  int ans = 0;
  rep(i, k) {
    ans += *itr;
    itr++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122_1
{
    class Program
    {
        static void Main(string[] args)
        {
            
                string b = Console.ReadLine();
                if (b == "A")
                {
                    Console.WriteLine("T");
                }
                else if (b == "T")
                {
                    Console.WriteLine("A");
                }
                else if (b == "C")
                {
                    Console.WriteLine("G");
                }
                else if (b == "G")
                {
                    Console.WriteLine("C");
                }
                //else
                //{
                //    Console.WriteLine("塩基ではありません");
                //}
                // Console.WriteLine(b);
            
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>

#define PI 3.1415927

using namespace std;


long long fun(long long n){
    if (n==2){
        return 1;
    }
    else{
        int p=1;
        for (int i=2;i<=sqrt(n);i++){
            if (n%i==0){
                p=i;
            }
        }
        return p;
    }
}

int main(){
    long long n;
    cin>>n;
    if (n==1){
        cout<<1<<endl;
        return 0;
    }
    int k=0,u=0;
    long long q;
    long long l=fun(n);

    if (l==1){
        while(n){
            n/=10;
            k++;
        }
        cout<<k<<endl;
    }
    else{
        k=0;
        u=0;
        q=n/l;
        while(q){
            q/=10;
            k++;
        }
        while(l){
            l/=10;
            u++;
        }
        int r = max(u,k);
        cout<<r<<endl;
    }
}


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

int main()
{
    ll n;cin>>n;
    int ans = 100;
    repd(i,1,n+1){
        if(n%i==0){
            string a = to_string(i);
            string b = to_string(n/i);
            int la = a.size();
            int lb = b.size();
            ans = min(ans,max(la,lb));
        }
        if(n/i < i) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

vvll g;

pair<mint, mint> dfs(ll u, ll v) {
	mint bl = 1;
	mint wh = 1;

	for (ll w : g[v]) {
		if (u == w) { continue; }
		auto p = dfs(v, w);
		bl *= p.second;
		wh *= (p.first + p.second);
	}

	return { bl,wh };
}
int main() {
	ll N;
	cin >> N;
	g.resize(N + 1);
	repn(i, N - 1) {
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	auto p = dfs(0, 1);
	cout << p.first + p.second << endl;
}

Measured memory_bytes: 15440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n=0;
  int max=-1,min=101;
  int sum=0,sum2=100000000;
  cin >> n;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
  }
  
  for (int i = 0; i < n; i++) {
  if(max<vec.at(i)){
      max=vec.at(i);
  }
  if(min>vec.at(i)){
     min=vec.at(i); 
  }
  }
  
  for(int i = min; i<=max;i++){
      for (int j = 0; j < n; j++) {
      sum+=(vec.at(j)-i)*(vec.at(j)-i);
  }
  if(sum2>sum){
      sum2=sum;
  }
  sum=0;
  }
  cout<< sum2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n;
    cin >> n;
    if (n == 1)
        cout << "Hello World" << endl;
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    string S;
	cin >> S;
    int n = S.size();
	cout << string(n, 'x') << endl;
	return 0;
}


Measured memory_bytes: 256
import copy
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
  
def bfs(l, tmp, came):
  t = []
  for n in tmp:
    for s in l:
      if (s[0]==n) and (s[1] not in came):
        t.append(s[1])
        came.append(s[1])
      elif (s[1]==n) and (s[0] not in came):
        t.append(s[0])
        came.append(s[0])
  if t == []:
    came = set(came)
    return came
  else:
    return bfs(l, t, came)
  
ans = 0
for i in range(M):
  x = copy.copy(l)
  x.pop(i)
  a = bfs(x, [1], [1])
  if len(a) < N:
    ans += 1
print(ans)

Measured memory_bytes: 9336
#include <iostream>

using namespace std;

int main(void) {
  int A, B, C, ans;
  cin >> A >> B >> C;
  ans = C - A + B;
  if(ans >= 0) {
  	cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
left = S[0:(len(S)-1)//2]
right = S[(len(S)+3)//2 - 1: len(S)]

def kaibun(s):
    for i in range(len(s)//2):
        if s[i] != s[len(s)-i-1]:
            return False
    return True

if kaibun(S) and kaibun(left) and kaibun(right):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(N: int, R: int):
    if N >= 10:
        print(str(R))
        return
    else:
        print(str(R+100*(10-N)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(N, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
lst=[2,11,31,41,61,71,101,151,181,191,211,241,251
,271,281,311,331,401,421,491,521,541
,571,601,631,641,661,691,701,751,761,1021
,1031,1051,1061,1091,1201,2221,3001,3011
,3821,4421,4441,4451,4111,4391,8861,8221,9901
,8831,6011,6581,7001,8171,6151,6701]
n=int(input())
x=''
for i in range(n):
    x+=str(lst[i])+' '
print(x)

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
int main(){
   int h, w, k;
   cin >> h >> w >> k;
   vector<string>board(h);
   vector<int>b(w);
   vector<vector<int>>ans(h,vector<int>(w));
   rep(i, 0, h)cin >> board[i];
   int p = 0;
   rep(i, 0, h){
       rep(j, 0, w){
           if(board[i][j]=='#'){
               p++;
               ans[i][j]=p;
           }
        }
    }
   rep(i, 0, h){
       if(board[i].find('#')==string::npos)continue;
       rep(j, 0, w){
           if(j-1<0)continue;
           if(ans[i][j]==0)ans[i][j]=ans[i][j-1];
        }
       rrep(j, w-1, 0){
           if(j+1>=w)continue;
           if(ans[i][j]==0)ans[i][j]=ans[i][j+1];
        }
    }
    rep(i, 0, h){
        if(i-1<0)continue;
        if(ans[i]==b)ans[i]=ans[i-1];
    }
    rrep(i, h-1, 0){
        if(i+1>=h)continue;
        if(ans[i]==b)ans[i]=ans[i+1];
    }
    rep(i, 0, h){
        rep(j, 0, w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

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

int main(){
    string s; cin >> s;
    long long k; cin >> k;
    int one = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '1') one++;
        else break;
    }
    if(one >= k) cout << '1' << endl;
    else cout << s[one] << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = set([int(input()) for _ in range(M)])
    ways = [0] * (N+1)
    ways[0] = 1
    for i in range(1, N+1):
        if i not in A:
            ways[i] = ways[i-1] + ways[i-2]

    print(ways[N] % 1000000007)


if __name__ == '__main__':
    main()

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

int main() {
    string S, T;
    cin >> S >> T;
    int res = 0;
    for(int i = 0; i < S.size(); ++i) {
        if(S[i] != T[i]) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
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;}

ll N;

int main() {
    cin >> N;

    int n = sqrt(N);
    for (int i = n; i > 0; i--) {
        if (N % i == 0) {
            int A = i, B = N / i;
            int a = 0, b = 0;
            while (A > 0) {
                A = A / 10;
                a++;
            }
            while (B > 0) {
                B = B / 10;
                b++;
            }
            cout << max(a,b) << endl;
            return 0;
        }
    }      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#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 REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

int n, k;
int a[limit];
int f[105][100005];

void solveProblem() {
    f[0][0] = 1;

    REP(i, 1, n) {
        int pre = 0;
        REP(j, 0, k) {
            pre += f[i - 1][j], pre %= MOD;
            if (j > a[i]) pre -= f[i - 1][j - a[i] - 1];
            pre = (pre % MOD + MOD) % MOD;

            f[i][j] = pre;
        }
    }

    cout << f[n][k] << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n >> k;
    REP(i, 1, n) cin >> a[i];
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 42684
import java.util.*;

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

        int N = sc.nextInt();

        for (int i=0; i<N; i++) {
            for (int j=0; j<N-i; j++) {
                if (i*4 + j*7 == N) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23252
class Dice:
    def __init__(self,list):
        self.list = []
        for i in range(6):
            self.list.append(list[i])

    def rotate(self,dir):
        if dir == "N":
            self.list[0], self.list[1], self.list[5], self.list[4] = self.list[1], self.list[5], self.list[4], self.list[0]
        elif dir == "S":
            self.list[0], self.list[4], self.list[5], self.list[1] = self.list[4], self.list[5], self.list[1], self.list[0]
        elif dir == "W":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[2], self.list[0], self.list[3], self.list[5]
        elif dir == "E":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[3], self.list[5], self.list[2], self.list[0]
        else:
            pass

    def show(self):
        for i in self.list:
            print(i)


l = [ int(x) for x in input().split()]
dice = Dice(l)
str = input()
for i in range(len(str)):
    dice.rotate(str[i])
print(dice.list[0])



Measured memory_bytes: 5616
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e3+10; 
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,k,p,h,w;
char a[10][10];
char b[10][10];

int main(){
	cin>>h>>w>>k;
	F(i,1,h){
		F(j,1,w){
			cin>>a[i][j];
		}
	}
	int ans = 0;
	for(int st=0;st<(1<<(h+w));st++){
		F(i,1,h){
			F(j,1,w){
				b[i][j]=a[i][j];
			}
		}
		int tmp = st;
		for(int j = 1;j<=h;j++){
			if(tmp&1){
				F(k,1,w){
					b[j][k] = '.';
				}
			}
			tmp>>=1;
		}
		for(int j=1;j<=w;j++){
			if(tmp&1){
				F(k,1,h){
					b[k][j] = '.';
				}
			}
			tmp>>=1;
		}
		int cnt = 0;
		F(i,1,h){
			F(j,1,w){
				if(b[i][j]=='#') cnt++;
			}
		}
		if(cnt==k) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	
	int n;
	scanf("%d",&n);
	int a[n];
	
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int maxv=a[1]-a[0];
	int minv=a[0];
	
	for(int j=1;j<=n-1;j++){
		if(maxv<a[j]-minv){
			maxv=a[j]-minv;
		}
		if(minv>a[j]){
			minv=a[j];
		}
	}
	
	
	
	printf("%d",maxv);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 200005
#define ll long long

void DBG() {
    cerr << "]\n";
}
template <class H, class... T> void DBG(H h, T... t) {
    cerr << h;
    if (sizeof...(t)) {
        cerr << ", ";
    }
    DBG(t...);
}
#define _DEBUG
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int tt, n, k;
int a[maxn];

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

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += a[n - i / 2];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 4404
import java.util.*;
import java.util.stream.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}

	public static void main(String[]$){
		int n=gInt(),x=gInt();
		int[]a=IntStream.range(0,n)
				.map(i->gInt())
				.sorted()
				.toArray();
		x-=Arrays.stream(a).sum();
		System.out.println(x/a[0]+n);
	}
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

const int maxn = 1e5 + 5;
ll s[maxn], t[maxn];
int n;

vector<ll> prime;

void init_prime(int N){
    vector<int> vis(N, 0);
    prime.clear();
    vis[1] = 1;
    for(int i = 2;i < N;i++){
        if(!vis[i]){
            prime.push_back(i);
            for(int j = i * 2;j < N; j += i){
                vis[j] = 1;
            }
        }
    }
}

ll qpow(ll a, ll n){
    ll ret = 1;
    while(n > 0){
        if(n & 1){
            ret = ret * a;
        }
        a = a * a;
        n >>= 1;
    }
    return ret;
}

vector<pair<ll, int> > decom(ll v){
    vector<pair<ll, int> > ans;
    for(int i = 0;i < prime.size();i++){
        if(prime[i] > v)
            break;
        if(v % prime[i] == 0){
            int cnt = 0;
            while(v % prime[i] == 0){
                v /= prime[i];
                cnt++;
            }
            cnt %= 3;
            ans.eb(prime[i], cnt);
        }
    }
    if(v > 1){
        ll rt = (ll)(sqrt(v) + 0.5);
        if(rt * rt == v){
            ans.eb(rt, 2);
        }else{
            ans.eb(v, 1);
        }
    }
    return ans;
}

int Inv[3] = {0, 2, 1};

ll cal(vector<pair<ll, int> > rep, bool inv){
    ll ret = 1;
    for(auto p : rep){
        int cnt = p.se;
        if(inv)
            cnt = Inv[cnt];
        ret = ret * qpow(p.fi, cnt);
    }
    return ret;
}

map<ll, int> Count;
map<ll, bool> visited;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    init_prime(2500);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> s[i];
        vector<pair<ll, int> > rep = decom(s[i]);
        ll v1 = cal(rep, false);
        ll v2 = cal(rep, true);
        Count[v1]++;
    }
    ll ans = 0;
    for(auto v : Count){
        ll val = v.first;
        if(visited.count(val))
            continue;
        int cnt = v.second;
        if(val == 1){
            ans++;
            visited[val] = true;
            continue;
        }
        vector<pair<ll, int> > rep = decom(val);
        ll val1 = cal(rep, true);
        if(Count.count(val1)){
            ans += max(cnt, Count[val1]);
            visited[val] = true;
            visited[val1] = true;
        }else{
            ans += cnt;
            visited[val] = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
using namespace std;
int a[105];
int main()
{
	int n,ans=0,flag=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	 {
	 	if(flag)
	 	{
	 		flag=!flag;
	 		ans+=a[i];
	 	}
	 	else
	 	{
	 		flag=!flag;
	 		ans-=a[i];
	 	}
	 }
	 cout<<ans;
	 return 0;
}


Measured memory_bytes: 256
import sys
from functools import reduce
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)
def main():
    _, X = input().split()
    x = sorted(map(int, input().split() + [X]))
    min_x = x[0]
    x = map(lambda a: a - min_x, x[1:])

    def gcd(m, n):
        if n == 0:
            return m
        else:
            return gcd(n, m % n)
    print(reduce(gcd, x))

if __name__ == '__main__':
    main()


Measured memory_bytes: 15364
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int a;
		cin>>a;
		n-=a;
	}
	if(n<0)
	cout<<"-1";
	else
	cout<<n;
}

Measured memory_bytes: 3616
#


def main():
    t = int(input())
    gohyaku = t // 500
    remain = t - gohyaku * 500
    goen = 0
    if remain > 0:
        goen = remain // 5
    print(gohyaku * 1000 + goen * 5)


if __name__ == '__main__':
    main()


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

long long combination (int val ) { 
	long long ans = 1; 
	ans = 1ll*val * (val-1); 
	ans = ans / 2 ; 
	return ans ; 
}


int main() { 
	int n ; 
	cin >> n ; 
	map<int,int> mp ;
	map<int,long long> sz ; 
	vector<int> vect(n) ; 
	for (int i = 0 ; i < n ; i ++ ) {
		cin >> vect[i] ; 
		mp[vect[i]]++ ; 
	}
	for ( auto & r : mp ) {
		sz[r.first] = combination(r.second); 
	}
	long long sum = 0 ; 
	for (auto & r : sz ) {
		sum+= r.second ; 
	}
	
for ( int i = 0 ; i < n ; i ++ ) {
		cout << sum-sz[vect[i]]+combination(mp[vect[i]]-1) << endl ; 
	}
	
}


Measured memory_bytes: 16256