akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; string s; cin >> k >> s;
    if(k>=s.size()){
        cout << s << endl;
    } else{
        cout << s.substr(0,k) << "..." << endl;
    }
} 

Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  int a=0,b=0,c=0;
  char s[101],t[101],u[101];
  int x=0;
  scanf("%s %s %s",s,t,u);
  while(1){
    char y;
    if(x==0){
      y=s[a++];
    }else if(x==1){
      y=t[b++];
    }else{
      y=u[c++];
    }
    if(y=='\0'){
      break;
    }
    x=y-'a';
  }
  printf("%c",x+'A');
  return 0;}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Set <Integer> numbers = new HashSet<Integer>();
        ArrayList<Integer> myNumbers = new ArrayList<Integer>();
        Scanner in = new Scanner(System.in);
        int n,x,sum=0,result =0;
        n = in.nextInt();
        in.nextLine();

        for(int i = 0 ;i<n;i++){
            x=in.nextInt();
            sum+=x;
            numbers.add(x);
            myNumbers.add(x);
        }
        if(numbers.size() == 1){
            System.out.println(0);
        }else{
            double mean = Math.round((double) sum/(double) n);
            int meanResult = (int) mean;
            for(int i=0;i<n ;i++){
                if(myNumbers.get(i) != meanResult){
                    int y = myNumbers.get(i) - meanResult;
                    result += (y*y);

                }
            }
            System.out.println(result);
        }

    }
}


Measured memory_bytes: 22608
def collatz(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1
    
s = int(input())
outputs = {s}

tmp_a = s
next_a = s
ans = 0
for i in range(100000):
    next_a = collatz(tmp_a)
    if next_a in outputs:
        ans = i + 2
        break
    else:
        outputs.add(next_a)
        tmp_a = next_a

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	for (Int i = 0; i < 50000; i++) {
		if ((Int)(i*1.08)==N) {
			cout << i << "\n";
			return 0;
		}
	}

	cout << ":(" << "\n";
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, c = i_map()
    k = i_input()

    count = 0
    while a >= b:
        b *= 2
        count += 1

    while b >= c:
        c *= 2
        count += 1

    print('Yes' if count <=k else 'No')

if __name__ == '__main__':
    main()


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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

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

    for(int i = 1;i<4;i++) {
        if( i != a && i != b) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
        int w, h, x, y, r;

        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

        // x
        if(x >= r && x <= w - r && y >= r && y <= h - r) {
                        printf("Yes\n");
        } else {
                        printf("No\n");
        }

        return 0;
}

Measured memory_bytes: 584
import math

n=int(input())
route = [list(map(int, input().split())) for _ in range(n)]

d=[]
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    
    l = math.sqrt((route[i][0]-route[j][0])**2+(route[i][1]-route[j][1])**2)
    d.append(l)
    

print(sum(d)*(n-1)/(n*(n-1)))

Measured memory_bytes: 3064
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = N * T # 総和
cur = 0 # いつまで出るか
for i in range(N):
    if cur > t[i]:
        ans -= cur - t[i]
    cur = t[i] + T
print(ans)

Measured memory_bytes: 30816
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[5],ans=0,tmp=6,tmp2=10;
    for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]%10!=0){
            if(a[i]%10<tmp2){
                tmp=i;
                tmp2=a[i]%10;
            }
        }
    }
    for(int i=0;i<5;i++){
        ans+=a[i];
        if(a[i]%10&&i!=tmp){
            ans+=(10-a[i]%10);
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <cstdio>
#define N 4000011
using namespace std;
int b[N],len,n,a[N],cnt[N],ans,maxx,minn,sum[N];
int judge(int avr){
	b[0]=b[len+1]=-1;
	for(int i=1;i<=len;i++){
		if(a[i]>=avr) b[i]=1;
		else b[i]=0;
		if(b[i]==b[i-1]) cnt[i]=cnt[i-1]+1;
		else cnt[i]=1;
	}
	for(int i=len;i>=1;i--){
		if(b[i]==b[i+1]) sum[i]=sum[i+1]+1;
		else sum[i]=1;
	}
	for(int i=0;i<n;i++){
		if(cnt[n+i]+sum[n+i]-1>=2) return b[n+i];
		if(cnt[n-i]+sum[n+i]-1>=2) return b[n-i];
	}
	return b[1];
}
void bin(){
	int head=minn,tail=maxx,mid;
	while(head<=tail){
		mid=(head+tail)/2;
		if(judge(mid)){
			ans=mid;
			head=mid+1;
		}
		else tail=mid-1;
	}
}
int main(){
//	freopen("triangle.in","r",stdin);
	scanf("%d",&n);len=2*n-1;
	for(int i=1;i<=len;i++) scanf("%d",&a[i]),minn=min(minn,a[i]),maxx=max(maxx,a[i]);
	bin();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 11264
A,B,C = map (int,input().split())
list = [A,B,C]
list.sort()

if list[0] == list[1] == list[2]:
  if list[2]  < list[0] + list[1]:
    print("Yes")
  elif list[2]  == list[0] + list[1]:
    print("No")
  else:
    print("No")
     
else:
  print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



void dfs(int d, ll val, vector<ll> &v) {
  v.push_back(val);
  
  if(d==10) return;
  
  for(int j=-1; j<=1; j++) {
    int add = (val%10) + j;
    if(add <= 9 && add >= 0) dfs(d+1,val*10+add,v);
  }
}

int main() {
  int K;
  cin >> K;
  vector<ll> v;
  for(int i=1; i < 10; i++) dfs(1,i,v);
  sort(all(v));
  cout << v[K-1] << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
using namespace std;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    vi no;
    pan(i,n) no.pb((int)s[i]-'0');
    for(int i=0;i<1000;i++){
        int d=i;
        int a=d%10;
        d/=10;
        int b=d%10;
        d/=10;
        int c=d%10;
        bool f1=false,f2=false,f3=false;
        for(int j=0;j<n;j++){
            if(no[j]==c){
                f1=true;
                for(int k=j+1;k<n;k++){
                    if(no[k]==b){
                        f2=true;
                        for(int l=k+1;l<n;l++){
                            if(no[l]==a) ans++,f3=true;
                            if(f3==true) break;
                        }
                    }
                    if(f2) break;
                }
            }
            if(f1) break;
        }
    }
    cout<<ans;
}   

Measured memory_bytes: 512
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

N = input()

for i in range(N):
    lst = []
    while len(lst) < 9:
        lst_ = raw_input().split()
        for S in lst_:
            lst.append(int(S, 16))
    res = lst[8]
    lst = lst[:8]
    diff = (sum(lst) - res) % (1 << 32)
    diff_lst = []
    for i in range(32):
        D = 0
        for j in lst:
            if j & (1 << i) == 0:
                D += (1 << i)
            else:
                D -= (1 << i)
        if res & (1 << i) == 0:
            D -= (1 << i)
        else:
            D += (1 << i)
        D %= (1 << 32)
        diff_lst.append((D, 1 << i))
    L1 = [(diff, 0)]
    for i in range(16):
        P = diff_lst[i]
        L = []
        for p in L1:
            L.append(((p[0] + P[0]) % (1 << 32), p[1] + P[1]))
        L1 += L
    L2 = [[0, 0]]
    for i in range(16, 32):
        P = diff_lst[i]
        L = []
        for p in L2:
            L.append(((p[0] + P[0]) % (1 << 32), p[1] + P[1]))
        L2 += L
    L1.sort()
    L2.sort()
    if L1[0][0] == 0:
        print hex(L1[0][1])[2:]
        continue
    pos = len(L2) - 1
    for p in L1:
        while p[0] + L2[pos][0] > (1 << 32):
            pos -= 1
        if p[0] + L2[pos][0] == (1 << 32):
            print hex(p[1] + L2[pos][1])[2:]
            break


Measured memory_bytes: 22500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	int n,k;cin>>n>>k;
	int h[n];for(int i=0;i<n;i++) cin>>h[i];

	ll dp[100500];for(int i=0;i<n;i++) dp[i]=inf;dp[0]=0;

	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			dp[i+j]=min(dp[i+j],abs(h[i]-h[i+j])+dp[i]);
		}
	}
/*
	for(int i=0;i<n;i++) cout<<dp[i]<<",";
	cout<<"\n";
*/
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1408
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define endl                        '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],vis(100010,0),dis(100010,0),par(100010,0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int k,x;
    cin>>k>>x;
    int num=x-k+1;
    for(int i=num;i<=x+k-1;i++)
    {
        if(i>=-1000000&&i<=1000000)
            cout<<i<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<vector>
#define inf 1000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    string str; cin >> str;
    int n = str.size();
    unordered_map<char, int> mp;

    for(int i =0; i<n; i++)
        mp[str[i]]++;
    
    if(mp['A'] < 1 || mp['B'] < 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}




Measured memory_bytes: 3588
var
 s:string;
 i,m,k:longint;
begin
 read(s);
 k:=pos('C',s);
 if k=0 then begin writeln('No');halt;end;
 for i:=k+1 to length(s) do if (s[i]='F') then begin m:=1;break;end;
 if m=1 then writeln('Yes')
        else writeln('No');
end.

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  
  if(a+c==2*b){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
int cnt[3];

int main() {
	cin >> s;
	rep(i, s.size()) {
		cnt[s[i] - 'a']++;
	}
	sort(cnt, cnt + 3);
	reverse(cnt, cnt + 3);
	if (cnt[0] == 0) {
		if (cnt[2] - 1 == cnt[1])cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	rep(i, s.size()) {
		if (cnt[i % 3] == 0) {
			cout << "NO" << endl;
			return 0;
		}
		cnt[i % 3]--;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
            double b, c;
            b=0;c=1<<29;
            string line;
            while((line=Console.ReadLine())!=null)
            {
                double a = double.Parse(line);
                if (b < a)
                    b = a;
                if (c > a)
                    c = a;
            }
            Console.WriteLine(b - c);
        }
    }
}
 
 

Measured memory_bytes: 9248
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vi x(n);
  rep (i, n) {
    scanf("%d", &x[i]);
  }
  int ans = INT_MAX;
  rep (i, n-k+1) {
    int mi = x[i];
    int ma = x[i+k-1];
    int dis = ma - mi;
    dis += min(max(mi, -mi), max(ma, -ma));
    ans = min(ans, dis);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvp a;

int main(){
	cin>>n>>m;
	a=vvp(n+1);
	for(int i=0;i<m;i++){
		int l,r,x;
		cin>>l>>r>>x;
		a[r].push_back({l,x});
	}
	vvi dp(n+1,vi(n+1));
	dp[0][0]++;
	for(int i=1;i<=n;i++){
		vvi DP=dp;
		for(int j=0;j<=n;j++) for(int k=0;k<=n;k++){
			(DP[i-1][j]+=dp[j][k])%=mod;
			(DP[i-1][k]+=dp[j][k])%=mod;
		}
		for(auto p:a[i]){
			int l=p.first,x=p.second;
			for(int j=0;j<=n;j++) for(int k=0;k<=n;k++){
				int y=1;
				if(l<=j) y++;
				if(l<=k) y++;
				if(x!=y) DP[j][k]=0;
			}
		}
		dp=DP;
	}
	int res=0;
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) (res+=dp[i][j])%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 1048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int m = sc.nextInt();
		int d = sc.nextInt();
		int res = 0;
		
		for (int i = 1; i <= m; i++) {
			for (int j = 10; j <= d; j++) {
				int d1 = j / 10;
				int d2 = j % 10;
				
				if (d1 >= 2 && d2 >= 2 && (d1 * d2 == i)) {
					// System.out.println(i + " " + j);
					res++;
				}
			}
		}
		System.out.println(res);
	}
  
	private static boolean isPalindromic(int n) {
		int num = n;
		int total = 0;
		while (num != 0) {
			total *= 10;
			total += (num % 10);
			num /= 10;
		}
		return n == total;
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
    private static  BufferedReader  br = null;
 
    static {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String	stdin = null;
        String	out   = "";
 
        while ((stdin = parseStdin()) != null) {
            String	tmp = "";
        	for(char c:stdin.toCharArray()) {
        		if (c == ' ' || c == '.' || c == ',') {
        			int	nLen = tmp.length();
        			if (3 <= nLen && nLen <= 6) {
        				out = (out.isEmpty()) ? tmp : out + " " + tmp;
        			}
        			tmp = "";
        		}
        		else {
        			tmp += c;
        		}
        	}
        }
 
        System.out.println(out);
    }
 
    private static String parseStdin() {
        String  stdin = null;
 
        try {
            stdin = br.readLine();
        }
        catch (IOException e) {}
 
        return stdin;
    }
}

Measured memory_bytes: 15152
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

OPERATORS = ["+", "-", "*"]


def calc(symbols):
    stack = []
    for s in symbols:
        if s in OPERATORS:
            a = stack.pop()
            b = stack.pop()
            if s == "+":
                stack.append(b + a)
            elif s == "-":
                stack.append(b - a)
            elif s == "*":
                stack.append(b * a)
        else:
            stack.append(int(s))
    return stack[-1]


def main():
    print(calc(input().split()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 7732
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

ll dp[10000005];
ll mod=1e9+7;
ll dp2[10000005];
int main() 
{
	string s;
	cin>>s;
	ll d;
	cin>>d;
	dp2[0]=1;
	for(ll i=0;i<s.size();i++)
	{
		ll p=s[i]-'0';
		for(ll j=0;j<d;j++)
		{
			for(ll k=0;k<p;k++)
			{
				dp[(i+1)*100+(j+k)%d]+=dp[i*100+j]+dp2[i*100+j];
			}
			dp[(i+1)*100+(j+p)%d]+=dp[i*100+j];
			dp2[(i+1)*100+(j+p)%d]+=dp2[i*100+j];
			for(ll k=p+1;k<10;k++)
			{
				dp[(i+1)*100+(j+k)%d]+=dp[i*100+j];
			}
		}
		for(ll j=0;j<d;j++)
		{
			dp[(i+1)*100+j]%=mod;
			dp2[(i+1)*100+j]%=mod;
		}
	}
	ll ans=dp[s.size()*100]+dp2[s.size()*100]+mod-1;
	cout<<ans%mod<<endl;
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct fenwick_tree {
    int n;
    T zero;
    std::vector<T> data;
    fenwick_tree(int n, T zero = T()) : n(n), zero(zero), data(n + 1, zero) {}
    void add(int i, T x) { for (i++; i <= n; i += i & -i) { data[i] += x; }}
    T get_sum(int i) const {
        if (i > n) { i = n; }
        T ret = zero;
        for (; i > 0; i -= i & -i) { ret += data[i]; }
        return ret;
    }
    T get_sum(int l, int r) const {
        if (l < r) { return get_sum(r) - get_sum(l); }
        else { return zero; }
    }
};

int N, D, A;
int X[220000], H[220000];
pint XH[220000];
signed main() {
    cin >> N >> D >> A;
    rep(i, N) {
        cin >> X[i] >> H[i];
        XH[i] = {X[i], H[i]};
    }
    sort(XH, XH + N);
    fenwick_tree<int> ft(N);
    int ans = 0;
    rep(i, N) {
        int r = upper_bound(XH + i, XH + N, pint(XH[i].first + 2 * D, LLONG_MAX)) - XH;
        int t = max((XH[i].second + ft.get_sum(i + 1) + A - 1) / A, 0LL);
        ans += t;
        ft.add(i, -A * t);
        ft.add(r, A * t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8576
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    
    string s;
    cin >> s;
    
    s = "#"+s+"#";
 
    auto can_reach = [&](int start, int end) {
        for (int i = start; i + 1 <= end; i++) {
            if (s[i] == '#' && s[i+1] == '#') return false;
        }
        return true;
    };
 
    if (!can_reach(a, c) || !can_reach(b, d)) {
        mes("No");
        re0;
    }
 
    if (c > d) {
        bool snuke_can_over = false;
        for (int i = b; i <= d; i++) {
            if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
                snuke_can_over = true;
            }
        }
        if (!snuke_can_over) {
            mes("No");
            re0;
        }
    }
 
    mes("Yes");
}

Measured memory_bytes: 3908
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val MAX = 1000000000000000000L
    val N = nextInt()
    val A = nextLongList()
    var ans = 1L
    if (A.contains(0)) {
        println(0)
        return
    }
    for (a in A) {
        if (ans * a > MAX || ans * a < ans) {
            println(-1)
            return
        }
        ans *= a
    }
    println(ans)
}

Measured memory_bytes: 63064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll mod2=1e9+9 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  ll ans=a[0]-1;
  int pos=2;
  rep(i,n-1){
    ans+=(a[i+1]-1)/pos;
    pos+=(a[i+1]==pos);
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
seq = [0] * n
a = 0
b = 0
res = 0

for i in range(n):
    seq[i] = i + 1

seq = list(itertools.permutations(seq))

for j in range(len(seq)):
    if list(seq[j]) == p:
        a = j + 1

    if list(seq[j]) == q:
        b = j + 1

if a > b:
    res = a - b
else:
    if a < b:
        res = b - a

print(res)

Measured memory_bytes: 8052
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct UnionFind {
    vector<int> parent;
    vector<int> rank;
    int operator [](int x) { return find(x); }
    void init(int size) { parent.assign(size, -1); rank.assign(size, 0); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteByRank(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (rank[x] < rank[y]) swap(x, y); else if (rank[x] == rank[y]) rank[x]++;
        return parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteBySize(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (size(x) < size(y)) swap(x, y);
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vi a(M), b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    UnionFind uf;
    int ans = 0;
    rep(i, M) {
        uf.init(N);
        rep(j, M) {
            if (i == j) continue;
            uf.uniteByRank(a[j], b[j]);
        }

        bool isConnected = true;
        int group = uf[0];
        rep(n, N) {
            if (uf[n] != group) isConnected = false;
        }
        if (!isConnected) ans++;
    }

    write(ans);
}

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

template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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

    int cnt = 0;
    rep(i, n) if (s[i] == 'R') cnt++;
    int ans = 0;
    rep(i, cnt) if (s[i] == 'W') ans++;
    cout << ans << '\n';
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define debug(a) cout << a << endl;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll dp[101][100100] = {0};
ll N,W,w[101],v[101];
int main(){
    cin >> N >> W;
    for(int i = 1; i <= N; i++){
        cin >> w[i] >> v[i];
        dp[i][0] = 0;
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= W; j++){
            dp[i+1][j] = dp[i][j];
            if(j >= w[i+1]){
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i+1]] + v[i+1]);
            }
        }
    }
    ll mx = 0;
    for(int i = 0; i <= W; i++){
        mx = max(mx, dp[N][i]);
    }
    cout << mx << endl;
}


Measured memory_bytes: 78464
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------

int main(){
    int n, m, x;
    bool exist = true;
    ll ANS = 1000000000;
    cin >> n >> m >> x;
    vec c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    for(int bit = 0; bit < (1 << n); ++bit){
        vector<ll> ans(m);
        ll tmp = 0;
        vector<int> S;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                S.push_back(i);
                tmp += c[i];
                //cout << i << " " << endl;
            }
        }
        for(int i = 0; i < S.size(); i++){
            int t = S[i];
            
            for(int j = 0; j < m; j++){
                ans[j] += a[t][j];
            }
        }
            rep(j, m){
                if(ans[j] < x) {
                    goto ABC;
                    exist = false;
                    }

            }
            ANS = min(ANS, tmp);
        
    ABC:;
    if(ANS == 1000000000) exist = false;
    else exist = true;
    }
    if(exist) cout << ANS << endl;
    else cout << -1 << endl;

}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    string s;
    ll k;
    cin>>s>>k;
    ll n = s.size();
    vector<ll> v;
    bool same = true;
    for(ll i=0;i<n;i++){
        if(s[i]!=s[0]){
            same = false;
            break;
        }
    }
    if(same){
        ll ans = n*k/2;
        cout << ans << endl;
        return 0;
    }
    if(k==1){
        ll c = 0;
        ll ans = 0;
        for(int i=0;i<n;){
            c = 1;
            while(i<n && s[i]==s[i+1]){
                i++;
                c++;
            }
            ans += c/2;
            i++;
        }
        cout << ans << endl;
    }
    ll c = 0;
    ll ans = 0;
    while(c<n && s[0]==s[c]){
        c++;
    }
    for(int i=c;i<n;){
        ll t = 1;
        while(i<n && s[i]==s[i+1]){
            i++,t++;
        }
        ans += t/2;
        i++;
    }
    ans += c/2;
    for(int i=0;i<c;i++){
        s += s[0];
    }
    n = s.size();
    ll ret = 0;
    for(int i=c;i<n;){
        ll cnt = 1;
        while(i<n && s[i]==s[i+1]){
            i++;
            cnt++;
        }
        ret += cnt/2;
        i++;
    }
    ans += ret * (k-1);
    //cerr << ret << endl;
    cout << ans <<endl;



}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    ai = list(map(int, input().split()))

    alice = 0
    bob = 0
    for i, a in enumerate(sorted(ai, reverse=True)):
        if i % 2 == 0:
            alice = alice+a
        else:
            bob = bob+a
    print(alice-bob)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() {
    int x, y, swap;
    while (1) {
            cin >> x >> y;
        if (x == 0 && y == 0) return 0;
        if (x > y) {
            swap = x;
            x = y;
            y = swap;
        }
        cout << x << ' ' << y << endl;
    }
}
    

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

int main() {
	int N, A;
	cin >> N >> A;
	if (N >= 500) N %= 500;
	string ans;
	if (N <= A){
		ans = "Yes";
	}
	else{
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main()
{
	int t;
	string s;
	char c;
	map<string,int> d;
	while (cin >> t >> c >> s)
	{
		if (d.find(s) == d.end())
			d[s] = 1;
		else
			d[s]++;
	}

	cout << d["A"] << endl;
	cout << d["B"] << endl;
	cout << d["AB"] << endl;
	cout << d["O"] << endl;
}

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

int main()
{
ll int n,i,t=0;

cin>>n;
for(i=1;i<=n;i++)
{
	if(i%3!=0 && i%5!=0)
	{
	t+=i;

    }
}
cout<<t;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) a[i] -= i + 1;

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

    ll mid;
    int l = a.size();
    if (l == 0) {mid = (a[l/2] + a[l/2-1]) / 2; }
    else mid = a[l/2];
    ll ans = LINF;
    for (int i = -1; i <= 1; i++) {
        ll tmp = 0;
        for (ll ai : a) tmp += abs(ai - (mid + i));
        ans = min(tmp, ans);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1792
n = int(input())
sList = list(input())

for i in range(len(sList)):
  tmp = ord(sList[i])+n
  if tmp > ord('Z'):
    sList[i]= chr(ord('A')+(tmp-ord('Z')-1))
  else:
    sList[i]= chr(tmp)

print(''.join(sList))
  

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

int F[102][102];
int xg,yg,ok;

void Maze(int X,int Y,int C){
	if(F[X][Y]!=C)
		return;

	

	if(X==xg&&Y==yg){
		cout << "OK"<<endl;
		ok++;
	}

	F[X][Y]=-1;

	Maze(X-1,Y  ,C);
	Maze(X  ,Y+1,C);
	Maze(X+1,Y  ,C);
	Maze(X  ,Y-1,C);
	
}



int main(){	
	while(1){
		ok=0;

		int w,h,xs,ys,n,c,d,x,y;

		cin >>w>>h;
		if(w==0&&h==0)
			return 0;

		cin >>xs>>ys;
		cin >>xg>>yg;
		cin >>n;


		for(int i=1; i<=w; i++)
			for(int j=1; j<=h; j++)
				F[j][i]=0;

		for(int i=1; i<=w;i++){
				F[w+1][i]=6;
				F[0][i]=6;
		}
		for(int i=1; i<=h;i++){
				F[i][h+1]=6;
				F[i][0]=6;
		}

		int N=0;
		while(N<n){
			cin >>c>>d>>x>>y;

			if(d){
				for(int i=x; i<x+2; i++)
					for(int j=y; j<y+4; j++){
						F[i][j]=c;
				}
			}else{
				for(int i=x; i<x+4; i++)
					for(int j=y; j<y+2; j++){
						F[i][j]=c;
					}
			}
			N++;
		}

/*for(int i=0; i<=h+1; i++){
	for(int j=0; j<=w+1; j++){
		cout <<F[j][i];
		}
	cout << endl;
}*/
		
		Maze(xs,ys,F[xs][ys]);

		if(ok==0)
			cout <<"NG"<<endl;

	}

}

Measured memory_bytes: 1216
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def longs: Seq[Long] = strings.map(_.toLong)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]): Unit = {
    for (a <- 1.to(9); b <- 1.to(9); c = a * b) {
      println(s"${a}x${b}=${c}")
    }
  }
}

Measured memory_bytes: 43844
using System;

namespace AtCoder {

    class Program {

        static void Main(string[] args) {

            Console.ReadLine(); // Discard N
            var S = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            var result = "";

            var exclude = S[K - 1];
            foreach(var s in S) {

                if(s != exclude) {

                    result += "*";
                } else {

                    result += s;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
def gcd(a, b):
    return b if a % b == 0 else gcd(b, a % b)

N = input()
T = [input() for i in range(N)]
ans = 1
for i in range(N):
    v = gcd(max(ans, T[i]), min(ans, T[i]))
    ans = ans * (T[i] / v)
print ans

Measured memory_bytes: 2568