akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	k = int(rl())
	s = rll()[0]
	if len(s) > k:
		print("".join([s[:k], "..."]))
	else:
		print(s)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65100
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

vector<pii> od, ev;

int odd[100001];
int even[100001];
int vec[100001];

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i]);
		if (i % 2) odd[vec[i]]++;
		else even[vec[i]]++;
	}

	for (int i = 1; i <= 100000; i++) {
		od.push_back({ odd[i], i });
		ev.push_back({ even[i], i });
	}

	sort(all(od), greater<pii>());
	sort(all(ev), greater<pii>());

	int mav = 0;
	if (od[0].second != ev[0].second) mav = od[0].first + ev[0].first;
	else {
		mav = max(mav, od[0].first + ev[1].first);
		mav = max(mav, od[1].first + ev[0].first);
	}

	printf("%d", n - mav);
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, q;
int A[20], m[200];

void func(vector<int> *S, int i, int x)
{
    if (i == n - 1)
    {
        (*S).push_back(x + A[i]);
        (*S).push_back(x);
    }
    else
    {
        func(S, i + 1, x + A[i]);
        func(S, i + 1, x);
    }

    return;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    cin >> q;
    for (int i = 0; i < q; i++)
        cin >> m[i];
    vector<int> S;

    func(&S, 0, 0);

    for (int i = 0; i < q; i++)
    {
        vector<int>::iterator itr = S.begin();
        bool flag = false;
        while (itr != S.end())
        {
            if (m[i] == *itr)
            {
                flag = true;
                break;
            }
            itr++;
        }
        if (flag)
            cout << "yes\n";
        else
            cout << "no\n";
    }

    return 0;
}


Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin>>n;
  std::vector<int>a(n);
  rep(i,n){
    int A;
    cin>>A;
    a.at(i)=A;
  }
  sort(a.begin(),a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    vector<int> nums;
    if (s[0] == '0') nums.pb(0);
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && s[j] == s[i]) j++;
        nums.pb(j - i);
        i = j;
    }
    if (s.back() == '0') nums.pb(0);

    vector<int> accum((int)nums.size()+1, 0);
    rep(i, nums.size()) accum[i+1] = accum[i] + nums[i];

    int ans = 0;
    for (int l = 0; l < accum.size(); l += 2) {
        int r = l + 2 * k + 1;
        if (r >= accum.size()) r = (int)accum.size() - 1;
        chmax(ans, accum[r] - accum[l]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1272
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 200010;
int bit[MX];
int sum(int i){
	int res = 0;
	for(i++; i; i -= i & -i) res += bit[i];
	return res;
}
void add(int i, int x){
	for(i++; i < MX; i += i & -i) bit[i] += x;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi v(n); rep(i, n) cin >> v[i];
	
	int lo = 0, hi = inf + 1, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		memset(bit, 0, sizeof(bit));
		int s = n;
		ll cnt = 0;
		add(s, 1);
		rep(i, n){
			s += v[i] >= mid ? 1 : -1;
			cnt += sum(s);
			add(s, 1);
		}
		if(2 * cnt >= n * (n + 1ll) / 2) lo = mid;
		else hi = mid;
	}
	cout << lo << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N = 1e5 + 10;

int n;
int a[N], ans1, ans2;
map<int, int> M[2], tmp;
int cnt, cnt2, ans=INF;

struct Node{
	int num;
	int t;
	bool operator < (const Node& rhs) const {
		return t>rhs.t;
	}
}p[N], p2[N];

int main() {
	scanf("%d", &n);
	REP(i, 1, n) {
		scanf("%d", &a[i]);
		M[i%2][a[i]]++;
	}
	for(auto it=M[0].begin(); it!=M[0].end(); it++) {
		p[++cnt].num=it->first;
		p[cnt].t=it->second;
	}
	sort(p+1, p+cnt+1);
	if (cnt==1) p[2].num=-1;
	for(auto it=M[1].begin(); it!=M[1].end(); it++) {
		p2[++cnt2].num=it->first;
		p2[cnt2].t=it->second;
	}
	sort(p2+1, p2+cnt2+1);
	if (cnt2==1) p[2].num=1;

	for(int i=1; i<=2; i++) {
		for(int j=1; j<=2; j++) {
			if (p[i].num==p2[j].num) continue;
			ans=min(ans, n-p[i].t-p2[j].t);
		}
	}


	cout<<ans<<endl;
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


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

using namespace std;

int main(){
	string str;
    const char* cstr;

    cin >> str;

    cstr = str.c_str();

    if(cstr[0] != cstr[1] && cstr[1] != cstr[2] && cstr[2] != cstr[3]){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 256
//author Forsaken
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e3;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index, ll p) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % p;
		base = base * base % p;
		index >>= 1;
	}
	return res;
}
ll v[maxn + 5][maxn + 5];
int main() 
{
	ll n, k;
	scanf("%lld%lld", &n, &k);
	v[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		v[i][0] = 1;
		for (int j = 1; j <= i; j++)
			v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]) % mod;
	}
	for (int i = 1; i <= k; i++)
		printf("%lld\n", v[n - k + 1][i] * v[k - 1][i - 1] % mod);
																 
	return 0;
}

Measured memory_bytes: 30080
#include <stdio.h>

int main(){
    double r;
    double x, s;
    
    scanf("%lf", &r);
    x = (double)2 * r * 3.14159265359;
    s = (double)r * r * 3.14159265359;
    
    printf("%lf %lf\n", s, x);
}


Measured memory_bytes: 2044
#include<bits/stdc++.h> 
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='A'&&s[1]=='A'&&s[2]=='A') cout<<"No";
	else if(s[0]=='B'&&s[1]=='B'&&s[2]=='B') cout<<"No";
	else cout<<"Yes";
	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
}


Measured memory_bytes: 65340
S=input()
flag = 0
for i in range(0,len(S)):
  if (i+1)%2==0 and not (S[i]=='L' or S[i]=='U' or S[i]=='D'):
    flag = 1
  elif (i+1)%2!=0 and not (S[i]=='R' or S[i]=='U' or S[i]=='D'):
    flag = 1
    
if flag==1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][] bector1=new int[n][m];
        int[] bector2=new int[m];
        int[] ans=new int[n];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                bector1[i][j]=sc.nextInt();
            }
        }
        for(int k=0;k<m;k++){
            bector2[k]=sc.nextInt();
        }
        
        for(int l=0;l<n;l++){
            for(int p=0;p<m;p++){
                ans[l]+=bector1[l][p]*bector2[p];
            }
            System.out.println(ans[l]);
        }
        
        
    }
}



Measured memory_bytes: 40048
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    if(s == "RRR")cout << 3;
    else if(s == "SRR" || s == "RRS")cout << 2;
    else if(s == "SSS")cout << 0;
    else cout << 1;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;

  vector<bool> flag(n, false);

  vector<int> pena(n, 0);

  for (int i = 0; i < m; i++) {
    int x;
    string y;

    cin >> x >> y;
    x--;

    if (y == "AC") {
      flag[x] = true;
    } else {
      if (!flag[x]) {
        pena[x]++;
      }
    }
  }

  int corr = 0, error = 0;

  for (int i = 0; i < n; i++) {
    if (flag[i]) {
      corr++;
      error += pena[i];
    }
  }

  cout << corr << " " << error << endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define vp vector<pair<ll, ll>>
#define all(a) a.begin(), a.end()
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second
#define for0(i, n) for(ll i=0; i<n; i++) 
#define for1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ll mod = 1e9+7;

void solve(){
	ll n , d; cin>>n>>d;
	ll x, y, c=0;
	while(n--){
		cin>>x>>y;
		if((x*x + y*y)<=d*d) c++;
	}
	cout<<c;
}

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll test = 1;
	//cin>>test;
	while(test--)
		solve();

	return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int count =0;
		for(int i=A;i<=B;i++){
			int a = i / 10000;
			int b = i % 10;
			int c = i / 10 % 10;
			int d = i / 1000 % 10;
			if(a==b&&c==d){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
S = input()

ans = ['S'] * N


def ok(ST):
    ret = ['S'] * N
    ret[-1] = ST[-1]
    ret[0] = ST[0]

    for i in range(0, N - 2):
        if ret[i] == 'S':
            if S[i] == 'o':
                ret[i + 1] = ret[i - 1]
            else:
                ret[i + 1] = 'W' if ret[i - 1] == 'S' else 'S'
        else:
            if S[i] == 'o':
                ret[i + 1] = 'W' if ret[i - 1] == 'S' else 'S'
            else:
                ret[i + 1] = ret[i - 1]

    for i in range(N):
        if S[i] == 'o' and ret[i] == 'S' and ret[i - 1] != ret[(i + 1) % N]:
            return False
        if S[i] == 'o' and ret[i] == 'W' and ret[i - 1] == ret[(i + 1) % N]:
            return False
        if S[i] == 'x' and ret[i] == 'S' and ret[i - 1] == ret[(i + 1) % N]:
            return False
        if S[i] == 'x' and ret[i] == 'W' and ret[i - 1] != ret[(i + 1) % N]:
            return False

    return "".join(ret)


def solve():
    for s in ["SS", "SW", "WS", "WW"]:
        r = ok(s)
        if r:
            print(r)
            return

    print(-1)


solve()

Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> v = {a,b,c};
  sort(all(v));
  cout << v[2] * 10 + v[1] + v[0] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
int ans[100005];
int a[104],cnt=0;
int dp(int n)
{
    if(n<6) return n;
    if(ans[n]!=0) {return ans[n];}
    int mi=100003;
    for(int i=cnt-1;i>=0;i--)
    {
        if(a[i]<n)
            mi=min(mi,1+dp(n-a[i]));
    }
    return ans[n]=mi;

}
int main()
{
    memset(ans,0,sizeof(ans));
    int i,n;
    scanf("%d",&n);
    for(i=6;i<=100000;i*=6)
        {a[cnt++]=i;ans[i]=1;}
    for(i=9;i<=100000;i*=9)
        {a[cnt++]=i;ans[i]=1;}
    sort(a,a+cnt);
    printf("%d\n",dp(n));
    return 0;
}


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

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int a = 0;
    int ans = 1;
    rep(i, n){
        a += l[i];
        if(a <= x){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(void)
{
	
	int n, a[5000];
	int i, j;
	int max, sum;
	
	while(1) {
	
		scanf( "%d", &n );
		if ( n == 0 ) break;
		
		for( i=0; i<n; i++ ) {
			scanf( "%d", &a[i] );
		}
		
		max = a[0];
		for ( i=0; i<n; i++ ) {
			sum = 0;
			for ( j=i; j<n; j++ ) {
				sum += a[j];
				if ( max < sum ) max = sum;
			}
		}
		printf( "%d\n", max );
	}
	return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

long long min(long long a, long long b){
    return (a < b ? a : b);
}

int main(){
    long long L, R;
    scanf("%lld%lld", &L, &R);
    long long ans;
    if(R - L >= 2018 || L % 2019 == 0 || R % 2019 == 0) ans = 0;
    else{
        ans = 2018;
        for(long long i = L; i < R; i++){
            for(long long j = i + 1; j <= R; j++)
                ans = min(ans, (i * j) % 2019);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
#AOJ A

n = int(input())
for _ in range(n):
    y,m,d = list(map(int,input().split()))
    sub = 1
    for i in range(y+1,1000):
        if i % 3 == 0:
            sub += 200
        else:
            sub += 19*5 + 100
    if y % 3 == 0:
        sub += (10 - m)*20 + (20 - d)
    else:
        if m % 2 == 0:
            sub += (19 - d) + (10 - m)//2*(20 + 19)
        else:
            sub += (10 - m + 1)//2*(20 + 19) - d
    print(sub)



Measured memory_bytes: 5592
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	h,w,d = readline() |> split |> parseMap
	a = Array{Int}(2,h*w)
	for i in 1:h
		x = readline() |> split |> parseMap
		for j in 1:w
			a[1,x[j]] = i
			a[2,x[j]] = j
		end
	end
	b = Array{Int}(h*w)
	for i in 1:h*w
		if i<=d
			b[i] = 0
		else
			b[i] = b[i-d]+abs(a[1,i]-a[1,i-d])+abs(a[2,i]-a[2,i-d])
		end
	end
	q = readline() |> parseInt
	for i in 1:q
		l,r = readline() |> split |> parseMap
		println(b[r]-b[l])
	end
end
main()

Measured memory_bytes: 209556
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static long mod = 1000000007;
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	if(N == 1){
		System.out.println(0);
	}else{
		System.out.println(1);
	}

	

    
  }
}

Measured memory_bytes: 35612
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
mult = (N + 999) // 1000

print(mult * 1000 - N)

Measured memory_bytes: 9688
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

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

	if (A > 8 || B > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
string s[1<<18];
int id[1<<18];
int nxt[1<<20][26];
int cnt[1<<20][26];
int nds=1;
int cs[26];

bool inline Compare(int a,int b){
	return s[a].size()>s[b].size();
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	cont(i,n)cin>>s[i],id[i]=i;
	sort(id+1,id+n+1,Compare);
	ll ans=0;
	cont(I,n){
		int i=id[I];
		reverse(all(s[i]));
		int t=1;
		loop(j,s[i].size()-1){
			t=nxt[t][s[i][j]-'a'];
			cs[s[i][j]-'a']++;
		}
		cs[s[i][s[i].size()-1]-'a']++;
		ans+=cnt[t][s[i][s[i].size()-1]-'a'];
		t=1;
		loop(j,s[i].size()){
			loop(k,26)if(cs[k])cnt[t][k]++;
			if(!nxt[t][s[i][j]-'a'])nxt[t][s[i][j]-'a']=++nds;
			t=nxt[t][s[i][j]-'a'];
			cs[s[i][j]-'a']--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 215672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>

using namespace std;

struct DSU {
    DSU(int N) {
        m_weight.resize(N, 1);
        m_color.resize(N);
        iota(m_color.begin(), m_color.end(), 0);
    }

    int get(int x) {
        while (x != m_color[x])
            x = m_color[x];
        return x;
    }

    void merge(int x, int y) {
        x = get(x);
        y = get(y);

        if (x == y)
            return;

        if (m_weight[x] > m_weight[y])
            std::swap(x, y);

        m_weight[y] += m_weight[x];
        m_color[x] = m_color[y];
    }

    vector<int> m_weight, m_color;
};

int main(int argc, char * argv[]) {
    int N;
    cin >> N;
    vector<pair<int, int>> X(N);
    for (auto & x : X)
        cin >> x.first >> x.second;

    map<int, vector<int>> h; // give x find all y
    map<int, int> y_to_rowid;
    for (auto & pt : X) {
        h[pt.first].push_back(pt.second);
        y_to_rowid[pt.second] = -1;
    }

    int rows = 0;
    for (auto & x : y_to_rowid) {
        x.second = rows;
        ++rows;
    }

    DSU dsu(rows);
    for (auto & x : h) {
        int y0 = x.second[0];
        for (int y1 : x.second) {
            dsu.merge(y_to_rowid[y0], y_to_rowid[y1]);
        }
    }

    map<int, set<int>> row_points, merged_row_points;
    for (auto & pt : X) {
        merged_row_points[dsu.get(y_to_rowid[pt.second])].insert(pt.first);
        row_points[y_to_rowid[pt.second]].insert(pt.first);
    }
    int64_t ops = 0;
    for (int i = 0; i < rows; ++i) {
        ops += merged_row_points[dsu.get(i)].size() - row_points[i].size();
    }

    cout << ops << endl;

    return 0;
}


Measured memory_bytes: 20992
#include<iostream>
#include<string>

using namespace std;

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

    string G[H + 2];
    string s;

    for(int i =0; i<H + 2; i++){
        if(i == 0 || i == H+1){
            for(int j = 0; j<W + 2; j++){
                G[i] += '#';
            }
        }

        else{
            cin >> s;
            G[i] = '#';
            G[i] += s;
            G[i] += '#';
        }
    }

    int L[H+2][W+2];
    int R[H+2][W+2];
    int U[H+2][W+2];
    int D[H+2][W+2];

    for(int i = 0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            if(G[i][j] == '#'){
                L[i][j] = 0;
                U[i][j] = 0;
            }
            else{
                L[i][j] = L[i][j-1] + 1;
                U[i][j] = U[i-1][j] + 1;
            }
        }
    }

    for(int i = H+1; i>=0; i--){
        for(int j=W+1; j>=0; j--){
            if(G[i][j] == '#'){
                R[i][j] = 0;
                D[i][j] = 0;
            }
            else{
                R[i][j] = R[i][j+1] + 1;
                D[i][j] = D[i+1][j] + 1;
            }
        }
    }

    int ans = 0;

    for(int i =0; i< H + 2; i++){
        for(int j =0; j<W+2; j++){
            int sum = L[i][j] + R[i][j] + U[i][j] + D[i][j];
            ans = max(ans, sum);
        }
    }

    cout << ans-3 << endl;

    return 0;
}

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

int main() {
	
	int X, Y, Z;
	cin>>X>>Y>>Z;
	
	int ans = 0;
	int sum = 0;
	bool f = false;
	while(true){
		if(f){
			if(sum + Y > X) break;
			ans++;
			sum += Y;
			f = false;
		}else{
			if(sum + Z > X) {
				if(ans > 0)ans--;
				break;
			}
			sum += Z;
			f = true;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  long N,M;
  cin >> N >> M;
  vector<long> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  vector<long> sumA(N+1,0);
  for (int i=1; i<N+1; i++) {
    sumA[i] = (sumA[i-1] + A[i-1]) % M;
  }
  sort(sumA.begin(),sumA.end());
  sumA.insert(sumA.end(),-1);
  long num = 1;
  long ans = 0;
  for (int i=1; i<N+2; i++) {
    if (sumA[i] != sumA[i-1]) {
      if (num == 1) {
        continue;
      }
      ans += num * (num-1) / 2;
      num = 1;
      continue;
    }
    num++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
# ABC 075
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def getIntFromRows(n): return [int(input()) for i in range(n)]
def getIntMat(n):
    mat = []
    for i in range(n): mat.append(getIntList())
    return mat
def zeros(n): return [0 for i in range(n)]
def zeros2(n, m): return [[0 for i in range(m)] for j in range(n)]

debug = True
def db(x): 
    if debug: print(x)

debug = False
n,m = getIntList()
a,b = zeros(m),zeros(m)
org = zeros(m)

for i in range(m):    org[i] = getIntList()

db(('org graph',org))
count = 0

def find(graph, fromNode, toNode, route): # -1: NG, >=OK、評価値
    db(('f-t',fromNode, toNode))
    if fromNode in route: return -1
    else:
        route = route + [fromNode]
        if fromNode==toNode: return 0
        for edge in graph:
            if edge[0]==fromNode:  # graphのソート、一旦fromが見つかった後の中断
                val = find(graph, edge[1], toNode, route)
                db(('found', route, edge[1], toNode))
                if val==0: return 0
        db(('cannot',fromNode, toNode))
        return -1
    
graph = zeros((m-1)*2)
count = 0
for i in range(m):
    new = org[:i] + org[i+1:]
    db(('cut',org[i]))
    db(('new',new))
    for j in range(m-1):
        graph[j*2] = new[j]
        graph[j*2+1] = [new[j][1], new[j][0]]
    graph.sort()
    db(('new graph',graph))
    route = []
    if find(graph, org[i][0], org[i][1], route)<0: count += 1
print(count)

def connected(graph, node): # 全ノードに行けるか
    db(('check node', node))
    for i in range(n):
        if i==node: continue
        found = False
        for e in graph:
            #db(('edge',e))
            if e[0]==node and e[1]==i: 
                found = True
                break
        if not found: return False
    db(('ok node', node))
    return True



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string str;
	char c;
	cin>>str;
	set<string> s;
	c=str[str.length()-1];
	s.insert(str);
	int flag=1;
	for(int i=1;i<n;i++){
		cin>>str;
		if(c!=str[0]||s.count(str))
			flag=0;
		s.insert(str);
		c=str[str.length()-1];
	}
    if(flag==0){
    	cout<<"No";
	}else{
		cout<<"Yes";
	}
} 



Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    ll x;
    scanf("%lld",&x);
    for (ll a = -500;a <= 500;a ++) {
        for (ll b = -500;b <= 500;b ++) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                printf("%lld %lld\n",a,b);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include<cmath>
#include<cstdio>
using namespace std;
char c,d;
int ans;
int main(){
	c=getchar();
	d=0;ans=-1;
	while ((c!=0)&&(c!='\n')){
		if (c!=d){
			d=c;
			ans++;
		}
		c=getchar();
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int n,s=0;
long long int a[1000000];
int main()
{
	cin>>n;
	for(long long int i=1;i<=n*2;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i++)
	{
		s+=a[i];
		i++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class unionFind{
  constructor(n){this.a=Array(n+1).fill(-1);}
  root(i){
    return this.a[i]<0?i:this.a[i]=this.root(this.a[i]);
  }
  same(x,y){return this.root(x)===this.root(y);}
  unite(x,y){
    const a=this.a;
    x=this.root(x),y=this.root(y);
    if(x===y)return false;
    if(a[y]<a[x])a[y]+=a[x],a[x]=y;
    else a[x]+=a[y],a[y]=x;
    return true;
  }
  size(i){return -this.a[this.root(i)];}
}

function main(){
  var n = next(), m = next();
  var uf = new unionFind(n);
  for(var i = 0; i < m; i++){
    var [a,b] = nexts(2);
    uf.unite(a,b);
  }
  return -Math.min(...uf.a);
}
if (process.argv[2] === "--stack-size=262144" || process.argv.length < 3) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=480000"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(String(myOut));
}

Measured memory_bytes: 106124
import itertools
import math


if __name__ == '__main__':
    n = int(input())
    xy = [list(map(int,input().split())) for i in range(n)]

    sum_length = 0.0
    sum_count = 0

    for i in itertools.permutations(range(n)):
        sum_count+=1
        for j in range(1,len(i)):
            sum_length += math.sqrt((xy[i[j-1]][0]-xy[i[j]][0])**2+(xy[i[j-1]][1]-xy[i[j]][1])**2)

    print(sum_length/sum_count)




Measured memory_bytes: 3064
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    H, W = map(int, input().split())
   
    dp = [[0]*W for i in range(H)]
    route = []
    for h in range(H):
        As = input().strip()
        route.append(As)

    for h in range(H):
        for w in range(W):
            if h == 0 and w == 0:
                dp[h][w] = 1
                continue
            if h > 0 and route[h-1][w] != '#':
                dp[h][w] += dp[h-1][w]
            if w > 0 and route[h][w-1] != '#':
                dp[h][w] += dp[h][w-1]

    print(dp[H-1][W-1] % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 167992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        
        if(S.length()<=K){
            System.out.println(S);
        } else {
            System.out.println(S.substring(0,K)+"...");
        }
        
    }
}


Measured memory_bytes: 38592
s = input()
q = int(input())
a, b = '', ''
cnt = 0
for _ in range(q):
    que = input().split()
    if que[0] == '1':
        cnt += 1
    else:
        if (cnt+int(que[1])) %2 == 0:
            a += que[2]
        else:
            b += que[2]
if cnt%2 == 1:
    s = a[-1::-1]+s[-1::-1]+b
else:
    s = b[-1::-1]+s+a
print(s)

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

int N;
string S;

int main() {
  cin >> N >> S;
  int ans = 0;
  REP(i, 1, N) {
    string X = S.substr(0, i);
    string Y = S.substr(i, N-i);
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());
    int temp = 0;
    REP(i, 0, X.size()) {
      REP(j, 0, Y.size()) {
        if (X[i] == Y[j]) temp++;
      }
    }
    ans = max(ans, temp);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

constexpr static int MAXN = 1e6;

int n;
int a[MAXN];

bool solve() {
    int64_t stepsum = 1LL * n * (n + 1) / 2;
    int64_t sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];
    if (sum % stepsum != 0)
        return false;
    int64_t cnt = sum / stepsum;
    // x + y == cnt
    // 1*x - (n-1)*y == diff
    // cnt - y - (n-1)*y == diff
    // cnt - diff = n*y
    int64_t ytotal = 0;
    for (int i = 0; i < n; i++) {
        int diff = a[(i + 1) % n] - a[i];
        if (cnt - diff < 0)
            return false;
        if ((cnt - diff) % n != 0)
            return false;
        ytotal += (cnt - diff) / n;
    }
    return ytotal == cnt;
}

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

    if (solve())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 640
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF =1e9;
const ll LINF=1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a / gcd(a, b)*b;}
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        s[i]='x';
    }
    cout << s << "\n";
}



Measured memory_bytes: 256
from math import sqrt
N = int(input())
ans = [0] * (N+1)

for x in range(1, int(sqrt(N)) + 2):
    for y in range(1,int(sqrt(N)) + 2):
        for z in range(1, int(sqrt(N)) + 2):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n] += 1

for i in range(1, len(ans)):
    print(ans[i])

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s,t; cin >> s >> t;
	cout << t << s << endl;
}

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

char s[15];
int n;
void dfs(int d)
{
    if(d==n){
        printf("%s\n",s);
        return ;
    }
    int mx = -1;
    for(int i=0;i<d;i++){
        mx = max(mx,s[i]-'a');
    }
    for(int i=0;i<=mx+1;i++){
        s[d] = 'a' + i;
        dfs(d+1);
    }
}

int main()
{
    while(scanf("%d",&n)==1){
        dfs(0);
    }
    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a>>b>>c;
  
  cout<<min(b/a,c)<<endl;
 
}



Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
	int fun;
	int cost;
	int vote;
}sports;

int main(void){
	sports a[1000];
	int b[1000];
	int n, m, i, j;
	
	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++) {
		scanf(" %d", &a[i].cost);
		a[i].fun = i+1;
		a[i].vote = 0;
	}
	for(i=0; i<m; i++)
		scanf(" %d", &b[i]);
		
	for(i=0; i<n-1; i++) {
		for(j=i; j<n; j++) {
			if(a[i].cost > a[j].cost){
				sports tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
		
	for(i=0; i<m; i++){
		int select = 0;

		for(j=0; j<n; j++){
			if(b[i] < a[j].cost) break;
				
			if(a[select].fun > a[j].fun)
				select = j;
		
		}
		
		a[select].vote++;
		//printf("b[%d] voted %d;\n", i ,select);
	}
	
	int max=0;
	for(i=0; i<n; i++){
		if(a[i].vote > a[max].vote)
			max = i;
	}
	
	printf("%d\n", a[max].fun);

	return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return 1;} return 0; }
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return 1;} return 0; }

int N;
vector<long long> dp, h;
const long long inf = (1 << 30);

int main() {
    int N; scanf("%d", &N);
    dp.resize(N);
    h.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", & h[i]);
    for (int i = 0; i < N; i++) dp[i] = inf;
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i >= 2) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    printf("%d\n", dp[N-1]);
    return 0;
    
}



Measured memory_bytes: 1792
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

S=input()
K=II()
DP=[[[0]*len(S) for _ in range(K+1)] for _ in range(2)]

for i in range(int(S[0])+1):
    if i < int(S[0]) and i > 0:
        DP[1][1][0] += 1
    elif i == 0:
        DP[1][0][0] = 1
    else:
        DP[0][1][0] = 1

for i in range(1, len(S)):
    n = int(S[i])
    DP[1][0][i] = DP[1][0][i-1]
    for j in range(K):
        DP[1][j+1][i] = (
            # 0の場合
            DP[1][j+1][i-1] +
            # 0以外の場合
            9*DP[1][j][i-1])
        if n != 0:
            DP[1][j+1][i] += (n-1)*DP[0][j][i-1]
            DP[0][j+1][i] = DP[0][j][i-1]

    for j in range(K+1):
        if n != 0:
            DP[1][j][i] += DP[0][j][i-1]
        else:
            DP[0][j][i] = DP[0][j][i-1]

print(DP[1][K][len(S)-1] + DP[0][K][len(S)-1])


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

int N, K;
vector<vector<int> > tree;

// 頂点 v を根として、p のある側は切り落としてできる部分木について
// v から各頂点への距離を depth に格納する
// (特に p = -1 のときは、ツリー全体について v を根とすることを表す)
void rec(int v, int p, int curdepth, vector<int> &depth) {
    depth[v] = curdepth;
    for (auto nv : tree[v]) {
        if (nv == p) continue;
        rec(nv, v, curdepth + 1, depth);
    }
}

int main() {
    cin >> N >> K;
    tree.assign(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        tree[a].push_back(b); tree[b].push_back(a);
    }
    int res = N; // INF の気持ち
    vector<int> depth(N);
    if (K % 2 == 0) {
        for (int v = 0; v < N; ++v) {
            rec(v, -1, 0, depth);
            int num = 0;
            for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
            res = min(res, num);
        }
    }
    else {
        for (int u = 0; u < N; ++u) {
            for (auto v : tree[u]) {
                depth[v] = depth[v] = 0;
                rec(u, v, 0, depth); rec(v, u, 0, depth);
                int num = 0;
                for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
                res = min(res, num);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t x;
    cin >> x;
    int64_t ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
// abc142_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<P> A(N);
    REP(i, N) {
        cin >> A[i].first;
        A[i].second = i+1;
    }
    sort(ALL(A));
    REP(i, N-1){
        cout << A[i].second <<  " ";
    }
    cout << A[N-1].second << endl;




    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#define NUMBER 100001

int main(void)
{
    int n, m, q;
    char s[3], t[NUMBER][1];
    int i;
    int sum_ac = 0, sum_wa = 0;
    int wa[NUMBER] = {0};
    
    for(i = 0; i < NUMBER; i++)
        t[i][0] = 'W';
    
    scanf("%d%d", &n, &m);
    
    while(m--){
        scanf("%d%s", &q, &s);
        if(t[q][0] == 'W')
            if(s[0] == 'W') wa[q]++;
            else{
            	sum_ac++;
            	sum_wa += wa[q];
            	t[q][0] = 'A';
            }
    }
    
    printf("%d %d", sum_ac, sum_wa);

    return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func scanNums(l int) [][]int {
	nums := make([][]int, 2)
	var a int
	for i := 0; i < len(nums); i++ {
		nums[i] = make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&a)
			nums[i][j] = a
		}
	}
	return nums
}
func main() {
	var n int
	fmt.Scan(&n)
	nums := scanNums(n)

	var sum int
	max := 0
	for i := 0; i < n; i++ {
		sum = 0
		for j := 0; j <= i; j++ {
			sum += nums[0][j]
		}
		for j := i; j < n; j++ {
			sum += nums[1][j]
		}
		if sum > max {
			max = sum
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> v;
    int N, K;
    cin >> N >> K;
    {
        int tmp;
        while (cin >> tmp) {
            v.push_back(tmp);
        }
    }
    //auto min = min_element(v.begin(), v.end());
    int ans = 0;
    int tmp = (int)v.size() - K;
    ans = tmp / (K - 1) + ((tmp % (K - 1) == 0) ? 0 : 1);
    cout << ans + 1 << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,ss;
  string s;
  cin >> n >> s;
  ss = (int)(s.length());
  for(int i;i < ss; i++)
  {
      s[i] += n;
      if(s[i] > 90)
      {
          s[i] = 64 + s[i] % 90;
      }
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 256