akhauriyash/Code-Regression huggingface dataset:
// implement 4min
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int memo[22][22][160];
int calc(int n, int m, int s) {
  if (n < 0 || m < 0 || s < 0) { return 0; }
  if (m == 0 && s == 0) { return 1; }
  int &ret = memo[n][m][s];
  if (ret != -1) { return ret; }
  ret = 0;
  ret += calc(n - 1, m, s);
  ret += calc(n - 1, m - 1, s - n);
  return ret;
}

int n, m, s;
int main() {
  MEMSET(memo, -1);
  while (scanf("%d %d %d", &n, &m, &s) > 0 && n) {
    int ans = calc(n, m, s);
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1496
#include <iostream>
#include<math.h>
using namespace std;

#define ll long long

int main()
{
    ll vals[4000];
    vals[0]=100;

    ll k;
    cin >> k;

    for(int i=1;i<4000;i++){
        vals[i]=vals[i-1]+(0.01*vals[i-1]);
        if(vals[i]>=k){
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,tmp;
    cin >>a >>b >>c;
    if ( a > b ){
        tmp=a; a=b; b=tmp;
    }
    if (b > c){
        tmp=b; b=c ; c=tmp;
        if (a>b){
            tmp=a; a=b; b=tmp;
        }
    }
    cout << a << " " << b << " " << c <<endl;
}


Measured memory_bytes: 3076
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val syou = n / 11
    val amari = n % 11
    when {
        amari == 0L -> println(syou * 2)
        amari < 7 -> println(syou * 2 + 1)
        else -> println(syou * 2 + 2)
    }
}

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

def main():
    t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    print(t[K-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    A = A + B + C;
    B = A - (B + C);
    C = A - (B + C);
    A = A - (B + C);
    System.out.println(A);
    System.out.println(B);
    System.out.println(C);
  }
}


Measured memory_bytes: 35660
#!/usr/bin/env python3

from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print("Yes")
print("\n".join(str(i) for i in result[2:]))

Measured memory_bytes: 65508
//Name: Pankaj Mandrawal (pankaj_m05)
//Problem: Sum of gcd of tuple
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define mod 10000000009
#define sz(c) int((c).size())
#define sortall(x) sort(all(x))         
#define PI 3.1415926535897932384626     
#define all(c) (c).begin(), (c).end()
#define clr(x) memset(x, 0, sizeof(x))  
#define MAX32 numeric_limits< int >::max() 
#define MIN32 numeric_limits< int >::min()
#define rall(c) (c).rbegin(), (c).rend()
#define deb(x) cerr << #x << " = " << x << endl
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = (int)(l); i < (int)(r); ++i)
#define tr(c, it) for(typeof(c).begin() it = c.begin(); it != c.end(); it++)
#define deb2(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl

using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vill;
typedef pair < int, int > pi;
typedef unsigned long long int ull;

ll binpow(ll base, ll exp) {
    base %= mod;
    ll res = 1;
    while (exp > 0) {
        if (exp & 1)
            res = (res * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return res;
}

int gcd(int a, int b, int c) {
	int temp = __gcd(a, b);
	return __gcd(temp, c);
}

void plssolve() {
	int k; cin >> k;
	int ans = 0;
	for(int it = 1; it <= k; ++it)
		for(int it1 = 1; it1 <= k; ++it1) 
			for(int it2 = 1; it2 <= k; ++it2)
				ans += gcd(it, it1, it2);
	cout << ans << '\n';
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    cout << fixed;
    int t = 1;
    // cin >> t;
    while(t--) {
        plssolve();
    }
    return 0;
}

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

int main(){
  	ll n , k;
  	cin >> n >> k;
  
  	cout << min(n % k, abs(n % k - k)) << endl;
}

Measured memory_bytes: 256
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())

a1=0
b1=c11
b2=c12
b3=c13
a2=c21-b1
a3=c31-b1

if c22!=a2+b2:
    print("No")
elif c23!=a2+b3:
    print("No")
elif c32!=a3+b2:
    print("No")
elif c33!=a3+b3:
    print("No")
else:
    print("Yes")


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int hmax = 0;
  rep(i,n) hmax = max(hmax, h[i]);
  bool count = 1;
  int time;
  rep(i,hmax){
    rep(i,n){
      if(h[i]>0){
        if(count){
          time++;
          count = 0;
        }
      h[i]--;
      }else count = 1;
      if(i == n-1) count = 1;
    }
  }
  cout << time << endl;  
}


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

p = [[0] * 30 for x in range(4)]

for i in range(0, n):
  b, f, r, v = map(int, input().split())
  p[b - 1][(f - 1) * 10 + r - 1] += v

for i in range(0, 4):
  if i >= 1:
    print('#' * 20)
  for j in range(0, 3):
    for k in range(0, 10):
      print(' ', end='')
      print(p[i][j * 10 + k], end = '')
    print()
  



Measured memory_bytes: 5636
from operator import itemgetter as get
N = int(input())

A = map(int, input().split())
SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)

def solve(a, i, prev, th):
  pl, pr, ps = 0, -1, 0
  for l, r, s in prev:
    if s < th:
      continue
    if pr == r-1:
      yield l, r-1, max(s+abs(r-i)*a, ps+abs(i-pl)*a)
    else:
      if pl:
        yield pl+1, pr, ps+abs(i-pl)*a
      yield l, r-1, s+abs(r-i)*a
    pl, pr, ps = l, r, s
  yield pl+1, pr, ps+abs(i-pl)*a

prev = [(1, N, 0)]
pm = 0
for j, (a,b,i) in enumerate(ABI):
  M = 0
  prev = [(M:=max(M,s),) and (l, r, s) for l, r, s in solve(a,i, prev, pm-SB)]
  pm = M
  SB -= b

print(pm)


Measured memory_bytes: 9728
n = int(input())
a = list(map(int, input().split()))

cnt = 0
for i in a:
    if i < 0:
        cnt += 1

a = list(map(abs, a))
total = sum(a)

if cnt % 2 ==  0:
    print(total)
else:
    print(total - 2 * min(a))


Measured memory_bytes: 14224
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans(n, -1);

    queue<int> q;
    q.push(0);
    ans[0] = 0;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (const auto& c : g[v]) {
            if (ans[c] == -1) {
                ans[c] = v;
                q.push(c);
            }
        }
    }

    bool ok = true;
    for (int i = 1; i < n; i++) {
        if (ans[i] == -1) {
            ok = false;
            break;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
        for (int i = 1; i < n; i++) { cout << ans[i] + 1 << endl; }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  if(h1==h2)
  {
    ll p=m2-m1;
    cout<<p-k;
    return 0;
  }
  ll p=0;
  if(m1>0)
  {
    h1++;
    p=p+60-m1;
  }
  p=p+m2;
  if(h2>h1)
    p=p+((h2-h1)*60);
  cout<<p-k;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] player = new int[N][];
		for(int i=0; i<N; ++i) player[i] = new int[5];//3はflg 4は和
		for(int i=0; i<N; ++i){
			for(int j=0; j<3; ++j){
				player[i][j] = sc.nextInt();
			}
			player[i][4]=0;
		}
		for(int k=0; k<3; ++k){
			for(int i=0; i<N; ++i){
				player[i][3]=1;
				for(int j=0; j<N; ++j){
					if(i!=j && player[i][k] == player[j][k]){
						player[i][3]=0;
					}
				}
				if(player[i][3]==1) player[i][4] += player[i][k];
			}
		}
		for(int i=0; i<N; ++i) System.out.println(player[i][4]);
	}
}

Measured memory_bytes: 20816
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

struct team{
	int num;
	int ans;
	double time;
};

bool hikaku(const team &right,const team &left){
 if(right.ans == left.ans){
 	if(right.time == left.time){
 		return right.num < left.num;
 	}
 	return right.time < left.time;
 }
 else return left.ans < right.ans;
}

int main(){
	int t,p,r;
	int wrong[52][12];
	int res[52];
	double pe[52];
	vector<team> v;
	int tid,pid,time;
	string message;
	team te;
	while(1){
		cin >> t >> p >> r;
		if(t == 0)break;
		for(int i = 0;i <= t;i++){
			res[i] = 0;
			pe[i] = 0;
			for(int j = 0;j <= p;j++){
				wrong[i][j] = 0;	
			}
		}
		v.clear();
		for(int i = 0;i < r;i++){
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT"){
				res[tid]++;
				pe[tid] += wrong[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG"){
				wrong[tid][pid]++;
			}
		}
		for(int i = 1;i <= t;i++){
			te.num = i;
			te.ans = res[i];
			te.time = pe[i];
			v.push_back(te);
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < v.size();i++){
			cout << v[i].num << " " << v[i].ans << " " << v[i].time <<endl;
		}
	}
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};

int h,w;
vvi used;
vector<string> g;
pll dfs(int i, int j){
    used[i][j] = 1;
    pll res = pll(0,0);
    if(g[i][j] == '#') res.fi++;
    else res.se++;
    rep(k,4){
        int ni = i + di[k];
        int nj = j + dj[k];
        if(ni < 0 || h <= ni) continue;
        if(nj < 0 || w <= nj) continue;
        if(used[ni][nj] || g[ni][nj] == g[i][j]) continue;
        pll tmp = dfs(ni,nj);
        res.fi += tmp.fi;
        res.se += tmp.se;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> h >> w;
    g = vector<string>(h);
    rep(i,h) cin >> g[i];

    ll ans = 0;
    used = vvi(h, vi(w, 0));
    rep(i,h) rep(j,w){
        if(!used[i][j] && g[i][j] == '#'){
            pll res = dfs(i,j);
            ans += res.fi * res.se;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16564
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

int[10^^5+2] CNT;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);
    foreach (a; as) {
        CNT[a == 0 ? 10^^5+1 : a-1]++;
        CNT[a]++;
        CNT[a+1]++;
    }
    int m = 0;
    foreach (cnt; CNT) {
        m = max(cnt, m);
    }
    writeln(m);
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)

const long long MOD = 2;


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> K(M);
    vector<vector<ll>> S;
    vector<ll> P(M);
    rep(i, M) {
        cin >> K[i];
        vector<ll> s(K[i]);
        rep(j, K[i]) {
            cin >> s[j];
        }
        S.push_back(s);
    }
    rep(i, M) {
        cin >> P[i];
    }
    ll cc = 0;
    rep(i, 1 << N) {
        bool flag = true;
        rep(j, M) {
            ll counter = 0;
            rep(k, N) {
                if (i>>k&1 == 1 && find(S[j].begin(), S[j].end(), k+1) != S[j].end()) counter++;
            }
            if (counter % 2 != P[j]) flag = false;
        }
        if (flag) cc++;
    }
    cout << cc << endl;
    return 0;
}


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

int main() {
  int N, W;
  vector<int> w(110);
  vector<int> v(110);
  vector<vector<long long>> dp(110, vector<long long>(100010));

  long long res = 0;

  cin >> N >> W;
  rep(i,N){
    cin >> w.at(i) >> v.at(i);
  }  
  
  rep(i,N){
    for(int j = 0; j <= W; j++){
      if(w.at(i) <= j){
        dp.at(i+1).at(j) = max(dp.at(i).at(j-w.at(i)) + v.at(i), dp.at(i).at(j));
      }
      else{
        dp.at(i+1).at(j) = dp.at(i).at(j);
      }
    }
  }

  rep(i,W+1){
    res = max(res, dp.at(N).at(i));
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 87296
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  ll ans = 0;
  ll dum = 0;
  ll sum = 0;
  REP(i, s.length()) {
    if(s[i] == '<') dum++;
    else sum++;

    if(i == s.length() - 1 || s[i] == '>' && s[i + 1] == '<') {
      ans += max(dum, sum);
      ans += (((sum - 1) * sum) / 2);
      ans += (((dum - 1) * dum) / 2);
      dum = 0;
      sum = 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1172
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	
	sort(all(v));
	int x = 0;
	rep(i,n-1){
		if(v[i]==v[i+1])x++;
	}
	
	cout<<n-((x+1)/2)*2<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<ll> a(n);
    REP(i, 0, n) {
        cin, a[i];
    }
    int ans = 0;
    REP(i, 0, n) {
        REP(j, i + 1, n) {
            REP(k, j + 1, n) {
                ll x = a[i], y = a[j], z = a[k];
                if (x == y || y == z || x == z) continue;
                if (x > y) swap(x, y);
                if (y > z) swap(y, z);
                if (x > y) swap(x, y);
                ans += (z < x + y);
            }
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


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



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    ll k;   cin >> k;
    ll res = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                res += gcd(gcd(i, j), l);
            }
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 3632
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int x;
bool dp[N], vis[N];

bool solve(int idx){
   if(idx > x)
      return 0;
   if(idx == x){
      tr(idx, x);
      return 1;
   }
   if(vis[idx])
      return dp[idx];
   vis[idx] = 1;
   bool ans = 0;
   ans |= solve(idx + 100);
   ans |= solve(idx + 101);
   ans |= solve(idx + 102);
   ans |= solve(idx + 103);
   ans |= solve(idx + 104);
   ans |= solve(idx + 105);
   return dp[idx] = ans;
}

void solve(){

   cin >> x;
   if(solve(0)){
      cout<<1;
   }
   else{
      cout<<0;
   }
}

int32_t main(){_
   
   int t = 1;
//   cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 512
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA ios_base::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
void cal()
{
  fact[0]=1;
  inv[0]=1;
  for(int i=1;i<int(2e5+1);++i)
  {
    fact[i]=(1LL*fact[i-1]*i)%mod;
    inv[i]=(1LL*inv[i-1]*(exp(i,mod-2,mod)%mod))%mod;//always use 1ll at first
  }

}
int ncr(int n,int r)
{
  if(n-r==0||r==0)return 1;
  int cal1=fact[n];
  int cal2=inv[r];
  int cal3=inv[n-r];
  return (1LL*((1ll*cal1*cal2)%mod)*cal3)%mod;

}
int main()
{
   VALHALLA  
   int h,w,a,b;
   cin>>h>>w>>a>>b;
   cal();
   int ans=0;
   for(int i=1;i<=h-a;++i)
   {
      int cal1=ncr(i-1+b-1,i-1);
      int cal2=ncr(h-i+w-b-1,h-i);
      ans+=(1ll*cal1*cal2)%mod;
      ans%=mod;
   }
   cout<<ans;
   
   


}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <cstring>

namespace FastIO{static constexpr size_t E=(1<<17);static constexpr size_t T=23
,A=334;static constexpr char O[]="%.16f";FILE*e=stdin,*t=stdout;char a[E|1],*o,
*i;char n[E|1],*s,*h;inline size_t r(){size_t f=fread(a,1,E,e);*(i=a+f)=0;o=a;
return f;}inline size_t d(){std::ptrdiff_t f=i-o;if(a+f>=o){return 0;}memcpy(a,
o,f);size_t b=fread(a+f,1,E-f,e);*(i=a+(f+=b))=0;o=a;return b;}inline void l(d\
ouble&f){if(*o==0&&r()){f=0;return;}char*p;f=strtod(o,&p);while(p==o){if(!r()){
f=0;return;}f=strtod(o,&p);}if(p==i&&d()){f=strtod(a,&p);}o=p;}inline void l(c\
har&f){if(*o==0){r();}if((f=*o)!=0){++o;}}inline void l(char*f){while(1){if(*o
==0){if(!r()){*f=0;return;}}if(*o<=' '){++o;}else{break;}}for(char*p=o;;++o){if
(*o==0){memcpy(f,p,o-p);f+=o-p;if(!r()){*f=0;return;}p=o;}else if(*o<=' '){mem\
cpy(f,p,o-p);f+=o-p;*f=0;return;}}}template<class N>inline void l(N&f,typename
std::enable_if<std::is_signed<N>::value>::type*g=0){f=0;int y=0;if(o+T>=i){d();
}while(*o<'-'){++o;}if(*o=='-'){y=1;++o;}do{f=f*10+*o-'0';}while(*++o>='0');++o
;if(y){f=-f;}}template<class N>inline void l(N&f,typename std::enable_if<!std::
is_signed<N>::value>::type*g=0){f=0;if(o+T>=i){d();}while(*o<'+'){++o;}do{f=f*
10+*o-'0';}while(*++o>='0');++o;}inline void c(){fwrite(n,1,s-n,t);s=n;}inline
void u(char f){if(s+1>=h)c();*s++=f;}inline void u(const char*f){size_t g=strl\
en(f);if(s+g>=h){c();}if(s+g>=h){fwrite(f,1,g,t);}else{memcpy(s,f,g);s+=g;}}te\
mplate<size_t N>inline void u(const char(&f)[N]){if(s+N>=h){c();}if(s+N>=h){fw\
rite(f,1,N,t);}else{memcpy(s,f,N);s+=N;}}inline void u(double f){char g[A];siz\
e_t y=snprintf(g,A,O,f);char*p=s+y;if(p>=h){c();p=n+y;}memcpy(s,g,y);s=p;}temp\
late<class N>inline void u(N f,typename std::enable_if<std::is_signed<N>::value
>::type*g=0){if(s+T>=h){c();}if(f==0){*s++='0';return;}char v[T],*k=v+T,*j=k;if
(f<0){*s++='-';f=-f;}do{*--k=f%10+'0';f/=10;}while(f);memcpy(s,k,j-k);s+=j-k;}
template<class N>inline void u(N w,typename std::enable_if<!std::is_signed<N>::
value>::type*f=0){if(s+T>=h){c();}if(w==0){*s++='0';return;}char b[T],*v=b+T,*k
=v;do{*--v=w%10+'0';w/=10;}while(w);memcpy(s,v,k-v);s+=k-v;}struct Scanner{Sca\
nner(){o=a;i=a+E;r();}template<class Z>inline void scan(Z&&z){l(z);}template<c\
lass Z,class...Q>inline void scan(Z&&z,Q&&...q){l(z);scan(q...);}};struct Prin\
ter{Printer(){s=n;h=n+E;}~Printer(){c();}template<class Z>inline void print(Z z
){u(z);}template<class Z,class...Q>inline void print(Z z,Q...q){u(z);print(q...
);}template<class Z>inline void println(Z z){u(z);u('\n');}};}

FastIO::Scanner cin;

int main() {
  unsigned N, x;
  cin.scan(N, x);

  uintmax_t res=0;
  unsigned prev=0;
  for (unsigned i=0; i<N; ++i) {
    unsigned a;
    cin.scan(a);

    if (a+prev > x) {
      res += a+prev-x;
      a = x-prev;
    }
    prev = a;
  }

  printf("%ju\n", res);
  return 0;
}


Measured memory_bytes: 256
a, b= map(int, input().split())

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
k=gcd(a,b)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
m=make_divisors(k)
x=len(m)
n=len(m)

for _ in range(n-1):
  for i in range(1,len(m)):
    if gcd(m[i],m[0])!=1:
      x-=1
      m.pop(0)
      break
    if i+1 == len(m):
      m.pop(0)
      break
print(x)
    

Measured memory_bytes: 3272
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        bool[,] A = new bool[N,N];
        bool[,] B = new bool[M,M];
        {
            string s;
            for(int i=0;i<N;i++){
                s = Console.ReadLine();
                for(int j=0;j<N;j++){
                    A[i,j] = s[j] == '.';
                }
            }
            for(int i=0;i<M;i++){
                s = Console.ReadLine();
                for(int j=0;j<M;j++){
                    B[i,j] = s[j] == '.';
                }
            }
        }
        bool ans = false;
        for(int i=0;i<N-M+1;i++){
            for(int j=0;j<N-M+1;j++){
                bool o = true;
                for(int k=0;k<M;k++){
                    for(int l=0;l<M;l++){
                        o &= A[i+k,j+l] == B[k,l];
                    }
                }
                ans |= o;
            }
        }
        sb.Append(ans ? "Yes\n" : "No\n");
    }
}

Measured memory_bytes: 13140
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <iostream>
#include <map>
using namespace std;
int main() {
	string s;
	long long int cnt[30] = {}, n;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		n = s[i] - 'a' + 1;
		cnt[n]++;
	}
	for (int i = 1; i <= 26; i++) {
		if (cnt[i] % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
a=input()
b=input()
c=[[]for i in range(26)]
for i in range(len(a)):
  c[ord(a[i])-97].append(i)

m=-1
ans=0
roop=0
for i in range(len(b)):
  s=ord(b[i])-97
  if c[s]==[]:
    print(-1)
    exit()
  else:
    p=bisect_left(c[s],m+1)
    if p<len(c[s]):
      m=c[s][p]
    else:
      roop+=1
      m=c[s][0]
print(roop*len(a)+m+1)
        
        

Measured memory_bytes: 7796
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
t = input().strip()

for i in range(len(s)):
    if t == s[len(s)-i:len(s)] + s[:len(s)-i]:
        print('Yes')
        sys.exit(0)
print('No')


Measured memory_bytes: 61688
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#include<vector>
#include<algorithm>
struct bridge{
	vector<int>ord,low;
	vector<bool>art;
	vector<pair<int,int> >bridges;
	vector<vector<int> >G;
	bridge(int n_=0):ord(n_,-1),low(n_),art(n_,false),G(n_){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool operator[](int a){return art[a];}
	bool is_bridge(int a,int b)
	{
		if(ord[a]>ord[b])swap(a,b);
		return ord[a]<low[b];
	}
	void dfs(int u,int p,int&k)
	{
		low[u]=ord[u]=k++;
		for(int&v:G[u])
		{
			if(ord[v]==-1)
			{
				dfs(v,u,k);
				low[u]=min(low[u],low[v]);
				art[u]=art[u]|ord[u]<=low[v];
				if(ord[u]<low[v])bridges.push_back(u<v?make_pair(u,v):make_pair(v,u));
			}
			else if(v!=p)
			{
				low[u]=min(low[u],ord[v]);
			}
		}
	}
	void build()
	{
		int k=1,cnt=0;
		low[0]=ord[0]=0;
		for(int&v:G[0])if(ord[v]==-1)
		{
			dfs(v,0,k);
			if(ord[0]<low[v])bridges.push_back(make_pair(0,v));
			cnt++;
		}
		if(cnt>=2)art[0]=true;
	}
};
int n,m;
vector<int>G[1<<17];
int cnt[1<<17];
main()
{
	cin>>n>>m;
	bridge P(n);
	for(int i=0;i<m;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
		P.add_edge(u,v);
		cnt[u]++;
		cnt[v]++;
	}
	P.build();
	bool six=0;
	int four=0,tt=0;
	for(int i=0;i<n;i++)
	{
		if(cnt[i]%2)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(cnt[i]>=6)six=1;
		if(cnt[i]==4)
		{
			four++;
			tt+=P[i];
		}
	}
	cout<<(six||four>=3||tt==2?"Yes":"No")<<endl;
}

Measured memory_bytes: 17536
fn main() {
    let n: i64 = read();
    println!("{}", solve(n));
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn solve(n: i64) -> String {
    // 要するに26進数
    let mut s = "".to_string();
    let mut i = n;
    while {
        s = ((b'a' + ((i - 1) % 26) as u8) as char).to_string() + &s;

        i = (i - 1) / 26;
        i > 0
    } {}

    s
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_solve_1() {
        assert_eq!("b".to_string(), solve(2));
    }

    #[test]
    fn test_solve_2() {
        assert_eq!("aa".to_string(), solve(27));
    }

    #[test]
    fn test_solve_3() {
        assert_eq!("jjddja".to_string(), solve(123456789));
    }

    #[test]
    fn test_solve_4() {
        assert_eq!("zz".to_string(), solve(702));
    }

    #[test]
    fn test_solve_5() {
        assert_eq!("aaab".to_string(), solve(18280));
    }
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int c[3];
  c[0] = a + b;
  c[1] = a - b;
  c[2] = a * b;
  sort(c, c+3);
  cout << c[2] << endl;
  return 0;
}

Measured memory_bytes: 256
n = str(input())

hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = 3

a = n[-1]


if int(a) in hon:
    print('hon')
elif int(a) in pon:
    print('pon')
elif int(a) == 3:
    print('bon')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int a, int B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, int B) {return (a + (B - 1)) / B;}
long long divCeil(int a, long long B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, long long B) {return (a + (B - 1)) / B;}

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

  int n = N;
  int f = 0;
  while (n > 0)
  {
    f += n % 10;
    n /= 10;
  }
  
  string ans = "No";
  if (N % f == 0) ans = "Yes";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    int max_val = 1;
    repi(i, 1, n+1){
        if(i > n) break;
        repi(j, 2, n+1){
            if(pow(i, j) <= n){
                max_val = max(max_val, (int)pow(i, j));
            }else{
                break;
            }
        }
    }

    cout << max_val << endl;
}

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

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

char field[55][55]; //[y][x]
int memo[55][55]; // [y][x]

int main() {
    int H, W;
    cin >> H >> W;

    for (int i=0; i<H; i++) {
        cin >> field[i];
    }

    // init
    for (int i=0; i<55; i++) {
        for (int j=0; j<55; j++) {
            memo[i][j] = INT_MAX;
        }
    }

    queue<pair<int,int> > q; // (x,y)
    q.push( make_pair(0,0) );
    memo[0][0] = 0;

    while (!q.empty()) {
        pair<int,int> cell = q.front();
        q.pop();

        int curr = memo[cell.second][cell.first];

        for (int i=0; i<4; i++) {
            int x = cell.first + dx[i];
            int y = cell.second + dy[i];
            if (x < 0 || y < 0 || x >= W || y >= H || field[y][x] == '#') continue;
            if (memo[y][x] != INT_MAX) continue;
            memo[y][x] = curr + 1;
            q.push( make_pair(x,y) );
        }
    }

    int goal_step = memo[H-1][W-1];

    // 白マスを数えておく
    int white_cells = 0;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (field[i][j] == '.') white_cells++;
        }
    }

    cout << (goal_step == INT_MAX ? -1 : (white_cells - goal_step - 1)) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		double interest = 1.05; 
		double debt = 100;
		
		for (int i = 0; i < n; i++) {
			debt = Math.ceil(debt * interest);
		}
		
		System.out.println((int)(debt * 1000));
	}
}

Measured memory_bytes: 17000
#include <stdio.h>
#include <string.h>
#define range(x,y) x >= 0 && x < 8 && y >= 0 && y < 8

int putable[8][8];
const int dx[8] = {-1,0,1,-1,1,-1,0,1}, dy[8] = {-1,-1,-1,0,0,1,1,1};
char table[8][9];

int putablechecker(char c){
	int i, j, k, l, flag = 0;
	char e;
	memset(putable,0,sizeof(putable));
	if(c == 'o')
		e = 'x';
	else
		e = 'o';
	for(i = 0;i < 8;i++){
		for(j = 0;j < 8;j++){
			if(table[i][j] == '.'){
				for(k = 0;k < 8;k++){
					for(l = 1;range(j + dx[k] * l,i + dy[k] * l) && table[i + dy[k] * l][j + dx[k] * l] == e;l++);
					if(range(j + dx[k] * l,i + dy[k] * l) && table[i + dy[k] * l][j + dx[k] * l] == c){
						for(l = 1;table[i + dy[k] * l][j + dx[k] * l] == e;l++){
							putable[i][j]++;
							flag = 1;
						}
					}
				}
			}
		}
	}
	return flag;
}

int main(void){
	int t, count, i, j, max, max_i, max_j;
	char c;
	for(i = 0;i < 8;i++)
		gets(table[i]);
	c = 'o';
	t = putablechecker(c);
	count = 0;
	while(t || count < 2){
		if(!t)
			count++;
		else{ // おける場所がある
			count = 0;
			max = 0;
			if(c == 'o'){
				for(i = 0;i < 8;i++){
					for(j = 0;j < 8;j++){
						if(max < putable[i][j]){
							max = putable[i][j];
							max_i = i;
							max_j = j;
						}
					}
				}
			}
			else{
				for(i = 8;i >= 0;i--){
					for(j = 8;j >= 0;j--){
						if(max < putable[i][j]){
							max = putable[i][j];
							max_i = i;
							max_j = j;
						}
					}
				}
			}
			for(i = 0;i < 8;i++){
				for(j = 1;range(max_j + dx[i] * j,max_i + dy[i] * j) && table[max_i + dy[i] * j][max_j + dx[i] * j] == ((c == 'o') ? 'x':'o');j++); // 範囲外参照を取り除く
				if(range(max_i + dy[i] * j,max_j + dx[i] * j) && table[max_i + dy[i] * j][max_j + dx[i] * j] == c){
					for(j = 1;table[max_i + dy[i] * j][max_j + dx[i] * j] == ((c == 'o') ? 'x':'o');j++)
						table[max_i + dy[i] * j][max_j + dx[i] * j] = c;
				}
			}
			table[max_i][max_j] = c;
		}
		if(c == 'o')
			c = 'x';
		else
			c = 'o';
		t = putablechecker(c);
	}
	for(i = 0;i < 8;i++){
		for(j = 0;j < 8;j++)
			printf("%c",table[i][j]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 908
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int N;
    std::cin >> N;

    int64_t sum = 0;
    std::vector<int> S;
    for (size_t i = 0; i < N; ++i) {
        int t;
        std::cin >> t;
        sum += t;
        S.push_back(t);
    }

    std::sort(std::begin(S), std::end(S));

    for (size_t i = 0; i < N; ++i) {
        if (sum % 10 != 0) {
            std::cout << sum << std::endl;
            return 0;
        }
        if (S[i] % 10 != 0) {
            sum -= S[i];
        }
    }

    std::cout << 0 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str0[105];
char str1[105];

int main(int argc, char* argv[])
{
    scanf("%s%s", str0, str1);
    printf("%s%s\n", str1, str0);



    return 0;
}



Measured memory_bytes: 128
import numpy as np

mod = 998244353
n, s = map(int, input().split())
dp = np.zeros((n+1, s+1), dtype=int)
dp[0, 0] = 1
for i, a in enumerate(map(int, input().split())):
  dp[i+1] = dp[i] * 2 % mod
  dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod
print(dp[-1, -1])

Measured memory_bytes: 97452
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K,H,W;
ll m;
string S,T;
ll d;
ll ans;
ll C[6][6];
ll M = 1000000007;
vector<ll> so;
ll ac,wa,tle,re;

int main() {
    cin >> H >> W >> K;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char a;
            cin >> a;
            if(a=='#'){
                C[i][j] = 1;
            }
        }
    }
    for(int i=0;i<(1<<W);i++){
        for(int j=0;j<(1<<H);j++){
            ll s=W*H;
            for(int k=0;k<W;k++){
                for(int l=0;l<H;l++){
                    if(i&(1<<k) || (j&(1<<l)) || C[l][k] == 0){
                        s--;
                    }
                }
            }
            if(s==K){
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0)
				break;
			int max = 0;
			int min = 1000;
			int ave = 0;
			int[] num = new int[n];

			for(int i = 0; i < num.length; i++) {
				num[i] = sc.nextInt();
				ave += num[i];

				if(num[i] > max)
					max = num[i];
				if(num[i] < min)
					min = num[i];
			}

			ave -= (max + min);
			ave /= n - 2;
			System.out.println(ave);
		}
	}
}

Measured memory_bytes: 29140
N, K = map(int, input().split())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1

D_list = sorted(D.items(), key=lambda x: x[1])
N = len(D_list)
ANS = 0
for t in D_list:
    if N <= K:
        break
    ANS += t[1]
    N -= 1

print(ANS)




Measured memory_bytes: 38964
void main() {
    int[] tmp = readln.split.to!(int[]);
    int r = tmp[0], d = tmp[1], x = tmp[2];
    foreach (i; 0 .. 10) {
        x = r * x - d;
        x.writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.typecons;

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    // 入力受付
	    Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    String str = scan.next();

	    if(n % 2 != 0){
	        System.out.println("No");
	        return;
	    }

	    int a = n / 2;
	    String splitStrA = str.substring(0, a);
	    String splitStrB = str.substring(a);

	    if(splitStrA.equals(splitStrB)){
	        System.out.println("Yes");
	    }else{
	        System.out.println("No");
	    }

	}
}

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

signed main(void)
{
	int n, sum, ave1, ave2, ans1, ans2, ans;
	cin >> n;
	int a[n];
	sum = ave1 = ave2 = ans1 = ans2 = ans = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	ave1 = sum / n;
	ave2 = ave1 + 1;
	rep(i, n)
	{
		ans1 += abs(a[i] - ave1) * abs(a[i] - ave1);
		ans2 += abs(a[i] - ave2) * abs(a[i] - ave2);
	}
	ans = min(ans1, ans2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;
int main(void){
    // Your code here!
    int a;
    std::cin >> a;
    
    int ame1[100];
    int ame2[100];
    
    for(int i=0; i < a; i++){
        cin >> ame1[i];
    }
    
    for(int i=0; i < a; i++){
        cin >> ame2[i];
    }
    
    int answer = 0;
    for(int i=0; i<a; i++){
        int tmp;
        tmp=accumulate(ame1,ame1+i+1,0);
        
        tmp+=accumulate(ame2+i,ame2+a,0);
        if(answer < tmp){
            answer=tmp;
        }
    }
    
    std::cout << answer << std::endl;
}


Measured memory_bytes: 256