akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {


    public void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int ans = Integer.MAX_VALUE;
        for (char ch : str.toCharArray()) {
            String s = str;
            int cnt = 0;
            while (true) {
                boolean go = false;
                for (int i = 0; i < s.length(); i++)
                    if (s.charAt(i) != ch) {
                        go = true;
                        break;
                    }
                if (!go) break;
                cnt++;
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < s.length() - 1; i++) {
                    if (s.charAt(i) == ch || s.charAt(i + 1) == ch) {
                        sb.append(ch);
                    } else {
                        sb.append(s.charAt(i));
                    }
                }
                s = sb.toString();
            }
            ans = Math.min(ans, cnt);
        }
        out.println(ans);
    }


}


class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 24768
def odd_even_same(p):
  t,x,y=p[0],p[1],p[2]
  if (x+y)%2==t%2:
    return 1
  else:
    return 0
def dist_judge(p):
  t,x,y=p[0],p[1],p[2]
  if t >= x+y:
    return 1
  else:
    return 0
N=int(input())
p=[]
for i in range(N):
  p.append(list(map(int,input().split())))
for i in p:
  if odd_even_same(i)*dist_judge(i):
    pass
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 27300
[n, w] = map(int, input().split())
weights = []
values = []
for i in range(n):
    weight, value = [int(i) for i in input().split()]
    weights.append(weight)
    values.append(value)
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(n):
    for weight in range(w+1):
        if weight - weights[i] >= 0:
            dp[i+1][weight] = max(dp[i][weight-weights[i]] + values[i], dp[i+1][weight])
        dp[i+1][weight] = max(dp[i+1][weight], dp[i][weight])

print(dp[n][w])

Measured memory_bytes: 171684
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const MOD = 1000000007
const size = 2100000

var fact [size + 1]int
var factInv [size + 1]int
var seqInv [size + 1]int

func createFactMod() {
	fact[0] = 1
	fact[1] = 1
	for i := 2; i < size; i++ {
		fact[i] = fact[i-1] * i % MOD
	}
}

func createInvMod() {
	seqInv[0] = 1
	seqInv[1] = 1
	for i := 2; i < size; i++ {
		seqInv[i] = (MOD - MOD/i) * seqInv[MOD%i] % MOD
	}
}

func createFactInvMod() {
	factInv[0] = 1
	factInv[1] = 1
	for i := 2; i < size; i++ {
		factInv[i] = factInv[i-1] * seqInv[i] % MOD
	}
}

func initTables() {
	createFactMod()
	createInvMod()
	createFactInvMod()
}

func comb(n, k int) int {
	return ((fact[n] * factInv[n-k]) % MOD * factInv[k]) % MOD
}

// 乗数計算（MOD)
func mpow(x, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % MOD
		}
		x = x * x % MOD
		n = n >> 1
	}
	return ans
}

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	initTables()

	sc.Split(bufio.ScanWords)

	r1, c1, r2, c2 := getInt(), getInt(), getInt(), getInt()

	x00 := comb(r1+c1, c1)
	x10 := comb(r2+c1+1, c1)
	x01 := comb(r1+c2+1, c2+1)
	x11 := comb(r2+c2+2, c2+1)

	ans := (x11 + x00) % MOD
	ans = ans - x01
	if ans < 0 {
		ans += MOD
	}
	ans = ans - x10
	if ans < 0 {
		ans += MOD
	}
	out(ans)
}


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

int main(){
        int n;
        scanf("%d", &n);
        std::vector<int> a(n+1);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);

        std::vector<int> ans(n+1, 0);
        for(int i=n; i>0; i--){
                int cnt = 0, j = i+i;
                while(j<=n){
                        cnt += ans[j];
                        j += i;
                }
                if(cnt%2!=a[i]){
                        ans[i] = 1;
                        ans[0]++;
                }
        }

        printf("%d\n", ans[0]);
        for(int i=1; i<=n; i++){
                if(ans[i]) printf("%d\n", i);
        }
        return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  char e;
  cin>>e;
  cout<<++e;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
//   cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3588
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n, m, k; 

char arr[7][7];

bool check(int mask_r, int mask_c) {
	// cout<<"for "<<mask_r<<" "<<mask_c<<endl;
	int cnt = 0;
	for(int i = 0 ; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(((1 << i) & mask_r) != 0) continue;
			if(((1 << j) & mask_c) != 0) continue;
			if(arr[i][j] == '#') cnt++;
			// cout<<arr[i][j]<<" "<<cnt<<endl;
			if(cnt > k) return false;
		}
	}
	// cout<<cnt<<endl;
	return cnt == k;
}

set<pair<int, int> > vis;

// int solve(int idx, int jdx, int mask_r, int mask_c) {
// 	// cout<<idx<<" "<<jdx<<" "<<mask_r<<" "<<mask_c<<endl;
// 	if(idx > n || jdx > m)
// 		return 0;

// 	if(idx == n && jdx == m) {
// 		if(vis.find({mask_r, mask_c}) == vis.end()) {
// 			vis.insert({mask_r, mask_c});
// 			return check(mask_r, mask_c);	
// 		} 
// 		return 0;
// 	}
	
// 	int new_mask_r = mask_r;
// 	new_mask_r |= (1 << idx);
// 	int new_mask_c = mask_c;
// 	new_mask_c |= (1 << jdx);

// 	// cout<<new_mask_c<<" "<<new_mask_r<<endl;

// 	int ans = solve(idx + 1, jdx, mask_r, mask_c);
// 	ans += solve(idx + 1, jdx, new_mask_r, mask_c);

// 	ans += solve(idx, jdx + 1, mask_r, mask_c);
// 	ans += solve(idx, jdx + 1, mask_r, new_mask_c);

// 	ans += solve(idx + 1, jdx + 1, mask_r, mask_c);
// 	ans += solve(idx + 1, jdx + 1, new_mask_r, mask_c);
// 	ans += solve(idx + 1, jdx + 1, mask_r, new_mask_c);
// 	ans += solve(idx + 1, jdx + 1, new_mask_r, new_mask_c);

// 	return ans;
// }

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin>>n>>m>>k;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++) 
			cin>>arr[i][j];


	// for(int i = 0 ; i < n ; i++) {
	// 	for(int j = 0; j < m; j++) {
	// 		cout<<arr[i][j]<<" ";
	// 	}cout<<endl;
	// }

	int ans = 0;
	for(int i = 0 ; i < (1 << n); i++) {
		for(int j = 0; j < (1 << m); j++) {
			if(check(i, j)) 
				ans++;
		}
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
A=list(map(int,input().split()))
B=[]
q=A[1]
from collections import deque
D=deque()
for i in range(A[0]):
    
    L=list(map(str,input().split()))
    L[1]=int(L[1])
    D.append(L[:])
    
    
time=0
while len(D):
    a=D.popleft()
    if a[1]<=q:
        time+=a[1]
        print(f'{a[0]} {time}')
    else:
        time+=q
        D.append([a[0],a[1]-q])


Measured memory_bytes: 13320
package main

import "fmt"

func calc(x int) int {
	sum := 0
	for x > 0 {
		sum += x % 10
		x /= 10
	}
	return sum
}

func main() {
	var n, a, b, ans int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		sum := calc(i)
		if sum >= a && sum <= b {
			ans += i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn],b[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i],b[i]=a[i];
    sort(a,a+n);
    int m1=a[n/2-1],m2=a[n/2];
    for(int i=0;i<n;i++)
    {
        if(b[i]<=m1) cout<<m2<<endl;
        else cout<<m1<<endl;
    }
}


Measured memory_bytes: 3712
import sys
from bisect import bisect_left
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lst = list(map(int, readline().split()))
lst.sort()
lst.reverse()
mul = 1
if 0 in lst : 
  print(0)
else :
  for x in lst :
 #   print(x,mul)
    if(mul>10**18):
      mul = -1
      break
    mul*=x

  if mul> 10**18 :
    mul = -1

  print(mul)


Measured memory_bytes: 85844
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_S = 100001, MOD = 1000000007;
    string S;
    cin >> S;
    int N = S.size();
    ll dp[MAX_S][4] = {};
    RREP(i, N) {
        RREP(j, 3) {
            if (i == N) {
                dp[i][j] = (j == 3 ? 1 : 0);
            } else {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3LL : 1LL);
                if (j < 3 && (S[i] == '?' || S[i] == "ABC"[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int dp[101][101][101];

signed main(void) {
	int R;
	cin >> R;
	std::cout << std::fixed;
	std::cout << std::setprecision(5) << R * 2 * 3.14159265359; 
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

int main() {
    lli x,y;
    scanf("%lld%lld",&x,&y);
    int ans=0;
    while(x<=y) {
        ans++; x*=2;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct rest{
  ll num;
  str city;
  ll points;

  rest(ll n, str c, ll p){
    num = n, city = c, points = p;
  }
};

bool comp(rest r1, rest r2){
  if(r1.city!=r2.city){
    return r1.city<r2.city;
  }else{
    return r1.points>r2.points;
  }
}

int main(){
  ll n; cin >> n;
  vector<rest> r;
  REP(i,n){
    str s; int p;
    cin >> s >> p;
    r.push_back(rest(i+1,s,p));
  }
  sort(r.begin(),r.end(),comp);
  REP(i,n){
    cout << r[i].num << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	vector<int>t(N + 1 , 0);
	vector<P>v(N + 1);
	v[0] = make_pair(0, 0);
	rep(i, N) {
		cin >> t[i + 1];
		P a;
		cin >> a.first >> a.second;
		v[i + 1] = a;
	}
	rep(i, N) {
		int num = abs(v[i + 1].first - v[i].first) + abs(v[i + 1].second - v[i].second);
		if (num > t[i + 1] - t[i]) {   
			cout << "No";
			return 0;
		}
		if (!(num % 2 == (t[i+1]-t[i])%2)) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug() {cerr<<endl;}
	template<class T> debug& operator<<(T x) {cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
#else
	template<class T> debug& operator <<(const T&) {return *this;}
#endif
};


bool solve(void) {

	string s, t;
	cin>>s>>t;
	int a, b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u == s) a--;
	else b--;
	cout << a<< ' ' << b << endl;
	return true;
}

int main(int argc, char* argv[]) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,Y; cin >> N >> Y;
    Y /= 1000;
    int x,y,z;
    int d = Y-N;

    if(d<0){
        cout << "-1 -1 -1" << endl;
        return 0;
    }else{
        int x = 0;
        int y,z;
        z = -1;
        while(9*x <= d){
            if((d-9*x)%4 == 0){
                y = (d-9*x)/4;
                z = N-x-y;
                if(z>=0) break;
            }
            x++;
        }
        if(z>=0) cout << x << " " << y << " " << z << endl;
        else cout << "-1 -1 -1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
    string S;
    int tmpCount = 0;
    vector<int> tmp;
    cin >> S;
    for (int count = 0; count < S.size(); count++)
    {
        for (int index = count; index < S.size(); index++)
        {
            if (S.at(count) == S.at(index))
            {
                tmpCount++;
            }
        }
        if (tmpCount == 1)
        {
            tmp.push_back(1);
        }
      	tmpCount = 0;
    }
    if (tmp.size() == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

long long test,n,m,check,d[100001],mark[100001],pre[100001];
vector <int> a[100001];
void bfs()
{
    queue <int> qu;
    qu.push(1);
    mark[1]=1;
    d[1]=0;
    check=1;
    pre[1]=0;
    while (qu.size())
    {
        int u=qu.front();
        qu.pop();
        int m=a[u].size();
        for (int i=0;i<m;i++)
        {

        int v=a[u][i];
        if (!mark[v])
        {
            qu.push(v);
            mark[v]=1;
            d[v]=d[u]+1;
            pre[v]=u;
            check++;
        }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //cin>>test;
    test=1;
   
    while (test--)
    {
        cin>>n>>m;
        for (int i=1;i<=m;i++)
        {
            int u,v;
            cin>>u>>v;
            a[u].push_back(v);
            a[v].push_back(u);
        }
        bfs();
        if (check!=n) cout<<"No";
        else
        {
            cout<<"Yes"<<endl;
            for (int i=2;i<=n;i++) cout<<pre[i]<<endl;
        }
        
        
    }
    
}    




Measured memory_bytes: 12444
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

/*（๑•﹏•๑｀) */

int main() {
    int A,B;
    cin >> A >> B;
    int ans;

    if (A > B) swap(A,B);
    if (B-A >= 1) ans = B + (B-1);
    else if (B==A) ans = A + B;

    cout << ans << "\n";

}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}



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

int main(){
  long n;
  cin >>n;
  long a,b,c,d=n-1;
  for(int i=1; i<=sqrt(n); i++){
  	if(n%i==0){
      a=i;b=n/i;
      c=a+b+-2;
      d=min(c,d);
    }
  }
  
  cout << d << endl;
  
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}



Measured memory_bytes: 3596
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    s = 0
    for a in A:
        s ^= a
    ans = [s ^ a for a in A]
    print(*ans) 


if __name__ == "__main__":
    main()


Measured memory_bytes: 31500
#include<cstdio>
using namespace std;
int main()
{
	int n,i,j,a,b,c,d,x[100],y[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x[i]=0;
		y[i]=1;
	}
	for(i=0;i<n*(n-1)/2;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d)	x[a]+=3;
		else if(c<d)	x[b]+=3;
		else{
			x[a]++;
			x[b]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(x[i]<x[j])	y[i]++;
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",y[i]);
	}
	return 0;
}


Measured memory_bytes: 2688
import itertools

a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
k = int(input())

ok = True
for i, j in itertools.product(a, a):
    if (j - i) < 0:
        continue
    if k >= (j - i):
        pass
    else:
        ok = False
        break

if ok:
    print("Yay!")
else:
    print(":(")

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

const int INF = 1<<29;
int dp[10005]; //dp[j]:=体力jを消費するまでの魔力の最小値.

int main(){
    int H, N;
    int a[1000], b[1000];

    cin >> H >> N;
    for(int i=0; i<N; i++) cin >> a[i] >> b[i];

    for(int i=0; i<=H; i++) dp[i] = INF;
    dp[0] = 0;

    for(int i=0; i<N; i++){
        for(int j=1; j<=H; j++){
            if(j <= a[i]) dp[j] = min(dp[j], b[i]);
            else dp[j] = min(dp[j], dp[j-a[i]]+b[i]);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    map<string, int> hist;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        int count = hist[s];
        hist[s] = count + 1;
    }
    int max_value = 0;
    for (auto entry: hist) {
        max_value = max(max_value, entry.second);
    }
    for (auto entry: hist) {
        if (entry.second == max_value) {
            cout << entry.first << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 25216
# ABC 115, c
n, k = [int(el) for el in input().split(' ')]
H = sorted([int(input()) for i in range(n)])

min_d = 10**9
for i in range(n-k+1):
    min_d = min(min_d, H[i+k-1] - H[i])
print(min_d)





Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  set<int> s;
  for (int i = 0; i < n; i ++) {
    int t; cin >> t;
    s.insert(t);
  }

  if (n == s.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

typedef pair<int,int> P;

int main(void){
    int N,M;
    cin>>N>>M;
    
    map<P,bool> ma;
    for(int i=0;i<2*M;i++){
        int a,b;
        cin>>a>>b;
        
        ma[P(a,b)]=true;
        ma[P(b,a)]=true;
        
    }
    
    bool judge=false;
    for(int i=2;i<=M;i++){
        if(ma[P(1,i)]&&ma[P(i,N)]){
            judge=true;
            break;
        }
    }
    
    if(judge) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 37760
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int X[4]={0,0,-1,1};
int Y[4]={-1,1,0,0};
int w,h;
int ans[50][50];
int bl[50][50];
int wh[50][50];

void black(int x,int y){
	bl[x][y]=1;
	for(int i=0;i<4;i++){
		if(x+X[i]>-1&&x+X[i]<w&&y+Y[i]>-1&&y+Y[i]<h){
			if(ans[x+X[i]][y+Y[i]]==0&&bl[x+X[i]][y+Y[i]]==0){black(x+X[i],y+Y[i]);}
		}
	}
}

void white(int x,int y){
	wh[x][y]=1;
	for(int i=0;i<4;i++){
		if(x+X[i]>-1&&x+X[i]<w&&y+Y[i]>-1&&y+Y[i]<h){
			if(ans[x+X[i]][y+Y[i]]==0&&wh[x+X[i]][y+Y[i]]==0){white(x+X[i],y+Y[i]);}
		}
	}
}


int main() 
{
	while(cin>>w>>h&&!(w==0&&h==0)){
		REP(i,50){REP(j,50){ans[j][i]=0;bl[j][i]=0;wh[j][i]=0;}}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				char tmp;
				cin>>tmp;
				switch(tmp){
				  case 'B':ans[j][i]=1;break;
				  case 'W':ans[j][i]=2;break;
				}
			}
		}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				int tmp1(false),tmp2(false);
				for(int k=0;k<4;k++){
					if(j+X[k]>-1&&j+X[k]<w&&i+Y[k]>-1&&i+Y[k]<h){
						if(ans[j+X[k]][i+Y[k]]==1){tmp1=true;}
						if(ans[j+X[k]][i+Y[k]]==2){tmp2=true;}
					}
				}
				if(tmp1&&bl[j][i]!=1&&ans[j][i]==0){black(j,i);}
				if(tmp2&&wh[j][i]!=1&&ans[j][i]==0){white(j,i);}
			}
		}
		
		int ans1(0),ans2(0);
		REP(i,h){REP(j,w){
				if(bl[j][i]+wh[j][i]==2){;}
				else if(wh[j][i]==1){ans2++;}
				else if(bl[j][i]==1){ans1++;}
			}
		}
		
		cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
N = int(input())
a = [int(x) for x in input().split()]

dp = [[[] for _ in range(N)] for _ in range(N)]
for i in range(N):
    dp[i][i] = a[i]

for l in range(1, N):
    for i in range(N-l):
        dp[i][i+l] = max(a[i] - dp[i+1][i+l], a[i+l] - dp[i][i+l-1])

print(dp[0][N-1])

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

int main() {
    string S , T ;
    cin >> S >> T ; // S and T are strings of lengths between 1 and 100 (inclusive) consisting of lowercase English letters
    string str[2] = { T , S} ;
    for(int i = 0 ; i <= 1 ; i++){
        cout << str[i] ; } 
	return 0;
}

Measured memory_bytes: 3516
rp = input().split()
n = len(rp)-1
i = 1
while n:
    if rp[i] in ('+', '-', '*'):
        i -= 1
        rp[i], rp[i+1] = rp[i+1], rp[i]
        rp[i-1] = str(eval(''.join(rp[i-1:i+2])))
        del rp[i:i+2]
        n -= 2
    else:
        i += 1
print(*rp)

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1;;) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if (i) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 7140
import fractions

def x(k, c, d):
    rl1 = k
    lcm = c*d // fractions.gcd(c,d)
    ccount = rl1 // c
    dcount = rl1 // d
    cdcount = rl1 // lcm
    # if lcm != 0:
    #     cdcount = int(rl1 // lcm)
    # else:
    #     cdcount = 0

    return rl1 - ccount - dcount + cdcount

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))

Measured memory_bytes: 5048
#include<queue>
#include<vector>
#include<stack>
#include<math.h>
#include<stdint.h>
#include<memory.h>
#include<deque>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<bitset>
int main(){
    int n,k,p[2000],s=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    std::sort(p,p+n);
    for(int i=0;i<k;i++){
        s+=p[i];
    }
    printf("%d\n",s);
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll n,k;
    cin >> n >> k;
    vector<ll> h(n),dp(n,INF);
    REP(i,n)cin >> h[i];
    dp[0] = 0;
    for(ll i = 1;i < n;i++){
        ll min_prev = INF;
        for(ll j = 1;j <= k && i - j >= 0;j++){
            min_prev = min(abs(h[i] - h[i - j]) + dp[i-j],min_prev);
        }        
        dp[i] = min_prev;
    }
    cout << dp[n-1] << endl;

    return 0;
}    

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int p = 998244353;
int N_MAX = 100000;
int main()
{
  int n,t,i;
  int d[N_MAX];
  long long c1,c2,res=1;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> d[i];
  if(d[0]>0){
    cout << "0" << endl;
    return 0;
  }
  sort(d+1,d+n);
  if(d[1]==0){
    cout << "0" << endl;
    return 0;
  }
  t=0;
  c2=1;
  for(i=1;i<n;i++)
    if(d[i]>=t+2){
      cout << "0" << endl;
      return 0;
    }else if(d[i]==t+1){
      t++;
      c1=c2;
      c2=1;
      res*=c1;
      res%=p;
    }else{
      c2++;
      res*=c1;
      res%=p;
    }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191024
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3])
            {
                Console.WriteLine("No");
            }
            else if ((s[0]==s[1] && s[2] ==s[3]) || (s[0]==s[2] && s[1]==s[3]) ||(s[0]==s[3] && s[1]==s[2]))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


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

ll N,A;
  cin>>N>>A;
  
  if(N%500<=A){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
 

  
  
}



Measured memory_bytes: 256
A=range(input())
P=[map(int,raw_input().split())+[i]for i in A]
o=sorted
def r(x):
 if A[x]<x:A[x]=x=r(A[x])
 return x
def u((w,X)):x,y=o(map(r,X));A[y]=x;return(x<y)*w
def s(i):P.sort(key=lambda x:x[i]);return[(q[i]-p[i],(q[2],p[2]))for p,q in zip(P,P[1:])]
print sum(map(u,o(s(0)+s(1))))


Measured memory_bytes: 65024
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);

    int x = in.nextInt();
    boolean ok = false;
    for (int a = -120; a < 121; a++) {
      if (ok) break;
      for (int b = -120; b < 121; b++) {
        if (Math.pow(a, 5) - Math.pow(b ,5) == x) {
          System.out.println(a + " " + b);
          ok = true;
          break;
        }
      }
    }
  }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1) throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0) return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c)) c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 36532
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int n,i;
    string str;
    map<string,int>mp;
    cin>>n;
    mp.insert({"AC",0});
    mp.insert({"WA",0});
    mp.insert({"TLE",0});
    mp.insert({"RE",0});
    for(i=0; i<n; i++)
    {
        cin>>str;

        mp[str]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
     cout<<"WA x "<<mp["WA"]<<endl;
      cout<<"TLE x "<<mp["TLE"]<<endl;
       cout<<"RE x "<<mp["RE"]<<endl;




    return 0;
}





Measured memory_bytes: 3664
n = int(raw_input())
d = [i for i in range(1,2*n+1)]
m = int(raw_input())
for i in range(m):
    k = int(raw_input())
    if k == 0:
        for j in range(n):
            d += [d[j]]+[d[n+j]]
        d = d[2*n:]
    else:
        d = d[k:]+d[:k]
for i in d:
    print i

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
int dp[1<<18][20];
int a[18],b[18];
int n;
int DP(int x,int now,int p){
   // printf("%d %d\n",x,p);
    assert(x&(1<<p));
    if(__builtin_popcount(x)==1)return 0;
    if(dp[x][p]!=-1)return dp[x][p]; 
    dp[x][p]=1e9;
    int add=0;
    for(int i= p+1;i<n;i++){
        if(x&(1<<i)){
            add++;
        }
    }
    int val;
    if((p&1)==(now&1))val=a[p];
    else val=b[p];
    for(int i=0;i<n;i++){
        if((x&(1<<i))&&(i!=p)){
            int val2;
            if((i&1)==((now-1)&1)){
                val2=a[i];
            }
            else{
                val2=b[i];
            }
            if(val2<=val){
                dp[x][p]=min(dp[x][p],DP(x-(1<<p),now-1,i)+add);
            }
        }
    }
    //printf("%d %d %d %d %d\n",x,p,dp[x][p],now,val);
    return dp[x][p];
}
int main(){
    scanf("%d",&n);
    for(int i = 0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i = 0;i<n;i++)
        scanf("%d",&b[i]);
    int ans=1e9;
        MEMS(dp);
    for(int i =0;i<n;i++){
        ans=min(ans,DP((1<<n)-1,n-1,i));
    }
    if(ans==1e9)ans=-1;
    printf("%d\n",ans);
}
/*
2 6
5 7
7 5
4 3
6 4
7 3
6 5
5 7
3 6
4 7
*/
//a+a+1=10a+1
//3a+2=10a+2

Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

map<char, int> state;
map<int, char> animal;

int main()
{
	animal[0] = 'S';
	animal[1] = 'W';
	state['S'] = 0;
	state['W'] = 1;
	int n;
	cin >> n;
	string s;
	cin >> s;
	string t = string(n, ' ');
	bool works = false;
	for (int i = 0; i <= 1; ++i) {
		t[0] = animal[i];
		for (int j = 0; j <= 1; ++j) {
			t[1] = animal[j];
			for (int k = 2; k < n; ++k) {
				if (t[k - 1] == 'S' ^ s[k - 1] == 'o') {
					t[k] = animal[state[t[k - 2]] ^ 1];
				} else {
					t[k] = t[k - 2];
				}
			}
			bool works2 = true;
			for (int k = 0; k < n; ++k) {
				if (t[k] == 'S' ^ s[k] == 'o') {
					if (t[(k - 1 + n) % n] == t[(k + 1) % n]) {
						works2 = false;
						break;
					}
				} else {
					if (t[(k - 1 + n) % n] != t[(k + 1) % n]) {
						works2 = false;
						break;
					}
				}
			}
			if (works2) {
				works = true;
				goto A;
			}
		}
	}
A:
	if (works) {
		cout << t << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 512
def gcd(x, y):
    if(y > x):
        tmp = y
        y = x
        x = tmp

    while(int(x%y)>0):
        r = x%y
        x = y
        y = r

    return y
        


n = int(input())
a = list(map(int, input().split()))

ans = gcd(a[0], a[1])
for i in range(1, n-1):
    ans = min(ans, gcd(a[i], a[i+1]))

print(ans)

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

int main(void){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> num(n,vector<int>(d,0));
    int ans = 0;

    for (int i = 0; i < n;i++){
        for (int j = 0; j < d;j++){
            cin >> num.at(i).at(j);
        }
    }
    for (int i = 0; i < n-1; i++){
        for (int j = i+1; j < n; j++){
            int norm = 0;
            for (int k = 0; k < d;k++){
                int diff = abs(num.at(i).at(k) - num.at(j).at(k));
                norm += diff * diff;
            }
            bool flag = false;
            for (int k = 0; k <= norm;k++){
                if(k*k == norm){
                    flag = true;
                }
            }
            if(flag)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(x,t)=input.split(" ").map(_.toInt)
    Array(x-t,0).max.toString
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    array.at(0) = 1000001;
    for(int i=1;i<n;i++){
        int b;
        cin >> array.at(i);
    }
    array.push_back(1000001);
    int sum = 0;
    for(int i=0;i<array.size()-1;i++){
        sum += min(array.at(i),array.at(i+1));
    }

    cout << sum << endl;
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int count=0;
  for(int i=min(A, B); i>=1; i--){
    if(A%i==0 && B%i==0){
      count++;
      if(count==K){
        cout << i << endl;
        break;
      }
    }
  }
}
  

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [[int(i) for i in input().split()] for _ in range(H)]  # a[h][w] で指定

c = 0
ans = []
ans_c = 0
for i in range(1, H+1):
    for j in range(1, W+1):

        h, w = i, j

        if h % 2 == 0:
            w = W-j+1

        if j == W:
            nh = h+1
            nw = w
        else:
            nh = h
            if h % 2 == 1:
                nw = w+1
            else:
                nw = w-1

        if (a[h-1][w-1]+c) % 2 == 0:
            c = 0
        elif (a[h-1][w-1]+c) % 2 == 1:
            c = 1
            if i != H or j != W:
                ans_c += 1
                ans.append((h, w, nh, nw))

print(ans_c)
for a in ans:
    print(*a)


Measured memory_bytes: 71516
// Train

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

using namespace std;

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

    cout << n + 1 - i << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
S=input()
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S',
   'T','U','V','W','X','Y','Z']
ans=''
for i in range(len(S)):
  for j in range(26):
    if  S[i]==A[j]:
      alpha=j
      alpha+=n
      alpha=alpha%26
      ans=ans+A[alpha]
print(ans)


Measured memory_bytes: 3064
import copy
from collections import deque


def bfs(s, f):
    f[s[0]][s[1]] = 0
    moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

    q = deque([s])
    while q:
        c = q.popleft()
        for m in moves:
            my, mx = c[0] + m[0], c[1] + m[1]

            if f[my][mx] == ".":
                f[my][mx] = f[c[0]][c[1]] + 1
                q.append([my, mx])
                goal = [my, mx]
            else:
                continue

    return goal, f[goal[0]][goal[1]]


def main():
    H, W = map(int, input().split())
    field = []

    for h in range(H + 2):
        field.append(["#"] * (W + 2))
        if 1 <= h <= (H):
            field[h][1:-1] = list(map(str, input().rstrip()))

    ans = 0
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if field[y][x] == ".":
                goal, tmp_ans = bfs([y, x], copy.deepcopy(field))
                ans = max(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
// https://atcoder.jp/contests/abc156/tasks/abc156_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

// mod条件下の高速pow
int modPow(int a, int p) {
    if (p == 0)
        return 1;
    if (p % 2 == 0) {
        int root = modPow(a, p / 2);
        return root * root % MOD;
    } else
        return a * modPow(a, p - 1) % MOD;
}

int modComb(int a, int b) {
    if (b > a - b)
        return modComb(a, a - b);
    int mul = 1; //分子
    int div = 1; //分母
    for (int i = 0; i < b; i++) {
        mul *= (a - i);
        mul %= MOD;
        div *= (i + 1);
        div %= MOD;
    }
    //フェルマーの小定理を利用して掛け算で計算
    return mul * modPow(div, MOD - 2) % MOD;
}

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    int t = modPow(2, N) - modComb(N, A) - modComb(N, B) - 1;
    while (t < 0)
        t += MOD;
    cout << t << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main( ) {

  int N , K , k ;
  string S;

  cin >> N;
  cin >> K;

  cin >> S;
  k = K-1;


  if( S.size() == N ){ 
    if(S.at(k) == 'A' ){

      S.at(k) = 'a';

    }
    if(S.at(k) == 'B'){

        S.at(k) = 'b';

    }
    if(S.at(k) == 'C'){
        S.at(k) = 'c';
    }

}

cout << S << endl ;

}

Measured memory_bytes: 256