akhauriyash/Code-Regression huggingface dataset:
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int calc(int x) {
	int w = 1;
	while(x % 2 == 0) {
		x /= 2;
		w++;
	}
	return w;
}

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 0;i < n - 1;i++) {
		for(int j = i + 1;j < n;j++) {
			if(j != i + 1) cout<<" ";
			cout<<(calc(j - i));
		}
		cout<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define N 37

typedef struct{
	char ch;
	int num;
} card;

card temp,output1[N],output2[N];
int n;

void bubble();
void select();

int main(void){
	int i,j,cnt = 0;
	scanf("%d",&n);
	for(i = 0 ; i < n ; i++){
		scanf(" %c%d",&output1[i].ch,&output1[i].num);
		output2[i] = output1[i];
	}
	bubble();
	select();
	for(i = 0 ; i < n ; i++){
		if(output1[i].ch==output2[i].ch) cnt++;
	}
	for(i = 0 ; i < n ; i++){
		printf("%c%d",output1[i].ch,output1[i].num);
		if(i != n-1) printf(" ");
		if(i == n-1) printf("\n");
	}
	puts("Stable");
	for(i = 0 ; i < n ; i++){
		printf("%c%d",output2[i].ch,output2[i].num);
		if(i != n-1) printf(" ");
		if(i == n-1) printf("\n");
	}
	if(cnt == n)puts("Stable");
	else puts("Not stable");
    	return 0;
}

void bubble(){
	int i,j;
	for(i = 0 ; i < n ; i++){
		for(j = n-1 ; j > i ; j--){
			if(output1[j-1].num > output1[j].num){
				temp = output1[j-1];
				output1[j-1] = output1[j];
				output1[j] = temp;
			}
		}
	}
	return ;
}

void select(){
	int mini,i,j;
	for(i = 0 ; i < n ; i++){
		mini = i;
		for(j = i ; j < n ; j++){
			if(output2[j].num < output2[mini].num) mini = j;
		}
		temp = output2[i];
		output2[i] = output2[mini];
		output2[mini] = temp;
	}
	return ;
}



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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -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; }

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

    if (n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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

		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		
		
		//偶＋偶
		//奇＋奇
		
		int cnt = 0;
		
		cnt += (n*(n-1))/2;
		cnt += (m*(m-1))/2;

		System.out.println(cnt);


	}

}


Measured memory_bytes: 21972
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m,q = LI()
    s = [I() for _ in range(n)]
    t = [I() for _ in range(m)]
    x = [I() for _ in range(q)]

    rr = []
    for y in x:
        r = inf
        si = bisect.bisect(s, y)
        if si > 0:
            z = s[si-1]
            k = y - z
            ti = bisect.bisect(t, z)
            if ti > 0:
                u = k + z - t[ti-1]
                if r > u:
                    r = u
            if ti < m:
                u = k + t[ti] - z
                if r > u:
                    r = u
        if si < n:
            z = s[si]
            k = z - y
            ti = bisect.bisect(t, z)
            if ti > 0:
                u = k + z - t[ti-1]
                if r > u:
                    r = u
            if ti < m:
                u = k + t[ti] - z
                if r > u:
                    r = u

        ti = bisect.bisect(t, y)
        if ti > 0:
            z = t[ti-1]
            k = y - z
            si = bisect.bisect(s, z)
            if si > 0:
                u = k + z - s[si-1]
                if r > u:
                    r = u
            if si < n:
                u = k + s[si] - z
                if r > u:
                    r = u
        if ti < m:
            z = t[ti]
            k = z - y
            si = bisect.bisect(s, z)
            if si > 0:
                u = k + z - s[si-1]
                if r > u:
                    r = u
            if si < n:
                u = k + s[si] - z
                if r > u:
                    r = u

        rr.append(r)

    return '\n'.join(map(str, rr))



print(main())




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

struct node{
	string str;
	int post;
};
queue<node> nxt;
map<string, int> ans;
const int dx[] = {1, -1, -4, 4};
bool judge(int pos, int op){
	if((pos==0||pos==4)&&op==1) return false;
	if((pos==3||pos==7)&&op==0) return false;
	if((pos<4&&op==2)||(pos>3&&op==3)) return false;
	return true;
}
void built(){
	node ori = node{"01234567", 0};
	nxt.push(ori);
	ans[ori.str] = 0;
	while(!nxt.empty()){
		node tem = nxt.front();
		nxt.pop();
		for(int i = 0; i < 4; i++){
			if(!judge(tem.post, i)) continue; 
			node now = node{tem.str, tem.post + dx[i]};
			swap(now.str[tem.post],now.str[tem.post+dx[i]]);
			if(ans.count(now.str)) continue;
			nxt.push(now), ans[now.str] = ans[tem.str] + 1;
	    }
	}
}

int main(){
	ios::sync_with_stdio(false);
	built();
	char lin[9];
	while(cin >> lin[0]){
	    for(int i = 1; i < 8; i++) cin >> lin[i];
	    lin[8] = '\0';
		cout << ans[lin] << "\n";
	}
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin>>N,N){
	VS vs(N);
	REP(i,N){
	  string s; cin >> s;
	  string t = string(1, s[0]);
	  for(int i=1;i<SZ(s);++i){
		if(string("aiueo").find(s[i-1]) != string::npos){
		  t += s[i];
		}
	  }
	  vs[i] = t;
	}
	
	int k;
	for(k=1;k<=50;++k){
	  set<string> s;
	  for(int i=0;i<N;++i)
		s.insert(vs[i].substr(0,k));
	  if(SZ(s) == N){
		break;
	  }
	}
	cout << (k>50?-1:k) << endl;
  }

  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

bool check(int a){
  if(a==2||a==3||a==5||a==7) return true;
  int a_2 = sqrt(a);
  for(int i=2;i<=a_2+1;i++){
    if(a%(i)==0) return false;
  }
  return true;
}
int main(){
  int x;
  cin>>x;
  while(true){
    if(check(x)){
      cout << x;
      return 0;
    }
    x++;
  }
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;
 
#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)
 
using ll = long long int;
using pll = pair<ll, ll>;
 
const ll mod = static_cast<ll>(1e9) + 7;
const ll inf = static_cast<ll>(1e10) + 7;
 
int main()
{
    ll X, Y, AN, BN, CN;
    cin >> X >> Y >> AN >> BN >> CN;
 
    vector<ll> A(AN), B(BN), C(CN);
    for (auto& x : A) { cin >> x; }
    for (auto& x : B) { cin >> x; }
    for (auto& x : C) { cin >> x; }
 
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
 
    sort(A.begin(), A.begin() + X);
    sort(B.begin(), B.begin() + Y);
 
    ll ai = 0, bi = 0, ci = 0;
    ll ans = 0;
 
    while (ai < X || bi < Y)
    {
        const ll a = ai < X ? A[ai] : inf;
        const ll b = bi < Y ? B[bi] : inf;
        const ll c = ci < CN ? C[ci] : -1;
 
        if (a < b)
        {
            if (a < c)
            {
                ans += c;
                ++ci;
            }
            else
            {
                ans += a;
            }
 
            ++ai;
        }
        else
        {
            if (b < c)
            {
                ans += c;
                ++ci;
            }
            else
            {
                ans += b;
            }
 
            ++bi;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
# coding: utf_8

n = int(input())
a = list(map(int, input().split()))
count = 0

for i1 in range(n):
    mini2 = i1
    for i2 in range(len(a[i1:])):
        i2 += i1
        if a[i2] < a[mini2]:
            mini2 = i2
    if i1 != mini2:
        temp = a[i1]
        a[i1] = a[mini2]
        a[mini2] = temp
        count +=1

print(a[0], end="")
for i in a[1:]:
    print(" {}".format(i),end="")

print("\n{}".format(count))



Measured memory_bytes: 5616
#include <stdio.h>
int main(int argc, char const *argv[]) {
int N;
int h[100000];
int b[100000];

scanf("%d\n",&N);
for (int i = 0; i < N; i++) {
  scanf("%d",&h[i]);
}
for (int i = 0; i < N; i++) {
  b[h[i]-1]=i+1;
}

for (int i = 0; i < N; i++) {
  printf("%d ",b[i] );
}


  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

int main(){
    string S;
    cin>>S;
    if(S=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(S=="Cloudy")
        cout<<"Rainy"<<endl;
    else
    {
        cout<<"Sunny"<<endl;
    }
   return 0; 
}




Measured memory_bytes: 256
// VU TRUONG AN
#include <bits/stdc++.h>
#define F first
#define S second
#define maxn 200005
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define pi acos(-1)
#define bit(p,x) ((x>>p) & 1)
#define Task "CF"
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int > piii;

const int base = 200003;
const long long MM = 1ll * MOD * MOD;

int n;

void Solve(){
    char a[4][4];
    n = 3;
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j) cin >> a[i][j];
    for(int i = 1;i <= n;++i) cout << a[i][i];
}

void NumTime(){cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen(Task".inp", "r", stdin);
    freopen(Task".out", "w", stdout);
#endif
    int test = 1;
//    cin >> test;
    while(test--){
        NumTime();
        Solve();
    }
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(){
	int w,n,
		a[30],b[30],
		kuji,result[30],
		i,j;
	
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d,%d",&a[i],&b[i]);
	
	for(i=1;i<=w;i++){
		kuji=i;
		for(j=0;j<n;j++){
			if(kuji==a[j])
				kuji=b[j];
			else if(kuji==b[j])
				kuji=a[j];
		}
		result[kuji-1]=i;
	}
	
	for(i=0;i<w;i++)
		printf("%d\n",result[i]);
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d) {
        cout << "Left" << endl;
    } else if (a + b < c + d) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
struct UnionFind {
    int n;
    vector<int> parent;

    UnionFind() {}
    UnionFind(int nmemb) {
        init(nmemb);
    };

    void init(int nmemb) {
        parent.clear();
        parent.assign(nmemb, -1);
    };

    int root(int x) {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    };

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        if (parent[y] < parent[x]) swap(x, y);

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    };
    
    bool same(int x, int y) {
        return root(x) == root(y);
    };
    int size(int x) {
        return -(parent[root(x)]);
    };
};
//===

UnionFind fore(100005);
vector<vector<int>> block(100005);
vector<vector<int>> fg(100005);

llong n, m, k;

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) {
        llong a, b;
        cin >> a >> b;
        
        fore.unite(a, b);
        fg[a].push_back(b);
        fg[b].push_back(a);
    }

    for (int i = 0; i < k; i++) {
        llong a, b;
        cin >> a >> b;
        block[a].push_back(b);
        block[b].push_back(a);
    }

    for (int i = 1; i <= n; i++) {
        llong ans = fore.size(i);
        ans -= fg[i].size();

        for (auto a:block[i]) {
            if (fore.same(a, i)) {
                ans--;
            }
        }

        ans--;
        cout << ans << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 12152
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S, T = gets.split
a, b = get_ints
U = gets.chomp

if U == S
  a -= 1
else
  b -= 1
end

puts "#{a} #{b}"


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

int main(){
	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i=0; i<h; i++)cin>>s[i];
	for(int i=0; i<h; i++){
		for(int j=0; j<w-1; j++){
			if(s[i][j]=='#'){
				cout<<'#';
				continue;
			}
			int cnt=0;
			if(s[i-1][j-1]=='#')cnt++;
			if(s[i-1][j]=='#')cnt++;
			if(s[i][j-1]=='#')cnt++;
			if(s[i-1][j+1]=='#')cnt++;
			if(s[i+1][j-1]=='#')cnt++;
			if(s[i+1][j]=='#')cnt++;
			if(s[i][j+1]=='#')cnt++;
			if(s[i+1][j+1]=='#')cnt++;
			cout<<cnt;
		}
		int j=w-1;
		if(s[i][j]=='#'){
			cout<<'#'<<endl;
			continue;
		}
		int cnt=0;
		if(s[i-1][j-1]=='#')cnt++;
		if(s[i-1][j]=='#')cnt++;
		if(s[i][j-1]=='#')cnt++;
		if(s[i-1][j+1]=='#')cnt++;
		if(s[i+1][j-1]=='#')cnt++;
		if(s[i+1][j]=='#')cnt++;
		if(s[i][j+1]=='#')cnt++;
		if(s[i+1][j+1]=='#')cnt++;
		cout<<cnt<<endl;
	}
}

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

#define HEIGHT_MAX 30
#define WIDTH_MAX 30
#define BOARD_MAX (HEIGHT_MAX*(WIDTH_MAX+1))
#define BUF_SIZE WIDTH_MAX+5

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

int judge(char *arr, int size, int chains, int neighs) {
    int score = 0;
    int cnt = 1;
    char cur = arr[0];
    int i, j;
    for(i = 1; i < size; i++) {
        char next = arr[i];
        if(cur == next) { cnt++; continue; }
        if(cnt >= neighs) {
            score += (1<<chains) * (cnt * cur);
            // labeled as 0
            for(j = i - cnt; j <= i-1; j++) {
                arr[j] = 0;
            }
        }
        // reset
        cur = next; cnt = 1;
    }
#ifdef DEBUG
    printf("chains: %d -> score: %d\n", chains, score);
#endif
    return score;
}

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    int height, width, neighs;
    get_int3(&height, &width, &neighs);
    static char board[HEIGHT_MAX][WIDTH_MAX+1];
    static char buf[BUF_SIZE];
    int i, j;
    for(i = height-1; i >= 0; i--) {
        get_str(buf, BUF_SIZE);
        for(j = 0; j < width; j++) {
            board[i][j] = buf[j]-'0';
        }
    }

    int ans = 0; // less than 1billion
    int hei, wid;
    for(hei = 0; hei < height-1; hei++) {
        for(wid = 0; wid < width; wid++) {
#ifdef DEBUG
            printf("remove: (%d, %d)\n", hei, wid);
#endif
            int score = 0;
            int chs = 0;
            char bboard[HEIGHT_MAX][WIDTH_MAX+1] = {0};
            memcpy(bboard, board, BOARD_MAX);
            // remove one of the stones
            for(i = hei+1; i < height; i++) {
                bboard[i-1][wid] = bboard[i][wid];
            }
            bboard[height-1][wid] = 0;

            // judge
            for(chs = 0; ; chs++) {
                int scr = 0;
                int h, w;
                char new[HEIGHT_MAX][WIDTH_MAX+1] = {0};
                for(h = 0; h < height; h++) {
                    scr += judge(bboard[h], width+1, chs, neighs);
                }
                // calc_score
                if(!scr) break;
                score += scr;

                // drop(not-in-place)
                for(w = 0; w < width; w++) {
                    int idx = 0;
                    // bottom to top..
                    for(h = 0; h < height; h++) {
                        if(!bboard[h][w]) continue;
                        new[idx++][w] = bboard[h][w];
                    }
                }
                // memcpy
                memcpy(bboard, new, BOARD_MAX);
            }
            ans = max(ans, score);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
input = stdin.readline

n = int(input().rstrip())
a = list(map(int, input().rstrip().split()))

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

Measured memory_bytes: 31492
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
string a,b;
int dp[3005][3005];
int LCS(int i,int j){
    if(i == sz(a) or j == sz(b))
        return 0;
    if(dp[i][j] != -1)return dp[i][j];
    int &ans = dp[i][j];
    if(a[i] == b[j])
        return ans = LCS(i + 1,j + 1) + 1;
    return ans = max(LCS(i + 1, j), LCS(i, j + 1));

}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    cls(dp, -1);
    cin >> a >> b;
    LCS(0, 0);
    //reconstruir
    int i = 0, j = 0;
    string ans = "";
    while(i < sz(a) and j < sz(b)){
        if(a[i] == b[j]){
            ans += a[i];
            i++;
            j++;
        }else 
        if(dp[i + 1][j] > dp[i][j + 1])
            i++;
        else
            j++;
    }
    cout << ans << '\n';
    return 0;
}   

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



void f(int n){
  string a;
  map<string,vector<string>> mp;

  for(int j=0;j<n;j++){
    string s;
    string b;
    vector<string> v;
    cin>>s;
    int i=0;
    string t="";
    while(i<s.size()){
      if(s[i]==':'){
        if(j==0)
          a=t;
        b=t;
        t="";
      }
      else if(s[i]==','){
        v.push_back(t);
        t="";
      }
      else if(s[i]=='.'){
        v.push_back(t);
        mp[b]=v;
      }
      else{
        t+=s[i];
      }
      i++;
    }
  }

  int ans=0;
  map<string,bool> ma;
  queue<string> q;
  q.push(a);
  while(!q.empty()){
    string s=q.front();
    q.pop();
    if(ma[s]) continue;
    ma[s]=true;
    if(mp[s].empty()){
//      cout<<s<<endl;
      ans++;
      continue;
    }

    for(string t:mp[s]){
      q.push(t);
    }
  }

  cout<<ans<<endl;


}



int main(){
  int n;
  while(true){
    cin>>n;
    if(!n) break;
    f(n);
  }

}



Measured memory_bytes: 3412
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    while(getline(cin, s), s != "0"){
        vector<int> v{0};
        for (auto &&i : s) {
            if(i == ' ') v.emplace_back();
            else v.back() = v.back()*10 + i-'0';
        }
        int val = 0, one = 0;
        for (auto &&i : v) {
            val += min(i, 10);
            one += (i == 1);
        }
        while(val <= 11 && one){
            val += 10;
            one--;
        }
        if(val > 21) val = 0;
        cout << val << "\n";
    }
    return 0;
}


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
#define _R 200001
//---------------------------------------------------------------------------------------------------
ll f[_R], rf[_R];
ll inv(ll x) {
	ll res = 1;
	ll k = mod - 2;
	ll y = x;
	while (k) {
		if (k & 1) res = (res * y) % mod;
		y = (y * y) % mod;
		k /= 2;
	}
	return res;
}
void init() {
	f[0] = 1;
	rep(i, 1, _R) f[i] = (f[i - 1] * i) % mod;
	rep(i, 0, _R) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
	ll a = f[n]; // = n!
	ll b = rf[n - k]; // = (n-k)!
	ll c = rf[k]; // = k!

	ll bc = (b * c) % mod;

	return (a * bc) % mod;
}
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll mc(ll n, ll k) { ll a = 1, b = 1; rep(i, 0, k) { a = a * (n - i + 1) % mod; b = b * i % mod; }return a * mpower(b, mod - 2) % mod; }

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	init();
	ll ans = 0;
	rep(i, 0, k + 1) {
		ans += mpower(m - 1, n - 1 - i) * C(n - 1, i);
		ans %= mod;
	}
	printf("%lld\n", m * ans % mod);
	return 0;
}


Measured memory_bytes: 6928
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

int main() {
    int N;
    vector<double> x,y;
    cin >> N;

    vector<int> idx;

    for (int i = 0; i < N; i++) {
        double _x, _y;
        cin >> _x >> _y;
        x.push_back(_x);
        y.push_back(_y);
        idx.push_back(i);
    }

    vector<double> res;
    do {
        double sum = 0;
        for (int i = 0; i < N - 1; i++) {
            double xx = x[idx[i]] - x[idx[i + 1]];
            double yy = y[idx[i]] - y[idx[i + 1]];
            sum += sqrtl(xx * xx + yy * yy);
        }
        res.push_back(sum);

    } while (next_permutation(idx.begin(), idx.end()));

    cout << setprecision(20) << std::accumulate(res.begin(), res.end(), 0.0) / res.size() << endl;

    return 0;
}

Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	int x = 0;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		x ^= a;
	}
	if (x == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto S = to!string(tokens[0]);

	ulong ans, cnt_b;

	foreach (i, e; S)
	{
		if (e == 'B') ++cnt_b;
		else ans += cnt_b;
	}

	writeln(ans);
	stdout.flush();
/*}catch (Throwable e)
	{
		writeln(e.toString());
	}
readln();*/
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(10001);
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int t = x * x + y * y + z * z + x * y + y * z + z * x;
                if (t <= 10000)
                    a[t]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << "\n";

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, S;
      cin >> N;
      S = 0;
      
      while(N > 0){
        int l, r;
        cin >> l >> r;
        S += r - l + 1;
        N--;
      }
      cout << S << endl;

    }

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


int main() {
	int a, b, c, d, e, f;
	double x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		x = (double)(c*e - f*b) / (double)(a*e - d*b);
		y = (double)(c*d - f*a) / (double)(b*d - e*a);
		if (x == 0) { x = 0; }
		if (y == 0) { y = 0; }
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1192
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
MOD = 998244353

N = int(readline())
D = np.array(read().split(),np.int32)

if D[0] != 0:
    print(0)
    exit()

counter = np.bincount(D,minlength=N)

if counter[0] != 1:
    print(0)
    exit()

arr = counter[D[1:] - 1]

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

answer = cumprod(arr,MOD)[-1]
print(answer)

Measured memory_bytes: 18564
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int A, B, K;
    cin >> A >> B >> K;

    vector<int> a(0);

    REP(i, K){
        if(A + i <= B) a.push_back(A + i);
        if(B - i >= A) a.push_back(B - i);
    }
    sort(a.begin(), a.end());

    vector<int> b(1);
    b[0] = a[0];
    FOR(i, 1, a.size()){
        if(a[i] != a[i - 1]) b.push_back(a[i]);
    }

    REP(i, b.size()){
        cout << b[i];
        if(i != b.size() - 1) cout << endl;
    }

    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 256
#include <limits.h>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
#include <vector>
#include <list>
#define NUMBER 100000

using namespace std;

int main()
{
  char s[NUMBER];
  cin >> s;
  int n = strlen(s);
  int K;
  cin >> K;

  int j = 0;
  while(K){
    //cout << "s = " << s << endl;
    if(j==n-1){
      while(K){
          if(s[j]=='z')
            s[j] = 'a';
          else
            s[j]+=1;
          K--;
      }
    }
    else if(s[j]+K >'z'){
      while(s[j]!='a'){
        if(s[j]=='z')
          s[j] = 'a';
        else
          s[j]+=1;
        K--;
      }
    }
    j++;
  }

  cout << s << endl;


  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int
#define F first
#define S second
#define pb push_back
#define M 1000000007
#define inf 1e18
#define endl "\n"
#define jam(x) cout<<"Case #"<<x<<": "

void display2D( vector<vector<int> > &v ) {
	int n = v.size();
	int m = v[0].size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

std::vector<std::vector<int>> dp;

int32_t main() {
	fastio;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s1, s2;
	cin >> s1 >> s2;
	int n = s1.size(), m = s2.size();
	dp.resize( n + 1 , std::vector<int>(m + 1, 0)  );

	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < m + 1; j++) {
			if (s1[i - 1] == s2[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max( dp[i - 1][j] , dp[i][j - 1] );
			}
		}
	}

	//display2D(dp);

	int len = dp[n][m];
	string ans = "";
	int i = n, j = m;
	while ( len > 0 && i >= 0 && j >= 0) {
		if ( s1[i - 1] == s2[j - 1] ) {
			ans = s1[i - 1] + ans;
			i--;
			j--;
			len--;
		}
		else {
			if ( dp[i][j - 1] >= dp[i - 1][j]) {
				j--;
			} else {
				i--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        String t = sc.next();
        
        char[] c = t.toCharArray();
        for(int i = 0; i < n; i++){
            if(c[i] == 'r'){
                c[i] = 'p';
            }else if(c[i] == 's'){
                c[i] = 'r';
            }else if(c[i] == 'p'){
                c[i] = 's';
            }
        }
        
        boolean[] b = new boolean[n];
        Arrays.fill(b, true);
        if(k*2 < n){
            for(int i = k; i < n-k; i++){
                if(c[i] == c[i-k]){
                    b[i] = false;
                    if(c[i] == 'r'){
                        if(c[i+k] == 's'){
                            c[i] = 'p';
                        }else{
                            c[i] = 's';
                        }
                    }else if(c[i] == 's'){
                        if(c[i+k] == 'p'){
                            c[i] = 'r';
                        }else{
                            c[i] = 'p';
                        }
                    }else if(c[i] == 'p'){
                        if(c[i+k] == 'r'){
                            c[i] = 's';
                        }else{
                            c[i] = 'r';
                        }
                    }
                }
            }
            for(int i = n-k; i < n; i++){
                if(c[i] == c[i-k]){
                    b[i] = false;
                }
            }
        }else{
            for(int i = k; i < n; i++){
                if(c[i] == c[i-k]){
                    b[i] = false;
                }
            }
        }
        
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(b[i]){
                if(c[i] == 'r'){
                    ans += r;
                }else if(c[i] == 's'){
                    ans += s;
                }else if(c[i] == 'p'){
                    ans += p;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27888
#include <iostream>
#include <cmath>

using namespace std;

struct Point {
	double x, y;
	Point(double x=0, double y=0) : x(x), y(y) {}
	Point operator-(const Point &o) const {
		return Point(x-o.x, y-o.y);
	}
};

double cross(Point &a, Point &b) {
	return (a.x * b.y - b.x * a.y);
}

bool in(Point &a, Point &b, Point &c, Point &p) {
	Point ab = b-a;
	Point bc = c-b;
	Point ca = a-c;
	Point ap = p-a;
	Point bp = p-b;
	Point cp = p-c;
	double cross_a = cross(ab, ap);
	double cross_b = cross(bc, bp);
	double cross_c = cross(ca, cp);
	return (cross_a / abs(cross_a) == cross_b / abs(cross_b) &&
			cross_b / abs(cross_b) == cross_c / abs(cross_c));
}



int main() {
	int n; cin >> n;
	while (n--) {
		Point v[3], altair, vega;
		for (int i = 0; i < 3; i++) cin >> v[i].x >> v[i].y;
		cin >> altair.x >> altair.y >> vega.x >> vega.y;

		bool altair_in, vega_in;
		altair_in = in(v[0], v[1], v[2], altair);
		vega_in = in(v[0], v[1], v[2], vega);

		if (altair_in ^ vega_in) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}



	

Measured memory_bytes: 952
#include <stdio.h>

int main(void){
    int n, array[100][100],i,j,minweight=2001,total=0,flag[100],k=1,minnum[100],num=0;
    
scanf("%d",&n);
for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        scanf("%d",&array[i][j]);
    }
    flag[i]=0;
}
minnum[0]=0;
flag[0]=1;
while(k<n){
    minweight=2001;
for(i=0;i<k;i++){
    for(j=0;j<n;j++){
        if(array[minnum[i]][j]!=-1){
            if(minweight>array[minnum[i]][j] &&flag[j] == 0){
                minweight=array[minnum[i]][j];
                num=j;
            }
        }
       
    }
}
minnum[k]=num;
flag[num]=1;
total+=minweight;
k++;
}
printf("%d\n",total);
return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[,\n]");
		
		while (true)
		{
			double l[] = new double[10];
			double v1, v2;
			try
			{
				for (int i = 0; i < 10; i++)
					l[i] = sc.nextInt();
				v1 = sc.nextInt();
				v2 = sc.nextInt();
			}
			catch (Exception e)
			{
				break;
			}
			double x = total(l) * v1 / (v2 + v1);
			double subtotal = 0;
			for (int i = 0; i < l.length; i++)
			{
				subtotal += l[i];
				if (x <= subtotal)
				{
					System.out.println(i + 1);
					break;
				}
			}
		}
	}
	private static double total(double a[])
	{
		double ret = 0;
		for (int i = 0; i < a.length; i++)
		{
			ret += a[i];
		}
		return ret;
	}
}

Measured memory_bytes: 12000
from typing import List


class Dice:

    def __init__(self, surface: List[int]):
        self.surface = surface

    def get_upper_sursurface(self) -> int:
        return self.surface[0]

    def invoke_method(self, mkey: str) -> None:
        if mkey == 'S':
            self.S()
            return None
        if mkey == 'N':
            self.N()
            return None
        if mkey == 'E':
            self.E()
            return None
        if mkey == 'W':
            self.W()
            return None
        raise ValueError(f'This method does not exist. : {mkey}')

    def S(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[4]
        self.surface[1] = tmp[0]
        self.surface[2] = tmp[2]
        self.surface[3] = tmp[3]
        self.surface[4] = tmp[5]
        self.surface[5] = tmp[1]

    def N(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[1]
        self.surface[1] = tmp[5]
        self.surface[2] = tmp[2]
        self.surface[3] = tmp[3]
        self.surface[4] = tmp[0]
        self.surface[5] = tmp[4]

    def E(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[3]
        self.surface[1] = tmp[1]
        self.surface[2] = tmp[0]
        self.surface[3] = tmp[5]
        self.surface[4] = tmp[4]
        self.surface[5] = tmp[2]

    def W(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[2]
        self.surface[1] = tmp[1]
        self.surface[2] = tmp[5]
        self.surface[3] = tmp[0]
        self.surface[4] = tmp[4]
        self.surface[5] = tmp[3]


# 提出用
data = [int(i) for i in input().split()]
order = list(input())

# # 動作確認用
# data = [int(i) for i in '1 2 4 8 16 32'.split()]
# order = list('EESWN')

dice = Dice(data)
for o in order:
    dice.invoke_method(o)
print(dice.get_upper_sursurface())



Measured memory_bytes: 7188
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll a;
	ld x;
	cin >> a >> x;
	ll q = a * x;
	cout << q;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N >> M;
	vl A(M);
	ll sum = 0;
	for (i = 0; i < M; i++) { cin >> A[i]; sum += A[i]; }
	if (sum > N) {
		cout << -1;
	}
	else {
		cout << N - sum;
	}
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int[] a = new int[3];
        int[] b = new int[3];
        int[] path = new int[4];
        for (int i = 0; i < 3; i++)
        {
            int[] input = ReadInts();
            //a[i] = input[0];
            //b[i] = input[1];
            path[input[0] - 1]++;
            path[input[1] - 1]++;
        }
        for(int i=0;i<4;i++)
        {
            if (path[i] >= 3) return "NO";
        }
        //Console.WriteLine(string.Join(", ", path));
        return "YES";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, M;
    cin >> N >> M;
    vector<int> accepted(N, 0);
    vector<int> wrong(N, 0);
    int ACnum = 0;
    while (M--) {
        int p;
        string S;
        cin >> p >> S;
        p--;
        if (S == "AC") {
            if (accepted.at(p)) continue;
            accepted.at(p) = 1;
            ACnum++;
        } else {
            if (accepted.at(p)) continue;
            wrong.at(p)++;
        }
    }
    int WAnum = 0;
    for (int i = 0; i < N; ++i) {
        if (accepted.at(i)) {
            WAnum += wrong.at(i);
        }
    }
    cout << ACnum << ' ' << WAnum << endl;

    return 0;
}

Measured memory_bytes: 1024