akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<lint> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    // dp[i][0]:i日目にa,dp[i][1]:i日目にb,dp[i][2]:i日目にc
    vector<vector<lint>> dp(n, vector<lint>(3, -1));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }
template<typename T>
void fin(std::vector<T>const& t, char delim=' '){
  if(t.size() > 0) {
    for(int i = 0; i < t.size() -1; ++i) std::cout << t[i] << delim;
    std::cout << t.back();
  }
  std::cout << std::endl; 
  exit(0);
}

int const MAXN = 2e5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; int64_t K; std::cin >> N >> K;
  std::vector<int> A(N+N);
  for(int i = 0; i < N; ++i) { std::cin >> A[i]; A[N+i] = A[i]; }
  std::vector<int> prev(MAXN+1, -1);
  std::vector<int> nx(N);
  for(int i = 0; i < N+N; ++i) {
    int p = prev[A[i]];
    if(0 <= p && p < N) nx[p] = i%N+1;
    prev[A[i]] = i;
  }
  int l = 0;
  for(int p = 0;;) {
    if(nx[p] <= p+1) ++l;
    p = nx[p];
    if(p >= N) ++l, p -= N;
    if(p==0) break;
  }
  K%=l;
  if(K == 0) fin("");
  int p = 0;
  for(;;) {
    if(K <= 1) break;
    if(nx[p] <= p+1) --K;
    p = nx[p];
  }
  int ans = -1;
  while(p < N) {
    if(nx[p] <= p+1) {
      if(ans >= 0) std::cout << ans << " ";
      ans = A[p];
      ++p;
    } else p = nx[p];
  }
  if(ans >= 0) std::cout << ans;
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 4608
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[81];
	rep(i, N) cin >> A[i];
	ll kotae = 1000;

	int mae = A[0];
	rep(i, N) {
		if (mae >= A[i]) {
			mae = A[i];
		}
		else {
			while (i < N && A[i - 1] <= A[i]) {
				i++;
			}
			kotae = kotae % mae + kotae / mae * A[i - 1];
			mae = A[i];
		}

	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(tokenizer.nextToken());
        BigInteger bigDecimal = BigInteger.valueOf(k);
        for (int i = 1; i < n; i++) {
            bigDecimal = bigDecimal.multiply(BigInteger.valueOf(k - 1));
        }
        System.out.println(bigDecimal);
    }
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n, k;
   cin>>n>>k;
   bool hav[100]={0};
   rep(i, k){
      int d;
      cin>>d;
      rep(j, d){
         int a;
         cin>>a; a--;
         hav[a]=true;
      }
   }
   int ans=0;
   rep(i, n) if(!hav[i]) ans++;
   cout << ans << endl;
   return 0;
}


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

long long ret;
void func(string s,int n,vector<int>& l){
	if(n == s.size()){
		if(l.size() == 0){
			ret += stoll(s);
		}else{
			long long tmp = 0;
			cerr << s.substr( 0, l[0]) << " ";
			tmp += stoll(s.substr( 0, l[0]));
			for(int i=1;i<l.size();i++){
				cerr << s.substr( l[i-1], l[i]-l[i-1]) << " ";
				tmp += stoll(s.substr( l[i-1], l[i]-l[i-1]));
			}
			cerr << s.substr(l[l.size()-1]) << " ";
			tmp += stoll(s.substr(l[l.size()-1]));
			cerr << endl;
			ret += tmp;
		}
		return;
	}

	func(s,n+1,l);
	l.push_back(n);
	func(s,n+1,l);
	l.pop_back();
}

int main(void){
	string s;
	cin >> s;
	vector<int> l;
	func(s,1,l);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
//
//AtCoder Beginner Contest 140
//B - Buffet
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

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

int main()
{
    int n;

    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n-1) cin >> c[i];

    int ans=0;
    REP(i, n){
        ans += b[a[i]-1];
    }
    REP(i, n-1){
        if (a[i+1] - a[i] == 1){
            ans+=c[a[i]-1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

ans = 0

for i in range(n):
    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)


Measured memory_bytes: 23328
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n:usize,
        a:[usize; n],
        q:usize,
        bc: [(usize, usize); q]
    }
    let mut d_num = vec![0; 100001];
    let mut current_sum: usize = a.iter().sum();
    for aa in a {
        d_num[aa] += 1;
    }
    for (b, c) in bc {
        let diff = c as isize - b as isize;
        let diff_sum = diff * d_num[b];
        current_sum = (current_sum as isize + diff_sum) as usize;
        println!("{}", current_sum);
        d_num[c] += d_num[b];
        d_num[b] = 0;
    }

}


Measured memory_bytes: 6840
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    if (N / 100 == N % 10){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

int main(){
	int A,B;
	cin >> A >> B;
	if(A > 12){
		cout << B << endl; 
	}
	else if(A < 6){
		cout << 0 << endl;
	}
	else{
		cout << B/2 << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = [int(item) for item in input().split()]
A = [int(item) for item in input().split()]


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


d_cand = make_divisors(sum(A))
d_cand.sort()
d_cand.reverse()

for d in d_cand:
    r = [a % d for a in A]
    rp_sum = sum(r)
    rm_sum = 0
    if rp_sum % d != 0:
        continue
    r.sort()

    for i in range(N):
        # index i まで r-, i+1から r+
        rp_sum -= r[i]
        rm_sum += r[i]

        n_min = max(0, -(rm_sum + rp_sum) / d + (N - i - 1))
        n_max = (K - rm_sum) / d
        if n_min <= n_max and (n_min % 1 == 0 or n_max % 1 == 0 or int(n_min) != int(n_max)):
            print(d)
            break
    else:
        continue
    break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N, R;
  cin >> N >> R;

  if(N<10){
    R = R + (100 * (10 - N)); 
  }
  else ;
 
  cout<<R<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}

Measured memory_bytes: 3560
N, K = map(int, input().split())
mod = 998244353
lr = []
for k in range(K):
    lr.append(list(map(int, input().split())))
dp = [0]*(2*N+1)
dp[0] = 1
dpsum = 0
for i in range(N):
    dpsum += dp[i]%mod
    for k in lr:
        l = k[0]
        r = k[1]

        dp[i+l] += dpsum%mod
        dp[i+r+1] -= dpsum%mod
        
print(dp[N-1]%mod)

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

#define ll long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll mod = 1000000007;
ll INF = 1e9 + 5;

int main(){
    FAST;
    ll n;
    cin >> n;
    vector<int> dp(3,0);
    for(int i=0;i<n;i++)
    {
      vector<int> a(3);
      for(int i=0;i<3;i++)
      {
        cin >> a[i];
      }
      vector<int> newdp(3,0);
      for(int i=0;i<3;i++)
      {
        for(int j=0;j<3;j++)
        {
          if(i != j)
          {
              newdp[j] = max(newdp[j],dp[i]+a[j]);
          }
        }
      }
      dp = newdp;
    }
    cout << max(dp[0],max(dp[1],dp[2])) << endl;
    return 0;
}


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

char F[102][102];

void DFS(int Y,int X,char c){
  if(F[Y][X]!=c){
    return;
  }

  F[Y][X] = '0';

  DFS(Y-1,X  ,c);
  //DFS(Y-1,X+1,c);
  DFS(Y  ,X+1,c);
  //DFS(Y+1,X+1,c);
  DFS(Y+1,X  ,c);
  //DFS(Y+1,X-1,c);
  DFS(Y  ,X-1,c);
  //DFS(Y-1,X-1,c);
}

int main(){
  while(1){
  int N,M;
  cin >> N >> M;
  if(N==0&&M==0)
    break;

  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      cin>>F[h][w];
    }
  }

  int cnt=0;
  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      if(F[h][w]=='@'){
        cnt++;
        DFS(h,w,'@');
      }else if(F[h][w]=='#'){
        cnt++;
        DFS(h,w,'#');
      }else if(F[h][w]=='*'){
          cnt++;
          DFS(h,w,'*');
      }
    }
  }
  cout<<cnt<<endl;
}
  return 0;
}



Measured memory_bytes: 3352
fun main(args: Array<String>) {
    abc143d()
}

fun abc143d() {
    val n = readLine()!!.toInt()
    val lines = readLine()!!.split(" ").map { it.toInt() }
        .sorted().toIntArray()

    var answer = 0
    for (ai in 0..lines.size - 3) {
        for (bi in ai + 1..lines.size - 2) {
            for (ci in bi + 1..lines.size - 1) {
                val a = lines[ai]
                val b = lines[bi]
                val c = lines[ci]

                if (a < b + c && b < a + c && c < a + b) answer++
            }
        }
    }

    println(answer)
}


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

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

int main(){
  ll N;cin>>N;
  ll i,j;
  vector<ll> a(N+1);
  repn(i,N) cin>>a[i];
  vector<ll> ans(N+1);
  if(N==1){
    if(a[1]==1){
      cout<<1<<endl;
      cout<<1<<endl;
    }
    else cout<<0<<endl;
    return 0;
  }
  if(N==2){
    if(a[1]==a[2]==1){
      cout<<1<<endl;
      cout<<2<<endl;
    }
    else if(a[1]==1 and a[2]==0){
      cout<<1<<endl;
      cout<<1<<endl;
    }
    else if(a[1]==0 and a[2]==1){
      cout<<2<<endl;
      cout<<1<<" "<<2<<endl;
    }
    else cout<<0<<endl;
    return 0;
  }

  ll left=(N+2)/2,right=N;
  for(i=left;i<=right;i++){
    ans[i]=a[i];
  }
  right=left-1;
  left=(left+2)/2;
  //後ろから数字を入れてく
  while(left>2){
    // cout<<left<<" "<<right<<endl;
    for(i=left;i<=right;i++){
      ll tmp=0;
      j=2*i;
      while(j<=N){
        tmp+=ans[j];
        j+=i;
      }
      // if(i==4) cout<<tmp<<endl;
      if(tmp%2==a[i]) ans[i]=0;
      else ans[i]=1;
    }
    right=left-1;
    left=(left+2)/2;
  }
  //ans[2]の入れ込み
  ll tmp2=0;
  for(i=4;i<=N;i+=2){
    tmp2+=ans[i];
  }
  if(tmp2%2!=a[2]) ans[2]=1;

  ll M=0;
  repn(i,N){
    M+=ans[i];
  }
  //ans[1]の入れ込み
  if(M%2!=a[1]){
    ans[1]=1;M++;
  }
  cout<<M<<endl;
  repn(i,N){
    if(ans[i]==1) cout<<i<<" ";
  }
  if(M>0) cout<<endl;
}


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

int main(void){
	int k,i;
  	char s[101];
    scanf("%d",&k);
    scanf("%s",s);
  	if(strlen(s)>k){
      for(i=0;i<k;i++){
      	printf("%c",s[i]);
      }
      printf("...");
    }else{
      	printf("%s",s);
    }
  return 0;
}

Measured memory_bytes: 1700
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits



def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))

def update(bit,i, dp):
    bit[i] = dp
    return bit

def query(bit, i):
    lis = [bit[j] for j in range(i)]
    return max(lis)


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n,m=MAP()

py = [LIST() for _ in range(m)]
py = [[i,x[0],x[1]] for i,x in enumerate(py)]
lis=deepcopy(py)
lis.sort(key=lambda x: (x[1], x[2]))

ans = [""] * m

tmp=1
ct = 1

for x in lis:
    if tmp!=x[1]:
        tmp = x[1]
        ct = 1
    ans[x[0]] = '{:06}{:06}'.format(x[1], ct)
    ct += 1
        
for x in ans:
    print(x)

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

int top,s[100];

int pop();
void push(int);

int main(){
  int x,y,a;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if ( s[0] == '-' ){
      x = pop();
      y = pop();
      push(y - x);
    }
    else if ( s[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      a = atoi(s);
      push(a);
    }
  }
  printf("%d\n",pop());
  return 0;
}


int pop(){
  top--;
  return s[top+1];
}

void push(int x){
  top++;
  s[top] = x;
}




Measured memory_bytes: 2052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0X3f3f3f3f
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=50000+10;
int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL a[1005],b[1005],cna = 0,cnb = 0,tot = 1;
LL n,c[1005],cnc = 0;

int main(){
	ios::sync_with_stdio(false);
	cin >> n; n ++;
	while(n){
		c[++ cnc] = n & 1;
		n >>= 1;
	}
	
	b[++ cnb] = 1;
	for(LL i = cnc - 1;i >= 1;i --){
		if(c[i]) a[++ cna] = ++ tot;
		if(i > 1) b[++ cnb] = ++ tot;
	}
	
	cout << tot + 100 << endl;
	for(LL i = cna;i >= 1;i --) cout << a[i] << ' ';
	for(LL i = 1;i <= cnb;i ++) cout << b[i] << ' ';
	for(LL i = 1;i <= 100;i ++) cout << i << (i == 100 ? '\n' : ' ');
	return 0;
}
// 太难了

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0162 Hamming Numbers

#include <stdio.h>

int hamming(int n)
{
    while (n % 2 == 0){
        n /=  2;
    }

    while (n % 3 == 0){
        n /=  3;
    }

    while (n % 5 == 0){
        n /=  5;
    }
    
    if (n == 1){
        return (1);
    }
    return (0);
}

int main(void)
{
    int m, n;
    int i;
    int cnt;
    
    while (1){
        scanf("%d", &m);
        if (m == 0){
            break;
        }
        scanf("%d", &n);
        
        cnt = 0;
        for (i = m; i <= n; i++){
            cnt += hamming(i);
        }
        printf("%d\n", cnt);
    }
    
    return (0);
}

Measured memory_bytes: 404
using System;

public class dice
{
    private int[] data;
    public dice(string s = "1,5,6,4,2,3")
    {
        data = new int[6];
        string[] line = s.Split(',');
        for (int i = 0; i < 6; i++)
            data[i] = int.Parse(line[i]);

        // 0: ceilling 1: front 2: floor 3:right:4:back:5:left
    }
    public void roll(char c)
    {
        var w = new int[6];
        Array.Copy(data, w, 6);
        if (c == 'U' | c == 'N') { data[4] = w[0]; data[0] = w[1]; data[1] = w[2]; data[2] = w[4]; }
        else if (c == 'D' | c == 'S') { data[1] = w[0]; data[2] = w[1]; data[4] = w[2]; data[0] = w[4]; }
        else if (c == 'R' | c == 'E') { data[3] = w[0]; data[5] = w[2]; data[2] = w[3]; data[0] = w[5]; }
        else { data[5] = w[0]; data[3] = w[2]; data[0] = w[3]; data[2] = w[5]; }
    }
    public int peek(int n) => data[n];
}

public class hello
{
    public static void Main()
    {
        var b0 = "013542";
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = new int[6];
        for (int i = 0; i < 6; i++)
            b[b0[i] - '0'] = a[i];
        var d = new dice(string.Join(",", b));
        line = Console.ReadLine().Trim().Split(' ');
        a = Array.ConvertAll(line, int.Parse);
        for (int i = 0; i < 6; i++)
            b[b0[i] - '0'] = a[i];
        var d2 = new dice(string.Join(",", b));
        Console.WriteLine(getAns(d, d2) ? "Yes" : "No");
    }
    static bool getAns(dice d, dice d2)
    {
        var ok = false;
    again:;
        for (int i = 0; i < 4; i++)
        {
            d.roll('D');
            if (d.peek(0) == d2.peek(0)) { ok = true; break; }
        }
        if (!ok) { d.roll('R'); goto again; }
        var da = "";
        var db = "";
        var w = new int[] { 1, 3, 4, 5 };
        for (int i = 0; i < 4; i++) da += d.peek(w[i]).ToString();
        for (int i = 0; i < 4; i++) db += d2.peek(w[i]).ToString();
        db += db;
        return db.IndexOf(da) != -1;
    }
}



Measured memory_bytes: 18536
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS

    constexpr int INF = 5e8;
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> v(r);
    REP(i,r) {
        cin >> v[i];
        v[i]--;
    }
    sort(ALL(v));

    vector<vector<int>> road(n,vector<int>(n,INF));
    REP(i,n) road[i][i] = 0;

    REP(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        road[a][b] = min(c,road[a][b]);
        road[b][a] = min(c,road[b][a]);
    }

    // ワーシャルフロイド法
    REP(i,n) REP(j,n) REP(k,n) {
        road[j][k] = min(road[j][k], road[j][i] + road[i][k]);
    }

    // 全通り試行
    auto v2 = v;
    int ans = INF;
    do {
        int cost = 0;
        for (int i = 0; i < r-1;i++) {
            cost += road[v2[i]][v2[i+1]];
            if (ans < cost) break;
        }
        if (ans > cost) ans = cost;
    } while(next_permutation(ALL(v2)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())
 
    a = [init] * n
    b = [init] * ((n // 100) + 1)
 
    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])
 
 
main()

Measured memory_bytes: 11216
perfect_squares = set(i**2 for i in range(1, 128))

n, d = (int(x) for x in input().split())
points = []
for _ in range(n):
  points.append([int(x) for x in input().split()])
ans = 0
for i in range(n-1):
  for j in range(n-i-1):
    nn = 0
    for dim in range(d):
        nn += (points[i][dim] - points[j+1+i][dim]) ** 2
    if nn in perfect_squares:
        ans += 1
print(ans)

Measured memory_bytes: 3064
//

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    int r_count = 0;
    int b_count = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r_count++;
        } else {
            b_count++;
        }
    }

    if (r_count > b_count) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    string ans = "No";
    int x = 0;
    int y = 0;
    int z = 0;
    if (n%2==1) x++;
    rep(i, n) {
        if (a[i]%4==0) x++;
        else if (a[i]%2==0) y++;
        else z++;
    }
    if (z<=x) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=110;
const int MAXS=110000;
const long long INF=1E18;
int w[MAXN], v[MAXN];
long long f[MAXN][MAXS];
int main()
{
//	freopen("E.in", "r", stdin);
//	freopen("E.out", "w", stdout);
	int n, m, s=0;
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; i++)
		scanf("%d%d", &w[i], &v[i]), s+=v[i];
	for (int i=1; i<=s; i++) f[0][i]=INF;
	for (int i=1; i<=n; i++)
		for (int j=0; j<=s; j++)
		{
			f[i][j]=f[i-1][j];
			if (j>=v[i]) f[i][j]=min(f[i][j], f[i-1][j-v[i]]+w[i]);
		}
	for (int i=s; i>=0; i--)
		if (f[n][i]<=m)
		{
			printf("%d\n", i);
			break;
		}
	return 0;
}

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

int main()
{
    string s, t; 
    cin >> s;
    cin >> t;
    int counter=0;
    for (int i = 0; i < t.length(); i++)
    {
        if(t[i] == s[i])
            continue;
        else
            counter++;
    }
    cout << counter;
    
}

Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
#define INF INT_MAX
int n,m;
vector<int> d;
vector<int> c;
vector< vector<int> > dp;

void solve(int nisu,int shi){
  if(nisu>0) dp[shi][nisu] = min(dp[shi][nisu],dp[shi][nisu-1]);
  if(nisu<m && shi<n){
    dp[shi][nisu+1] = min(dp[shi][nisu+1],dp[shi][nisu]);
    dp[shi+1][nisu+1] = min(dp[shi+1][nisu+1],dp[shi][nisu]+c[nisu]*d[shi]);
    solve(nisu+1,shi);
    if(dp[shi+1][nisu] == INF) solve(nisu+1,shi+1);
    
  }
}



int main (){
  cin >>n>>m;
  d.resize(n);
  c.resize(m);
  dp.resize(n+1);
  for(int i=0;i<=n;i++){
    dp[i].resize(m+1);
    for(int j=0;j<=m;j++) dp[i][j] = INF;
  }
  for(int i=0;i<n;i++) cin >> d[i];
  for(int i=0;i<m;i++) cin >> c[i];
  dp[0][0] = 0;
  solve(0,0);
  int ans = INF;
  for(int i=0;i<=m;i++) ans=min(ans,dp[n][i]);
  
  //for(int i=0;i<=m;i++){
  //for(int j=0;j<=n;j++) cout << dp[j][i]<<" ";
  //cout<< endl;
  //}
  cout << ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4440
N=int(input())
A=list(map(int,input().split()))
ans=[[0 for i in range(2)] for j in range(N)]

for i in range(N):
    ans[i][0]=A[i]

for i in range(N):
    ans[i][1]=i+1

ANS=sorted(ans)

ans_new=''

for i in range(N):
    ans_new+=str(ANS[i][1])
    ans_new+=' '
    
print(ans_new)

Measured memory_bytes: 24676
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s1,s2;
	while(cin>>s1>>s2){
		int ans=0;
		for(int i=0;i<s1.size();i++){
			while(true){
				if(i+ans>=s1.size())break;
				if(s2.find(s1.substr(i,ans+1),0)!=string::npos)ans++;
				else break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 1216
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	int M;
	int t[N];
	//int p[M];
	//int x[M];
	cin >> N;

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> t[i];
		sum += t[i];
	}

	cin >> M;
	std::vector<int> v;
	for (int i = 0; i < M; i++)
	{
		//cin >> p[i] >> x[i];
		//p[i]--;

		//v.pb( sum - t[p[i]] + x[i] );
		int tmp_p, tmp_x;
		cin >> tmp_p >> tmp_x;
		tmp_p--;
		v.pb(sum - t[tmp_p] + tmp_x);
	}

	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;
const int base=311;

string s;
ll Hash=0,res=0,Hash1=-1;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
   // freopen(task".inp","r",stdin);
   // freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>s;
    for (int i=0;i<s.length();i++) {
        Hash=(Hash*base+s[i]-'a'+1)%inf;
        if (Hash!=Hash1) {
            res++;
            Hash1=Hash;
            Hash=0;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 720
def prime_factors(n):
    d = {}
    while n%2 == 0:
        d[2] = d.get(2, 0) + 1
        n //= 2
    i = 3
    while i*i <= n:
        while n%i == 0:
            d[i] = d.get(i, 0) + 1
            n //= i
        i += 2
    if n > 2:
        d[n] = d.get(n, 0) + 1
    return d

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
G = {}
for a in A:
    pf = prime_factors(a)
    for k,v in pf.items():
        G[k] = max(G.get(k, 0), v)
lcm = 1
for k,v in G.items():
    lcm *= pow(k, v, MOD)
    lcm %= MOD
ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD) % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define INF (1 << 10)

typedef pair<int, int> P;

int main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector< vector<int> > cost(n, vector<int>(n, INF));
		vector< vector<int> > connect(n, vector<int>(n, 0));

		for (int i = 0; i < n; ++i)
			cost[i][i] = 0;

		for (int i = 0; i < m; ++i) {
			int a, b, c; cin >> a >> b >> c;
			--a, --b;
			cost[a][b] = cost[b][a] = c;
			connect[a][b] = connect[b][a] = 1;
		}

		vector< vector<int> > prev(n, vector<int>(n));

		for (int i = 0; i < n; ++i)
			for(int j = 0 ; j < n ; j++)
				prev[i][j] = i;

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				for (int k = 0; k < n; ++k)
					if (cost[j][i] + cost[i][k] < cost[j][k]) {
						prev[j][k] = prev[i][k];
						cost[j][k] = cost[j][i] + cost[i][k];
					}

		int ans = cost[0][n-1];

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j) {
				bool flag = false;
				for (int k = 0; k < n; ++k)
					if (connect[i][k] && connect[k][j])
						flag = true;

				if (!flag) continue;

				ans = min( ans, cost[0][i] + cost[j][n-1] );
			}


		cout << ans << endl;
/*
		// 経路復元
		int from = 0, to = n-1;
		vector<int> v;
		v.push_back(from);
		while (from != to) {
			from = prev[to][from];
			v.push_back(from);
		}

		// 逆関数
		map<int, int> pos;
		for (int i = 0; i < v.size(); ++i)
			pos[v[i]] = i+1;

		// 累積和
		int s = 0;
		vector<int> sum;

		sum.push_back(0);
		for (int i = 0; i < v.size()-1; ++i) {
			s += cost[v[i]][v[i+1]];
			sum.push_back(s);
		}

		int ans = sum[n-1];
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j) {
				if (!pos[i]) continue;
				if (pos[i] >= pos[j]) continue;

				bool flag = false;
				for (int k = 0; k < n; ++k)
					if (connect[i][k] && connect[k][j])
						flag = true;

				if (!flag) continue;

				ans = min( ans, sum[i] + cost[j][n-1] );
			}

		cout << ans << endl;
*/
/*
		vector<P> koho;
		for (int i = 0; i < n; ++i)
			for (int j = i+1; j < n; ++j)
				for (int k = 0; k < n; ++k)
					if (i != j && connect[i][k] && connect[k][j])
						koho.push_back( P(i, j) );

		koho.erase( unique( koho.begin(), koho.end() ), koho.end() );

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				for (int k = 0; k < n; ++k)
					if (cost[i][k] + cost[k][j] < cost[i][j])
						cost[i][j] = cost[i][k] + cost[k][j];

		int ans = cost[0][n-1];
		for (int x = 0; x != koho.size(); ++x) {
			vector< vector<int> > c = cost;
			c[koho[x].first][koho[x].second] = c[koho[x].second][koho[x].first] = 0;
			for (int i = 0; i < n; ++i)
				for (int j = 0; j < n; ++j)
					for (int k = 0; k < n; ++k)
						if (c[i][k] + c[k][j] < c[i][j])
							c[i][j] = c[i][k] + c[k][j];

			if (c[0][n-1] < ans) ans = c[0][n-1];
		}
*/

	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;
int main(){
  ll h,w;
  cin >> h >> w;
  if(h==1||w==1)cout << 1 << endl;
  else if(h%2==1&&w%2==1)cout << h*w/2LL + 1 << endl;
  else cout << h*w/2LL << endl;
}


Measured memory_bytes: 256
def ABC_89_B():
    N=int(input())
    s = input().split()
    l = ['P','W','G','Y']
    c=0
    for i in range(len(l)):
        if s.count(l[i])>=1:
            c+=1

    if c==3:
        print('Three')
    else:
        print('Four')

if __name__ == '__main__':

    ABC_89_B()

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N, p[101010];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> p[j];
    }

    int ans = 0;
    if (p[0] == 1) {
        ++ans;
        swap(p[0], p[1]);
    }
    for (int j = 1; j < N; ++j) {
        if (p[j] == j+1) {
            ++ans;
            if (j+1 < N && p[j+1] == j+2) {
                swap(p[j], p[j+1]);
            } else {
                swap(p[j-1], p[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<bool>> a(N, vector<bool>(N, false));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            char tmp;
            cin >> tmp;
            if(tmp == '.') a[i][j] = false;
            else a[i][j] = true;
        }
    }

    // 元々全部白いなら塗れない
    int cnt = 0;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            if(a[i][j]) cnt++;
    if(cnt == 0){
        cout << -1 << endl;
        return 0;
    }

    // 全てが黒い列の数
    cnt = 0;
    for(int j=0; j<N; j++){
        int tmp = 0;
        for(int i=0; i<N; i++)
            if(a[i][j]) tmp++;
        if(tmp == N) cnt++;
    }
    
    // すぐに黒く塗れる行
    vector<bool> vec(N, false);
    for(int j=0; j<N; j++){
        for(int i=0; i<N; i++){
            if(a[i][j]) {
                vec[j] = true;
                break;
            }
        }
    }

    // i行目で黒い場所の数の最大値
    // ただし、vecにないなら準備として+1かかる
    int blk = 0;
    for(int i=0; i<N; i++){
        int tmp = 0;
        for(int j=0; j<N; j++){
            if(a[i][j]) tmp++;
        }
        if(vec[i])
            blk = max(blk, tmp);
        else
            blk = max(blk, tmp-1);
    }

    int ans = N - blk + N - cnt;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
int main(void){
int n,x,y,ans;
  scanf("%d",&n);
  ans=0;
  for(int i=0;i<n;i++){
   scanf("%d",&y);
    if(i>0){
     if(x==y){
      ans++;
       y=0;
     }
    }
    x=y;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	int i,j;
	int MaxL=0;
	int num=0;
	for (i=0;i<S.size();i++){
		num=0;
		for (j=i;j<S.size();j++){
			switch(S[j]){
				case 'A':
				case 'C':
				case 'G':
				case 'T':
					num++;
					break;
				default:
					if (MaxL<num){
						MaxL=num;
					}
					num=0;
					break;
			}
			if (num==0){
				break;
			}
		}
		if (MaxL<num){
			MaxL=num;
		}
	}

	cout<<MaxL<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<double,P> P2;

const double EPS = 1e-6;
P v[3];

double cross(P a, P b){ return imag(conj(a)*b);}

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  return m.first + B / A * (m.second - m.first);
}

double areaV(){
  double sum = 0.0;
  for(int i=0;i<3;i++) sum += (real(v[i]) - real(v[(i+1)%3])) * (imag(v[i]) + imag(v[(i+1)%3]));
  return abs(sum) / 2.0;
}

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

P2 check2(P2 p, int pos){
  double le = 0.1, ri = 2.0 * areaV() / (abs(v[1]-v[0]) + abs(v[2]-v[1]) + abs(v[0]-v[2]));
  L l[2];
  P2 res;
  for(int i=0;i<1000;i++){
    double mid = (le + ri) / 2.0;

    for(int j=pos;j<pos+2;j++){
      P a = (v[(j+1)%3]-v[j%3]) * mid / abs(v[(j+1)%3]-v[j%3]);
      P b = rotate(a, M_PI/2.0);
      l[j-pos] = L(v[(j+1)%3]+b, v[j%3]+b);
    }
    res = P2(mid, crossPoint(l[0],l[1]));

    if(equal(abs(res.second-p.second), res.first+p.first)) return res;
    else if(abs(res.second-p.second) < res.first+p.first) ri = mid;
    else le = mid;
  }
}

int check(double r, int pos){
  L l[2];
  P2 p[3];
  for(int i=0;i<2;i++){
    P a = (v[i+1]-v[i]) * r / abs(v[i+1]-v[i]);
    P b = rotate(a, M_PI/2.0);
    l[i] = L(v[i+1]+b, v[i]+b);
  }
  p[0] = P2(r, crossPoint(l[0],l[1]));


  for(int i=1;i<3;i++) p[i] = check2(p[0], i);

  if(pos == 999 || equal(abs(p[2].second-p[1].second), p[2].first+p[1].first)){
    printf("%.6f %.6f %.6f\n",p[2].first, p[0].first, p[1].first);
    return 1;
  }
  else if(abs(p[2].second-p[1].second) < p[2].first+p[1].first) return 2;
  else return 0;
  
}

void solve(){
  double le = 0.1, ri = 2.0 * areaV() / (abs(v[1]-v[0]) + abs(v[2]-v[1]) + abs(v[0]-v[2]));
  for(int i=0;i<1000;i++){
    double mid = (le + ri) / 2.0;
    int res = check(mid,i);
    if(res == 0) ri = mid;
    else if(res == 2) le = mid;
    else return;
  }
}

int main(){
  int x[3],y[3];
  while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] && (x[0]|y[0]|x[1]|y[1]|x[2]|y[2])){
    for(int i=0;i<3;i++) v[i] = P((double)x[i], (double)y[i]);
    solve();
  }
}

Measured memory_bytes: 1220
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <ctime>
#include <cmath>

using namespace std;

int main() {

    int num;
    cin>>num;
    vector<int> vec;
    for(int i = 0; i < num; ++i){
        int s;
        cin>>s;
        vec.push_back(s);
    }

    sort(vec.begin(), vec.end());

    int sum = 0;
    int mv = 0;
    for(int i = 0; i < vec.size(); ++i){
        sum += vec[i];
        if(mv == 0 && vec[i]%10 != 0)
            mv = vec[i];
    }

    if(sum %10 != 0)
        cout<<sum<<endl;
    else if(mv != 0)
        cout<<sum-mv<<endl;
    else
        cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int numa;
int a[100];
int res;

int solve(int i, int m) {

	if (m == 0) {
		return 1;
	}
	if (i >= numa) {
		return 0;
	}
	res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	return res;

}

int main(void)
{
	int numb, i, key;

	scanf("%d", &numa);

	for (i = 0; i < numa; i++) {
		scanf("%d", &a[i]);
	}

	scanf("%d", &numb);
	
	for (i = 0; i < numb; i++) {
		scanf("%d", &key);
		if ( solve(0, key)) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 1964
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    map<string, int> mm;
    int n, m;
    cin >> n;
    rep(i, n)
    {
        string str;
        cin >> str;
        mm[str]++;
    }
    cin >> m;
    rep(i, m)
    {
        string str;
        cin >> str;
        mm[str]--;
    }
    int ans = 0;
    for (auto i = mm.begin(); i != mm.end(); i++)
    {
        if (i->second > ans)
        {
            ans = i->second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[500000];

ll comb(ll a, ll b) {
  ll ans = frac[a];
  ll sh1, sh2;
  ll h=mod-2;
  ll two;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh1 %= mod;
      sh2 *= sh2;
      sh2 %= mod;
    }
    ans *= sh1*sh2%mod;
    ans %= mod;
    h -= two;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<500000;++i) frac[i] = frac[i-1]*i%mod;
  ll N, M;
  cin>>N>>M;
  vector<ll> prime;
  map<ll, ll> amap;
  for(ll i=2;i*i<=M;++i) {
    if(M%i==0) {
      prime.push_back(i);
      while(M%i==0) {
        amap[i]++;
        M /= i;
      }
    }
  }
  if(M>1) {
    prime.push_back(M);
    amap[M]++;
  }
  ll ans = 1;
  for(int i=0;i<prime.size();++i) {
    ans *= comb(N-1+amap[prime[i]], N-1);
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int k,q; cin>>k>>q;
    vector<int> d(k);
    for (int i = 0; i < k; ++i) {
        cin>>d[i];
    }

    for (int i = 0; i < q; ++i) {
        ll n,x,m; cin>>n>>x>>m;
        vector<ll> cnt(k+1,0),ruiseki(k+1,0);
        for (int j = 0; j < k; ++j) {
            cnt[j+1]=cnt[j]+((d[j]%m==0)?1:0);
            ruiseki[j+1]=ruiseki[j]+d[j]%m;
        }
        ll ans=(n-1ll)/k*cnt[k];
        ans+=cnt[(n-1ll)%k];

        ll last=x+(n-1ll)/k*ruiseki[k];
        //cout<<last<<endl;
        last+=ruiseki[(n-1ll)%k];
        //cout<<last<<endl;
        ll cnt2=last/m-x/m;


        cout<<n-1-ans-cnt2<<endl;
    }

    return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
const int mod=1e9+7;

int a[maxn];
int main()
{
	ll k; cin>>k;
	ll m,n;
	m=k/50; n=k%50;
 
	//N-1+m*1;
	//剩余n步伐
	vc<ll> ans;
	ll x=50-1+m;
	for(int i=0;i<n;++i)
	{
		ans.push_back(x+50-n+1);
	}
	for(int i=0;i<(50-n);++i)
	{
		ans.push_back(x-n);
	}
	cout<<50<<endl;
	for(int i=0;i<50;++i)
	{
		cout<<ans[i]<<" ";
	}
//	int p=ans.size();
	//dbg(p);
}


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

int main(){
    
    int n;
    cin >> n;
    vector<int> a(n),b(n+1),c(n);
    long long int sum=0;

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    for(int i=1; i<n; i++){
        b.at(i)=abs(a.at(i)-a.at(i-1));
    }
    b.at(0)=abs(a.at(0));
    b.at(n)=abs(a.at(n-1));

    for(int i=0; i<=n; i++){
        sum+=b.at(i);
    }

    for(int i=1; i<n-1; i++){
        c.at(i)=abs(a.at(i+1)-a.at(i-1));
    }
    c.at(0)=abs(a.at(1));
    c.at(n-1)=abs(a.at(n-2));

    long long int ans;
//    cout << sum << endl;
    for(int i=0; i<n; i++){
        //cout << b.at(i) << ' ' << b.at(i+1) << ' ' << c.at(i) << endl;
        ans=sum-b.at(i)-b.at(i+1)+c.at(i);
        cout << ans << endl;
    }
}

Measured memory_bytes: 4564
var
	n:Longint;
function f(x:int64;a,b,c:Longint):Longint;
begin
	f:=0;
	if x<=n then f:=a*b*c+f(x*10+3,1,b,c)+f(x*10+5,a,1,c)+f(x*10+7,a,b,1);
end;
begin
	read(n);
	if n>700000000 then begin writeln(17656+f(7,0,0,1));exit;end;
	writeln(f(0,0,0,0));
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main() {
	cin >> s;
	cout << s;
	if (s[s.size() - 1] == 's') {
		cout << "es" << endl;
	}
	else cout << "s" << endl;
	return 0;
}

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

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

    int s = n.size() - 1;
    char c = n.at(s);

    if (c == '2' || c == '4' || c == '5' || c == '7' || c == '9') {
        cout << "hon" << endl;
    }

    else if (c == '0' || c == '1' || c == '6' || c == '8') {
        cout << "pon" << endl;
    }

    else if (c == '3') {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    string S;
    cin >> S;
    bool flg = false;
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
            flg = true;
    }
    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll x,n;
    cin>>x>>n;
    vector<ll> a(102,1);
    for(ll i=0;i<n;i++){
        ll t;
        cin>>t;
        a[t]=0;
    }
    ll ans=0,mx=INF;
    for(ll i=0;i<=101;i++){
        if(a[i]==0) continue;
        if(abs(x-i)<mx){
            ans=i;
            mx=abs(x-i);
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)

map<char,int> mp;
string s;

int main() {
	cin>>s;
	for (char c:s) mp[c]++;
	if ((mp['N']+mp['S']==0||(mp['N']&&mp['S']))&&(mp['W']+mp['E']==0||(mp['W']&&mp['E']))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256