akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        Set<String> gacha = new HashSet<String>();
        
        for(int i=0;i<N;i++){
            gacha.add(sc.next());
        }
        
        System.out.println(gacha.size());
        
    }
}


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

void Main() {
    int n, a;
    cin >> n >> a;
    while (n >= 500) {
        n -= 500;
    }
    if (n <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

// struct tr{
//     int key;
//     int parent;
//     int left;
//     int right;
// };
struct tree{
    int key;
    tree *parent, *left, *right;
};

void assignment(tree &a, tree b){
    a.key = b.key;
    a.parent = b.parent;
    a.left = b.left;
    a.right = b.right;
}

tree *root,*NIL;

void insert(int k){
    tree *y = NIL;
    tree *x = root;
    tree *z;
    z = (tree *)malloc(sizeof(tree));
    z->key = k;
    z-> left = NIL;
    z-> right = NIL;
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}
// void ist(vector<tree> &T, tree z){
//     tree y = {-1,-1,-1,-1};
//     tree x;
//     assignment(x, root);
//     while(x.key != -1){
//         assignment(y,x);
//         if(z.key < x.key){
//             x = T[x.left];
//         }else{
//             x = T[x.right];
//         }
//     }
    
//     z.parent = y.key;
//     if(y.key == -1){
//         assignment(root, z);
//     }else if(z.key < y.key){    
//         y.left = z.key;
//     }else{
//         y.right = z.key;
//     }
// }
void preorder(tree *u){
    if (u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}
void inorder(tree *u){
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    for(int i = 0; i < n;i++){
        string order;
        cin >> order;
        if(order == "insert"){
            int num;
            cin >> num;
            insert(num);
        }else{
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    

    return 0;
}


Measured memory_bytes: 26656
/*
  AUTHOR:SOURABH
  CREATED:19:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,i,n;
    string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s;
        n=s.length();
        if(s[n-1]=='s')
            s+="es";
        else
            s+="s";
        cout<<s;
    }
}






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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    string str[n];
    int    b[n], c[n];
    rep(i, n) { cin >> str[i] >> b[i]; }
    rep(i, n) { c[i] = i + 1; }
    // rep(i, n) { cout << str[i] << " " << b[i] << " " << c[i] << endl; }
    string tmps[n];
    int    tmpi[n];

    //文字列ソート
    for (int i = 0; i < n - 1; i++) {
        for (int j = 1 + i; j < n; j++) {
            if (str[i] > str[j]) {
                swap(str[i], str[j]);
                swap(b[i], b[j]);
                swap(c[i], c[j]);
            }
            // tmps[i] = str[i];
            // str[i]  = str[j];
            // str[j]  = tmps[i];
            if (str[i] == str[j] && b[i] < b[j]) {
                swap(str[i], str[j]);
                swap(b[i], b[j]);
                swap(c[i], c[j]);
            }
        }
    }

    // cout << "---" << endl;
    // rep(i, n) { cout << str[i] << " " << b[i] << " " << c[i] << endl; }
    rep(i, n) { cout << c[i] << endl; }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int a[10001];
int ans[105][105];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	cin >> h >> w >> n;
	rep(i, n) {
		int b; cin >> b;
		a[i] = b;
	}
	int cell = 0;
	for (int i = 0; i < h; ++i) {
		if (i % 2 == 0) {
			rep(j, w) {
				ans[i][j] = cell + 1;
				a[cell]--;
				if (a[cell] == 0) cell++;
			}
		}
		else {
			for (int j = w - 1; j >= 0; --j) {
				ans[i][j] = cell + 1;
				a[cell]--;
				if (a[cell] == 0) cell++;
			}
		}
	}
	rep(i, h)rep(j, w) cout << ans[i][j] << (j == w - 1 ? "\n" : " ");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    string s,sd,t;
    int f = 0;
    cin >> sd >> t;
    REP(i,sd.size()-t.size()+1){
        f = 1;
        REP(j,t.size()){
            if (sd[sd.size()-t.size()-i+j]!='?' && sd[sd.size()-t.size()-i+j]!=t[j]) f *= 0;
        }
        if (f) {
            string str = sd;
            string from = "?";
            string to = "a";
            
            string::size_type pos = str.find(from);
            while(pos != string::npos){
                str.replace(pos, from.size(), to);
                pos = str.find(from, pos + to.size());
            }
            
            str.replace(sd.size()-t.size()-i, t.size(), t);
            
            cout << str << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop
from math import gcd

INF = float('inf')
NIL = - 1


K = int(input())

total = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        tmp = gcd(a, b)
        for c in range(1, K + 1):
            total += gcd(tmp, c)

print(total)


Measured memory_bytes: 9584
#include<iostream>
using namespace std;
int n,k,ans;
int bol[100];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>bol[i];
        ans+= (bol[i]<=k-bol[i] ? bol[i]*2:(k-bol[i])*2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int x; cin >> x;
	cout << (x / 11) * 2 + (x % 11 != 0) + (x % 11 > 6) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

ruisekiwa = [0]
ans = n

for i in s:
    if i == "W":
        ruisekiwa.append(ruisekiwa[-1]+1)
    else:
        ruisekiwa.append(ruisekiwa[-1])
        
for i in range(1,n+1):
    w = ruisekiwa[i-1]
    e = n-i-(ruisekiwa[-1]-ruisekiwa[i])
    ans = min(ans,w+e)
    
print(ans)    

Measured memory_bytes: 17484
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n,i;
	cin>>n>>i;
	cout<<n-i+1<<endl;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
from math import gcd
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    A,B = LMIIS()
    print(A*B//gcd(A,B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 62088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

   cout<<(r*r)<<endl;
   return 0;
}


Measured memory_bytes: 3560
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            long resultNum = 0;
            String resultStr = "";

            int n = sc.nextInt();
            int k = sc.nextInt();
            ArrayList<Integer> p = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                p.add(sc.nextInt());
            }
            Collections.sort(p);
            for (int i = 0; i < k; i++) {
                resultNum += p.get(i);
            }
            return resultNum;
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}

Measured memory_bytes: 30236
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n=I()
    h=L()
    for i in reversed(range(1,n)):
        if h[i]<h[i-1]:
            h[i-1]-=1
            if h[i]<h[i-1]:
                print('No')
                exit()
    for i in range(n-1):
        if h[i]>h[i+1]:
            print('No')
            exit()
    print('Yes')

if __name__=='__main__':
    main()

Measured memory_bytes: 14592
#include <stdio.h>

int main(){
  char ch1,ch2;
  int data[3]={1,0,0},i,t;
  while (scanf(" %c, %c",&ch1,&ch2)!=EOF){
    t=data[ch1-'A'];
    data[ch1-'A']=data[ch2-'A'];
    data[ch2-'A']=t;
  }
  for (i=0;i<3;i++)
    if (data[i]==1)
      printf("%c\n",i+'A');
  return 0;
}

Measured memory_bytes: 540
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a = I()
print(a + a ** 2 + a ** 3)

Measured memory_bytes: 76832
//
//  a?c.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265
void dfs(vector<int> A, int n, int m)  {
  if  (A.size() > n) {
    for (int i = 1; i <= n; i++) {
      std::cout << A[i];
    }
    std::cout << std::endl;
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A, n, m);
    A.back()++;
  }
}

int main(int argc, const char* argv[]) {

  std::string s;
  std::cin >> s;

  if (s[1] == 'B') {
    std::cout << "ARC" << std::endl;
  }
  else {
    std::cout << "ABC" << std::endl;
  }
  return 0;
}


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

int main() {
    int n, m, a[100][100], b[100], c[100] = {};
    cin >> n >> m;
    rep(i,n)
        rep(j,m) cin >> a[i][j];
    rep(i,m) cin >> b[i];
    rep(i,n)
        rep(j,m) c[i] += a[i][j]*b[j];
    rep(i,n) cout << c[i] << endl;
}


Measured memory_bytes: 3152
import java.util.Scanner

val sc = Scanner(System.`in`)
val d = sc.nextInt()

fun main(args: Array<String>) {
    println(
        when (d) {
            25 -> "Christmas"
            24 -> "Christmas Eve"
            23 -> "Christmas Eve Eve"
            else -> "Christmas Eve Eve Eve"
        }
    )
}

Measured memory_bytes: 29352
#include<iostream>
#include<vector>
using namespace std; 
vector<long long> L;
int main(void){
    int N,ans = 0;
    cin >> N;
    L = vector<long long>(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                int a=L[i],b=L[j],c=L[k];
                if(a!=b && b!=c && a!=c){
                    if((a+b>c)&&(a+c>b)&&(c+b>a)){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  max_heap<int> x;

  while(1){
    string s;
    cin>>s;
      if(s == "end") break;
      else if(s == "extract"){
        cout<<x.top()<<'\n';
        x.pop();
      }else{
        int a;
        cin>>a;
        x.emplace(a);
      }
  }

  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

FiniteField ParseBinary(string s) {
  FiniteField x = 0;
  for (int d = 0; d < s.size(); d++) {
    x *= 2;
    if (s[d] == '1') x += 1;
  }
  return x;
}

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

  int n;
  string s;
  cin >> n >> s;

  FiniteField x = ParseBinary(s);
  if (DEBUG) cout << "x: " << x.Value() << endl;
  FiniteField sum = (x + 1) * 2 * n;

  vector<int> ls;
  for (int l = 1; l <= n; l++) {
    if (n % l == 0) {
      int d = n / l;
      if (d % 2 ==1 && d >= 3) ls.push_back(l);
    }
  }

  map<int, FiniteField> dp;
  for (int l : ls) {
    int d = n / l;
    if (d % 2 == 0) continue;
    if (d == 1) continue;
    if (DEBUG) cout << "l: " << l << endl;
    string t = s.substr(0, l);
    FiniteField y = ParseBinary(t);
    FiniteField count = y;
    string tr = t;
    for (int i = 0; i < tr.size(); i++) {
      if (tr[i] == '1') tr[i] = '0';
      else tr[i] = '1';
    }
    string u = "";
    for (int i = 0; i < d; i++) {
      if (i % 2 == 0) u.append(t);
      else u.append(tr);
    }
    if (DEBUG) cout << "u: " << u << endl;
    if (u <= s) {
      count += 1;
    }
    if (DEBUG) cout << "count before ajudst: " << count.Value() << endl;

    for (int c : ls) {
      if (c < l && l % c == 0) {
        count -= dp[c];
      }
    }
    dp[l] = count;
    if (DEBUG) cout << "count: " << count.Value() << endl;
    FiniteField cycle = 2 * l;
    sum -= count * (FiniteField(2 * n) - cycle);
  }
  cout << sum.Value() << endl;
}


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

void call(int n){
	int i=1, x;
	do{
		x = i;
		if(x % 3 == 0){
			cout << " " << i;
		}else{
			do{
				if(x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}while(x);
		}
	}while(++i <= n);
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	call (n);
 	return 0;
}

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

using namespace std;

int main(void)
{
    int a;
    while ( scanf("%d", &a) != EOF) {
        bool fl = false;
        for (int i = 0; i < 10; i++) {
            if ((a&1) == 1) {
                if (fl) {
                    cout << " ";
                } else { 
                    fl = true;
                }
                cout << (1<<i);
            } 
            a >>= 1;
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 3104
import math

N,K = map(int,input().split())

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a = 0
if N >= 2:
  a = combinations_count(N, 2)
b = 0
if K >= 2:
  b = combinations_count(K, 2)
print(a + b)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;



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

    int a,b,c;
    cin >> a >> b >> c ;    
    
    cout << c << " " << a << " " << b << "\n"  ;
}   

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(Math.min(k*a,b));

    }
}


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

int N;
long long A[110];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    long long min = A[0],max = A[0];

    // 操作が行える限り操作を繰り返す
        for (int i = 0; i < N; ++i) {
          // cout <<  A[i] << endl;
 
           
         if (A[i] >= max) max = A[i];  // 奇数があったらフラグを立てる
         if (A[i] <= min) min = A[i];  // 奇数があったらフラグを立てる
        
        
        }

    // cout << max << endl;
    // cout << min << endl;
   // max = max - min;
    cout << max - min << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void) {
	int buf,i,c;
	long int a,b,gcd,lcm;
	
	while(scanf("%ld%ld",&a,&b) != EOF){
		if(b > a){buf = a;a = b;b = buf;}
		for(i = 1;;i++){
			if(((int)(a/i)) == a/(float)i && b%(a/i) == 0) {gcd = a/i;break;}
		}
		for(i = 1; ;i++){
			if((a*i)%b == 0) {lcm = a*i;break;}
		}
		
		printf("%ld %ld\n",gcd,lcm);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[8010];
int x, y;
int n;

vector<int> key[2];

bool make(int x, int k){
	auto& v = key[k];
	bitset<16001> bs; bs[8000] = 1;
	for(int t:v){
		bs = (bs << t) | (bs >> t);
	}
	return x<=n && bs[8000+x];
}

int main()
{
	scanf("%s", s+1);
	read(x, y);
	n = strlen(s+1);
	int sp = n+1;
	for(int i=1; i<=n; ++i){
		if(s[i] != 'F'){
			sp = i;
			break;
		}
		--x;
	}
	int pos = 0;
	for(int i=sp; i<=n; ++i){
		if(s[i] == 'T') pos ^= 1, key[pos].pb(0);
		else ++key[pos].back();
	}
	if(make(abs(x), 0) && make(abs(y), 1)){
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
import math
x1,y1,x2,y2 = [float(i) for i in input().split()]
def dis(x1,y1,x2,y2):
    return math.sqrt((x2-x1) ** 2 + (y2-y1) ** 2)

print("{0:.6f}".format(dis(x1,y1,x2,y2)))



Measured memory_bytes: 5664
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    n = I()
    ans = 0
    # 式変形より問題文を言い換える

    for j in range(1, n + 1):
        # 1 ~ n の中で j の倍数であるものの総和 の総和
        # 倍数の数
        k = n // j
        # 1 * j + 2 * j + ... + k * j
        ans += ((k + 1) * k // 2) * j
    print(ans)


main()


Measured memory_bytes: 79944
from math import factorial as fact
from functools import reduce

def is_prime(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True

def divc(n, d):
    c = 0
    while n % d == 0:
        c = c + 1
        n = n // d
    return c

n = int(input())
pl = [p for p in range(1, 1001) if is_prime(p)]
cl = [divc(fact(n), d) for d in pl]
ans = reduce(lambda x, y: x * y, [c + 1 for c in cl]) % (10 ** 9 + 7)
print(ans)


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

int r,g,b,n;

int main(){
  scanf("%d%d%d%d",&r,&g,&b,&n);
  int ans = 0;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
      int tmp = n-(i*r)-(j*g);
      if(tmp<0 || tmp%b!=0) continue;
      ans++;
//      cout << i << " " << j << " " << tmp/b << endl;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	fifth := make([]int64, 1)
	fifth[0] = 0
	for i := 1; ; i++ {
		fi := int64(i * i * i * i * i)
		if fi > 0 && fi <= int64(math.MaxInt64) {
			fifth = append(fifth, fi)
		} else {
			break
		}
	}
//	fmt.Println(len(fifth))

	var x int64
	fmt.Scanf("%d", &x)
	for i := 0; i < len(fifth); i++ {
		bf := fifth[i] - x
		for j := 0; j < len(fifth); j++ {
			if fifth[j] == bf {
				fmt.Println(i, j)
				return
			} else if fifth[j] == -bf {
				fmt.Println(i, -j)
				return
			}
		}
	}
}


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

int main(){
    int N;
    cin >> N;
    bool ans = false;
    for(int c=0;4*c<=N;c++){
        for(int d=0;7*d<=N-4*c;d++){
            if(4*c+7*d==N) ans = true;
        }
    }
    if(ans) cout <<"Yes"<<endl;
    if(!ans) cout <<"No" <<endl;
}

Measured memory_bytes: 3604
n=int(input())

total=n*(n+1)//2

Fizz=3*(n//3)*(n//3+1)//2

Buzz=5*(n//5)*(n//5+1)//2

FizzBuzz=15*(n//15)*(n//15+1)//2

print(total-Fizz-Buzz+FizzBuzz)
    

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

char x[1000],y[1000];

int LCS()
{
 int i,j;
 int n=strlen(x),m=strlen(y);
 int a[n+1][m+1];

 for(i=1;i<=n;i++){
   a[i][0]=0;
 }

 for(i=0;i<=m;i++){
   a[0][i]=0;
 }

 for(i=1;i<=n;i++){
  for(j=1;j<=m;j++){
   if(x[i-1]==y[j-1]){
     a[i][j]=a[i-1][j-1]+1;
   }else if(a[i-1][j]>=a[i][j-1]){
     a[i][j]=a[i-1][j];
   }else{
     a[i][j]=a[i][j-1];
   }
  }
 }
 return a[n][m];
}

int main(void)
{
 int i,n;

 scanf("%d",&n);

 for(i=0;i<n;i++){
   scanf("%s%s",x,y);
   printf("%d\n",LCS());
 }

 return 0;
}

Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n, d;
int p[20];
int ans = 0;

int main(){
  cin >> n;
  rep(i, n) cin >> p[i];
  for(int i = 1; i < n -1; i ++){
    if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1]) ){
      ans++;
    }
      
  }
  cout << ans <<endl;
}
  

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

using namespace std;


int main() {


    vector<int> Dy;
    int D = 0;
    
    list<int> Dyy;

    int N;
    cin >> N;
    int X;
    cin >> X;

    int U;
    cin >> U;
    D += U;
    Dyy.push_front(0);
    Dyy.push_back(D);
    vector<int> L(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> L[i];
    }

    for (size_t i = 0; i < L.size(); ++i) {
        Dyy.push_back(Dyy.back() + L[i]);
    } 

    int res = 0;
    for (auto k : Dyy) {
        if (k <= X)
            res += 1;
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 256
m = 0
f = 0
r = 0
while m!=-1 or f!=-1 or r!=-1:
	m,f,r = [int(i) for i in input().split()]
	sum = m + f
	if m!=-1 or f!=-1 or r!=-1:
		if m == -1 or f == -1:
			print('F')
		elif sum >= 80:
			print('A')
		elif sum >= 65:
			print('B')
		elif sum >= 50:
			print('C')
		elif sum >= 30:
			if r >= 50:
				print('C')
			else:
				print('D')
		else:
			print('F')

Measured memory_bytes: 7656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;
 
#define ll long long
const int maxn = 1e5+5;
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n; cin >> n;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i >= 1 && n / i <= 9) {
            cout << "Yes" << endl; return 0;
        } 
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
#define X 3
#define Y 3
int main(){
	int i=1,start_point;
	vector<int>start(X*Y),goal;
	for(;i<X*Y;i++)goal.push_back(i);goal.push_back(0);
	for(i=0;i<X*Y;i++){
		scanf("%d",&start[i]);
		if(start[i]==0)start_point=i;
	}
	if(start==goal){puts("0");return 0;}

	map<vector<int>,pair<int,int> >mstart,mgoal;
	queue<pair<vector<int>,bool> >q;
	mstart[start]=make_pair(start_point,0);
	mgoal[goal]=make_pair(X*Y-1,0);
	q.push(make_pair(start,false));
	q.push(make_pair(goal,true));
	for(;!q.empty();){
		vector<int> v=q.front().first;
		bool f=q.front().second;
		q.pop();
		map<vector<int>,pair<int,int> >&m=f?mgoal:mstart;
		map<vector<int>,pair<int,int> >&m2=f?mstart:mgoal;
		int coor=m[v].first,x=coor%X,y=coor/X;
		int depth=m[v].second;
		if(0<x){
			swap(v[coor],v[coor-1]);
			if(m.find(v)==m.end())m[v]=make_pair(coor-1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-1]);
		}
		if(x<X-1){
			swap(v[coor],v[coor+1]);
			if(m.find(v)==m.end())m[v]=make_pair(coor+1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+1]);
		}
		if(0<y){
			swap(v[coor],v[coor-X]);
			if(m.find(v)==m.end())m[v]=make_pair(coor-X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-X]);
		}
		if(y<Y-1){
			swap(v[coor],v[coor+X]);
			if(m.find(v)==m.end())m[v]=make_pair(coor+X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+X]);
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for (int i = 1; i < s.length() - 1; i++)
        if (s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C')
            count++;

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)


#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#include<ext/rope>*/
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//void err(istream_iterator<string> it){cerr<<endl;}
//template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args){cerr << *it << " = " << a << " , ";err(++it, args...);}
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mem(a,b) memset((a),b,sizeof((a)))
#define fpre(x) cout<<fixed<<setprecision(x)
#define clr(v) (v).clear()
#define pii pair<int,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define pb emplace_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define ushort unsigned short
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lowbit(i) (i&(-i))
#define lson rt<<1
#define rson lson|1
#define fi first
#define se second
const double eps=1e-7;
const double pi=acos(-1);
inline int dcmp(double x)
{
    if(x<-eps)
        return -1;
    if(x>eps)
        return 1;
    return 0;
}
//-----------------------------------------------head


int a[105];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;++i)
            scanf("%d",a+i);
        ll r=1e10;
        for(int t=-100;t<=100;++t)
        {
            ll v=0;
            for(int i=0;i<n;++i)
                v+=1LL*(t-a[i])*(t-a[i]);
            r=min(v,r);
        }
        printf("%lld\n",r);
    }
}

/*
























*/









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	int N = 0;

	cin >> N;

	long long L0 = 2;
	long long L1 = 1;
	vector<long long> L(N + 1,0);
	L[0] = 2;
	L[1] = 1;

	for (int i = 2; i < N+1 ; ++i)
	{
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[N] << endl;


	return 0;
}

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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    string S, T;
    cin >> S >> T;
    cout << (S == T.substr(0, T.size() - 1) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n - 1);
  for (auto& a : as) {
    std::cin >> a;
  }
  int aa;
  std::cin >> aa;
  std::cout << aa;

  std::vector<int> bs(n / 2);
  int i = 0;
  bool flag = false;
  for (auto const a : boost::adaptors::reverse(as)) {
    if (flag) {
      std::cout << " " << a;
    } else {
      bs[i++] = a;
    }
    flag = !flag;
  }
  for (auto const b : boost::adaptors::reverse(bs)) {
    std::cout << " " << b;
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
      int n;
      int sum =0;
      n=input.nextInt();
      
      for(int i =1;i<=n;i++){
          sum+=i;
      }
      System.out.print(sum);
      
        
        
    }
    
}


Measured memory_bytes: 26932
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main() {

    int N;
    cin>>N;
    vector<int>x(N);
    vector<int>yp(N);
    vector<int>xp(N);
    for(int i=0;i<N;i++){
        int h,w;
        cin>>h>>w;
        h--;
        w--;
        x[h]=w;
        yp[h]++;
        xp[w]++;
    }
    if(*min_element(yp.begin(),yp.end())==0||*min_element(xp.begin(),xp.end())==0){
        cout<<-1<<endl;
        return 0;
    }
    int ans=0;
    vector<int>used(N);
    for(int i=0;i<N;i++){
        if(used[i])continue;
        int cn=i;
        int sz=0;
        while(!used[cn]){
            sz++;
            used[cn]=1;
            cn=x[cn];
        }
        ans+=sz-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4392
def main():

    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    prefix = [0]
    suffix = [0]
    for i in range(N):
        prefix.append(max(prefix[-1], A[i]))
        suffix.append(max(suffix[-1], A[N-i-1]))
    suffix.sort(reverse = True)

    for i in range(N):
        ans = max(prefix[i], suffix[i+1])
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15656
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[100005][13]; // dp[i][j]:= i桁目まで見てあまりがjとなる数の総数
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = s.size();
    int mul = 1; // 桁数
    dp[0][0] = 1;
    reverse(ALL(s));
    for(int i=1;i<=n;i++){
        if(s[i-1]=='?'){
            for(int k=0;k<13;k++){
                for(int j=0;j<10;j++){
                    dp[i][(mul*j + k)%13] += dp[i-1][k];
                    dp[i][(mul*j + k)%13] %= mod;
                }
            }
        }else{
            int c = s[i-1] - '0';
            for(int k=0;k<13;k++){
                dp[i][(mul*c + k)%13] += dp[i-1][k];
                dp[i][(mul*c + k)%13] %= mod;
            }
        }
        mul *=10;
        mul %=13;
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10704
# coding: utf-8
S = list(input())

N = len(S)
ans = 0
if N % 2 == 0:
    m = N//2-1
else:
    m = N//2
for i in range(m+1):
    if S[i] != S[N-1-i]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([usize]);
    let mut even = HashMap::with_capacity(n / 2);
    let mut odd = HashMap::with_capacity(n / 2);
    for (i, x) in v.iter().enumerate() {
        if i % 2 == 0 {
            let counter = even.entry(x).or_insert(0);
            *counter += 1;
        } else {
            let counter = odd.entry(x).or_insert(0);
            *counter += 1;
        }
    }
    let mut e_max_val = 0;
    let mut e_second_val = 0;
    let mut key_of_e_max_val = 0;
    for (key, val) in even.iter() {
        if e_max_val <= *val {
            key_of_e_max_val = **key;
            e_second_val = e_max_val;
            e_max_val = *val;
        } else if e_second_val <= *val {
            e_second_val = *val;
        }
    }
    let mut o_max_val = 0;
    let mut o_second_val = 0;
    let mut key_of_o_max_val = 0;
    for (key, val) in odd.iter() {
        if o_max_val <= *val {
            key_of_o_max_val = **key;
            o_second_val = o_max_val;
            o_max_val = *val;
        } else if o_second_val <= *val {
            o_second_val = *val;
        }
    }
    //eprintln!(
    //    "key_of_e_max_val: {}, e_max_val: {}, e_second_val: {}",
    //    key_of_e_max_val, e_max_val, e_second_val
    //);
    //eprintln!(
    //    "key_of_o_max_val: {}, o_max_val: {}, o_second_val: {}",
    //    key_of_o_max_val, o_max_val, o_second_val
    //);
    if key_of_e_max_val != key_of_o_max_val {
        println!("{}", n - e_max_val - o_max_val);
    } else {
        println!(
            "{}",
            std::cmp::min(n - e_max_val - o_second_val, n - e_second_val - o_max_val)
        );
    }
}


Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> sint(n+2);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='o')sint[i]=0;
		else sint[i]=1;
	}
	sint[n]=sint[0];
	sint[n+1]=sint[1];
	
	// S=0,W=1
	int d[4][2]={{0,0},{0,1},{1,0},{1,1}};

	vector<int> SorW(n+2);

	bool flag=false;

	for(int i=0;i<4;i++)
	{
		SorW[0]=d[i][0];
		SorW[1]=d[i][1];
		for(int j=2;j<n+2;j++)
		{
			if(sint[j-1]==SorW[j-1])SorW[j]=SorW[j-2];
			if(sint[j-1]!=SorW[j-1])SorW[j]=(SorW[j-2]+1)%2;
		}
		if(SorW[0]==SorW[n] and SorW[1]==SorW[n+1])
		{
			flag=true;
			break;
		}
	}
	if(!flag)cout << -1 << endl;
	else
	{
		for(int i=0;i<n;i++)
			cout << (SorW[i]==0 ? 'S':'W');
		cout << endl;
	}



}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    long long int n, a[200000], mid, sum = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] = a[i] - (i + 1); // あらかじめ引いておく
    }
    // 中央値を求める
    sort(a, a+n);
    mid = a[n/2];

    for(int i=0; i<n; i++){
        sum += abs(a[i] - mid);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        int N = scan.NextInt(), M = scan.NextInt();
        var foods = new int[M];
        for (int i = 0; i < N; i++) {
            var K = scan.NextInt();
            for (int j = 0; j < K; j++) {
                var A = scan.NextInt();
                foods[A - 1]++;
            }
        }
        return foods.Count(c => c == N);
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
    public int[] ArrayInt(int N, int add = 0) {
        var Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = NextInt() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 27864
#include <bits/stdc++.h>
using namespace std;
vector<int> group;
vector<vector<int>> G;
map<int,int> num;

void dfs(int v,int w) {
  group[v] = w;
  num[w]++;
  for (auto next : G[v]) {
    if (group[next]!=-1) continue;
    dfs(next,w);
  }
}

int main() {
  int n,m,k,a,b; cin >> n >> m >> k;
  G.resize(n+1);
  vector<int> minus(n+1,1);
  for (int i=0;i<m;i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    minus[a]++;minus[b]++;
  }
  group.assign(n+1, -1);
  for(int v=1;v<=n;v++){
    if(group[v]!=-1) continue;
    num[v]=0;
    dfs(v,v);
  }
  for(int i=0;i<k;i++){
    cin >> a >> b;
    if(group[a]==group[b]){minus[a]++;minus[b]++;}
  }
  for(int i=1;i<=n;i++) cout << num[group[i]] - minus[i] << endl;
}


Measured memory_bytes: 9600