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

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    n = in.ni();
    int a = in.ni(), b = in.ni(), c = in.ni();
    x = new String[n];
    for (int i = 0; i < n; i++) {
      x[i] = in.next();
    }
    dfs(a, b, c, 0);
    if (possible) {
      out.println("Yes");
      out.print(result.toString());
    } else {
      out.println("No");
    }
  }

  private boolean possible;
  private int n;
  private String[] x;
  private ArrayDeque<Character> path = new ArrayDeque<>();
  private StringBuilder result = new StringBuilder();

  private void dfs(int a, int b, int c, int idx) {
    if (possible) return;
    if (a < 0 || b < 0 || c < 0) {
      return;
    }
    if (idx == n) {
      possible = true;
      while (path.size() > 0) {
        result.append(path.pollFirst());
        result.append("\n");
      }
      return;
    }
    String command = x[idx];
    if ("AB".equals(command)) {
      path.addLast('A');
      dfs(a + 1, b - 1, c, idx + 1);
      if (path.size() > 0) path.pollLast();

      path.addLast('B');
      dfs(a - 1, b + 1, c, idx + 1);
      if (path.size() > 0) path.pollLast();
    } else if ("BC".equals(command)) {
      path.addLast('B');
      dfs(a, b + 1, c - 1, idx + 1);
      if (path.size() > 0) path.pollLast();

      path.addLast('C');
      dfs(a, b - 1, c + 1, idx + 1);
      if (path.size() > 0) path.pollLast();
    } else if ("AC".equals(command)) {
      path.addLast('A');
      dfs(a + 1, b, c - 1, idx + 1);
      if (path.size() > 0) path.pollLast();

      path.addLast('C');
      dfs(a - 1, b, c + 1, idx + 1);
      if (path.size() > 0) path.pollLast();
    }
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 82448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10000
int n,s[2][N];
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=0; i<2; i++)
            for(int j=0; j<n; j++)
                scanf("%d",&s[i][j]);
        int c[105];
        for(int i=0;i<105;i++)
            c[i]=0;
        int k=n,x,y,maxn;
        for(int i=0;i<n+1;i++)
        {
            for(x=0;x<2;x++)
            {
                if(x==0)
                    for(y=0;y<k;y++)
                        c[i]=c[i]+s[x][y];
                else
                    for(y=k-1;y<n;y++)
                        c[i]=c[i]+s[x][y];
            }
            k--;
            if(i==0)
                maxn=c[i];
            if(c[i]>maxn)
                maxn=c[i];
        }
        printf("%d\n",maxn);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

int main(){
	int N, M, L;
	int a[100][100], b[100][100];
	long c[100][100]={0};

	scanf(" %d %d %d", &N, &M, &L);
	for(int i=0; i<N; ++i){
		for(int j=0; j<M; ++j){
			scanf(" %d", &a[i][j]);
		}
	}
	
	for(int i=0; i<M; ++i){
		for(int j=0; j<L; ++j){
			scanf(" %d", &b[i][j]);
		}
	}

	for(int i=0; i<N; ++i){
		for(int j=0; j<L; ++j){
			for(int k=0; k<M; ++k){
				c[i][j] += a[i][k]*b[k][j];
			}
		}
	}
	
	for(int i=0; i<N; ++i){
		for(int j=0; j<L; ++j){
			printf("%ld", c[i][j]);
			if(j!=L-1) printf(" ");
		}
		printf("\n");
	}

	return 0;
}

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

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

    int n;
    string s;
    cin >> n >> s;
    if(n % 2 == 1) {
        cout << "No" << "\n";
        return 0;
    }
    int flag = 1;
    for(int i = 0; i < n / 2; i++) {
        if(s[i] != s[i + n / 2]) {
            flag = 0;
            break;
        }
    }
    if(flag == 1)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
    int n,d[50],i,j,ans = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&d[i]);
    }

    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            ans += d[i] * d[j];
        }        
    }
    
    printf("%d",ans);
}


Measured memory_bytes: 128
// ABC 099 C
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ll long long
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<ll> dp(100001,100001);
    dp[0] = 0;
    REP(i,N+1){
        int p = 1;
        while(p<=i&&p<=N){
            dp[i] = min(dp[i],dp[i-p]+1);
            p*=6;}}
    REP(i,N+1){
        int p = 1;
        while(p<=i&&p<=N){
            dp[i] = min(dp[i],dp[i-p]+1);
            p*=9;}}
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
while 1:
    try:
        l=set(range(1,11))
        a,b,c=map(int,raw_input().split())
        t=a+b
        l=l-set([a,b,c])
        cnt=0
        for i in l:
            if t+i<=20:
                cnt+=1
        print 'YES' if cnt>3 else 'NO'
    except:
        break

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int H, W, M; cin >> H >> W >> M;
  vector<int> h(M), w(M);
  vector<int> y(3e5+1, 0), x(3e5+1, 0);
  map<pair<int,int>, int> mp;
  for(int i = 0; i < M; i++){
    cin >> h[i] >> w[i];
    h[i]--, w[i]--;
    y[h[i]]++;
    x[w[i]]++;
    mp[{h[i], w[i]}]++;
  }

  vector<int> Y = y, X = x;
  sort(y.rbegin(), y.rend());
  sort(x.rbegin(), x.rend());
  int ans = y[0] + x[0];

  int cnt = 0;
  for(int i = 0; i < y.size(); i++){
    int left = -1, right = x.size()+1;
    while(right - left > 1){
      int mid = (left + right) / 2;
      (y[i] + x[mid] < ans ? right : left) = mid;
    }
    cnt += right;
  }
  //cout << cnt << endl;

  int cnt2 = 0;
  for(auto p : mp){
    int y2 = p.first.first, x2 = p.first.second;
    int t = Y[y2] + X[x2];
    //cout << y2 << " "<< x2 << " : " << Y[y2] << " " << X[x2] << " " << t << endl;
    cnt2 += (t == ans);
  } 
  //cout << cnt2 << endl;
  if(cnt == cnt2) ans--;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35944
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);


const int mod = 924844033;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

const int maxn = (int) 2e3 + 10;
int fact[maxn];

void precalc() {
  fact[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    fact[i] = mult(fact[i - 1], i);
  }
}

int n, k;

int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  return 1;
}

int dp[maxn][2][2];

void solve() {
  memset(dp, 0, sizeof(dp));
  dp[0][1][0] = 1;

  for (int r = 0; r < k; ++r) {
    //eprintf("r = %d\n", r);
    for (int x = r; x < n; x += k) {
      for (int took = n; took >= 0; --took) {
        int pdp[2][2];
        memcpy(pdp, dp[took], sizeof(dp[took]));
        memset(dp[took], 0, sizeof(dp[took]));

        for (int pr = 0; pr < 2; ++pr) {
          for (int cur = 0; cur < 2; ++cur) {
            int val = pdp[pr][cur];
            if (!val) {
              continue;
            }
            if (!pr) {
              add(dp[took + 1][cur][0], val);
            }
            add(dp[took + 1][cur][1], val);

            add(dp[took][cur][0], val);
          }
        }
      }
    }
    for (int took = 0; took <= n; ++took) {
      int sum = 0;
      for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
          //eprintf("dp[%d][%d][%d] = %d\n", took, i, j, dp[took][i][j]);
          if (!j) {
            add(sum, dp[took][i][j]);
          }
          dp[took][i][j] = 0;
        }
      }
      dp[took][1][0] = sum;
    }
  }

  int res = 0;
  for (int took = 0; took <= n; ++took) {
    int val = mult(fact[n - took], dp[took][1][0]);
    //eprintf("took = %d, val = %d\n", took, val);
    if (took & 1) {
      val = mod - val;
    }
    add(res, val);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S,T;
    cin>>S>>T;
    sort(all(S));sort(all(T));
    reverse(all(T));
    if(S<T)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
N,K = map(int,input().split())
if K == 0:
    print(N**2)
    exit()
ans = 0
for b in range(K+1,N+1):
    i1 = 0; i2= 0
    Q = (N-K)//b
    i1 = Q*(b-K) 
    left = K; right = min(N-b*Q,b-1)
    #print("{}<=r<={}".format(left,right))
    i2 = max(right - left + 1,0)
    ans += i1 + i2
    #print(i1,i2)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int t=max(A,max(B,C));
  int l=t;
  REP(i,K){
    t*=2;
  }
  cout<<t+A+B+C-l<<endl;
}

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

int main() {
    long long n,s=0;
    cin >> n;
    for(int i=0;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            s+=i;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3632
using System;
class Program
{
    private int ranksum(int n)
    {
        string str = n.ToString();
        int s = 0;
        for (int i = 0; i < str.Length; i++)
        {
            s += (int)Char.GetNumericValue(str[i]);
        }
        return s;
    }
    public static void Main()
    {
        Program prog = new Program();
        int n, a, b;
        string[] str = Console.ReadLine().Split(' ');
        n = int.Parse(str[0]);
        a = int.Parse(str[1]);
        b = int.Parse(str[2]);
        int sum = 0;
        for (int j = 1; j <= n; j++)
        {
            if (prog.ranksum(j) >= a && prog.ranksum(j) <= b)
                sum += j;
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll n;
vector<ll> a;
vector<vector<ll>> dp,flag;

ll f(int l,int r){
	if(flag[l][r]>0) return dp[l][r];
	flag[l][r]=1;
	if(l==r)dp[l][r]=a[l];
	else dp[l][r] = max(a[l]-f(l+1,r),a[r]-f(l,r-1));

	return dp[l][r];
}

int main()
{
	cin>>n;
	a.resize(n+1,0);
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	dp.resize(n+2,vector<ll>(n+1,0));
	flag.resize(n+2,vector<ll>(n+1,0));

	cout << f(1,n) << endl;

	return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    ll l,r;
    cin>>l>>r;
    if(r-l > 2019){
        cout << 0 << endl;
        return 0;
    }
    l %= 2019;
    r %= 2019;
    ll ans = 2019;
    for(int i=l;i<r;++i){
        for(int j=l+1;j<=r;++j){
            ans = min(1ll*(i*j)%2019,ans);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,s;
    while(1){
        cin>>x>>y>>s;
        if(x==0 && y==0 && s==0){break;}
        int mx=0;
        for(int i=1;i<s;i++){
            int p1=i+i*x/100;
            for(int j=1;j<s;j++){
                int p2=j+j*x/100;
                if(p1+p2!=s){continue;}
                int sum=i+i*y/100+j+j*y/100;
                mx=max(mx,sum);
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,sum=0;
    cin >> n;
    for(int i=1;i<=n;i++){
    	if(i%3==0 or i%5==0)continue;
    	sum+=i;
    }
    cout << sum ;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define inf 1000000000000000000

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x){
    return power(x,mod-2,mod)%mod;
}

ll func(char s[20][20],ll h,ll w,ll i,ll j,ll dx,ll dy,bool vis[20][20])
{
    //cout<<i<<" "<<j<<" "<<dx<<" "<<dy<<endl;
    queue<pair<ll,ll>>q;
    q.push(make_pair(i,j));
    vis[i][j]=true;
    ll ans=0;
    while(q.empty()==0)
    {
        ll z=q.size();
        for(int l=0;l<z;l++)
        {
            pair<ll,ll>p=q.front();
            q.pop();
           // vis[p.first][p.second]=true;
           // if(i==0 && j==0 && dx==2 && dy==2){
           // cout<<p.first<<" "<<p.second<<endl;}
            //cout<<dx<<" "<<dy<<endl;
            if(p.first==dx && p.second==dy)
                return ans;
            
            if(p.first-1>=0 && vis[p.first-1][p.second]==false && s[p.first-1][p.second]=='.')
                vis[p.first-1][p.second]=true,q.push(make_pair(p.first-1,p.second));
            if(p.second+1<w && vis[p.first][p.second+1]==false && s[p.first][p.second+1]=='.')
                vis[p.first][p.second+1]=true,q.push(make_pair(p.first,p.second+1));
            if(p.first+1<h && vis[p.first+1][p.second]==false && s[p.first+1][p.second]=='.')
                vis[p.first+1][p.second]=true,q.push(make_pair(p.first+1,p.second));
            if(p.second-1>=0 && vis[p.first][p.second-1]==false && s[p.first][p.second-1]=='.')
                vis[p.first][p.second-1]=true,q.push(make_pair(p.first,p.second-1));
        }
        ans++;
    }
    return ans;
}

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

    ll h,w;
    cin>>h>>w;
    char s[20][20];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            cin>>s[i][j];
    }
    
    ll ans=0;
    bool vis[20][20];
    memset(vis,false,sizeof(vis));
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            for(int l=0;l<h;l++)
            {
                for(int r=0;r<w;r++)
                {
                    if(s[i][j]!='#' && s[l][r]!='#')
                    {
                        memset(vis,false,sizeof(vis));
                        ll z=func(s,h,w,i,j,l,r,vis);
                       // cout<<i<<" "<<j<<" "<<l<<" "<<r<<" "<<z<<endl;
                        ans=max(ans,z);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int A[N]; rep(i, N) cin >> A[i];
    for(int i = K; i < N; i++){
        if(A[i] > A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef vector<char> vc;
typedef vector<vector<char>> vcc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> cnt(3,0);
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        if(p <= a) cnt[0]++;
        else if(p >= b+1) cnt[2]++;
        else cnt[1]++;
    }
    cout << *min_element(cnt.begin(),cnt.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)? a:b)
typedef long long ll;
int F(ll a){
  if(a%10==a) return 1;
  if(a%100==a) return 2;
  if(a%1000==a) return 3;
  if(a%10000==a) return 4;
  if(a%100000==a) return 5;
  if(a%1000000==a) return 6;
  if(a%10000000==a) return 7;
  if(a%100000000==a) return 8;
  if(a%1000000000==a) return 9;
  if(a%10000000000==a) return 10;
  if(a%100000000000==a) return 11;
}
int main()
{
  ll n;
  cin>>n;
  vector<int> f;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i!=0) continue;
    f.push_back(max(F(i),F(n/i)));
  }
  sort(f.begin(),f.end());
  cout<<*f.begin();
}

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

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

    std::vector<long long> A(N), F(N);
    for (int i = 0; i < N; i++) std::cin >> A[i];
    for (int i = 0; i < N; i++) std::cin >> F[i];

    std::sort(A.begin(), A.end());
    std::sort(F.begin(), F.end(), std::greater<long long>());

    long long left = 0, right = 1LL << 40;
    while (left < right) {
        long long x = (left + right) / 2;

        long long res = 0;
        for (int i = 0; i < N; i++) {
            res += std::max(0LL, A[i] - x / F[i]);
        }

        if (res <= K) {
            right = x;
        } else {
            left = x + 1;
        }
    }
    std::cout << right << "\n";
}

Measured memory_bytes: 3328
def bfs(i, c):
    global m,C

    q = [i]
    while len(q) > 0:
        j = q.pop()
        if C[j] == -1:
            C[j] = c
            q += M[j]
if __name__ == '__main__':
    n, m = map(int, raw_input().split())
    M = [[] for i in xrange(n)]
    C = [-1] * n

    for i in xrange(m):
        l, r = map(int, raw_input().split())
        M[l].append(r)
        M[r].append(l)

    c = 0
    for i in xrange(n):
        if C[i] == -1:
            bfs(i, c)
            c += 1

    q = input()
    for i in xrange(q):
        l, r = map(int, raw_input().split())
        if(C[l] == C[r]):
            print "yes"
        else:
            print "no"

Measured memory_bytes: 25128
{-# LANGUAGE ScopedTypeVariables #-}

import Data.List

main :: IO ()
main = do
    _ :: Int <- read <$> getLine
    as :: [Int] <- reverse . sort . map read . words <$> getLine
    print (( sum $ takeOdds as) - (sum $takeEvens as))

takeOdds :: [a] -> [a]
takeOdds [] = []
takeOdds [a] = [a]
takeOdds (a:_:as) = a:takeOdds as

takeEvens :: [a] -> [a]
takeEvens [] = []
takeEvens (_:as) = takeOdds as

Measured memory_bytes: 1020
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Double> listX = new ArrayList<Double>();
		List<Double> listY = new ArrayList<Double>();
		while(scan.hasNext()){
			double a = scan.nextDouble();
			double b = scan.nextDouble();
			double c = scan.nextDouble();
			double d = scan.nextDouble();
			double e = scan.nextDouble();
			double f = scan.nextDouble();
			double y = (f * a - d * c)/(-d * b + e * a);
			double x = (f * b - e * c)/(b * d - e * a);
			if(x == 0)x = 0.;
			if(y == 0)y = 0.;
			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
}

Measured memory_bytes: 28388
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL k, ans = 1;
	cin >> k;
	LL x = 7;
	for (LL i = 0; i < 10000000; ++i) {
		x %= k;
		if (x == 0) {
			break;
		}
		++ans;
		x = (x * 10) + 7;
	}
	cout << (ans >= 10000000 ? -1 : ans) << endl;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s; cin >> s;
    cout << (((s[0] == s[s.size()-1]) != (s.size() % 2)) ? "First" : "Second") << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
class segtree
{
  public:
  int depth;//セグ木の深さ(最上部が0）
  int size;
  vector<int> node;//セグ木本体

  //コンストラクタ
  //初期値の代入もする
  segtree(int n/*,vector<int> v*/)
  {
    depth=0;
    size=1;
    while(n>size)
    {
      size*=2;
      depth++;
    }
    size*=2;
    node.resize(size,2147483647);
    //最下段に値を入れたあとに、下の段から順番に値を入れる
    //値を入れるには自分の子の2値を参照する
    // for(int i=0;i<n;i++)
    //   node[i+(1<<depth)]=v[i];
    
    // for(int d=depth-1;d>=0;d--)
    // {
    //   for(int i=0;i<(1<<d);i++)
    //   {
    //     int ind=i+(1<<d);
    //     node[ind]=min(node[ind*2],node[ind*2+1]);
    //   }
    // }
  }

  //値の更新
  //node[k]をaにする
  void update(int k,int a)
  {
    k+=(1<<depth);//セグ木上のインデックスに読み替え
    node[k]=a;
    while(k>0)
    {
      k/=2;
      node[k]=min(node[k*2],node[k*2+1]);
    }
    return;
  }
  
  //値の取得
  //閉区間[l,r]の最小値
  int get(int l,int r)
  {
    l+=(1<<depth);
    r+=(1<<depth);
    if(l==r)
      return node[l];
    int ret=l;
    while(l<=r)
		{
			if(!(r&1))
			{
				if(node[ret]>node[r])
					ret=r;
				r--;
			}
			if(l&1)
			{
				if(node[ret]>node[l])
					ret=l;
				l++;
			}
			l/=2;r/=2;
		}
    return node[ret];
  }
};

int main()
{
  int n,q;
	cin>>n>>q;
	segtree seg=segtree(n);
	for(int i=0;i<q;i++)
	{
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0)
		{
			seg.update(x,y);
		}else
			cout<<seg.get(x,y)<<endl;
	}
  return 0;
}


Measured memory_bytes: 3884
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc162c
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            int k = int.Parse(Console.ReadLine());


            //==========================================================================================================================
            //2) output
            str = new int[3];

            Execute(3, k);


            Console.WriteLine(output);

            //==========================================================================================================================

        }

        static int output = 0;

        /// <summary>
        /// 結果保持配列
        /// </summary>
        static int[] str;

        /// <summary>
        /// n桁の数において、各桁の数値「0~k-1」を用いた組み合わせの総当たり
        /// </summary>
        /// <param name="n">桁数</param>
        /// <param name="k">利用する数値</param>
        public static void Execute(int n, int k)
        {
            if (n < 1)
            {
                int tmp = Gcd(str[0], str[1]);

                output += Gcd(str[2], tmp);


            }
            else
            {
                for (int index = 1; index <= k; index++)
                {
                    str[n - 1] = index;
                    Execute(n - 1, k);

                }



            }

        }

        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
}


Measured memory_bytes: 27384
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  double A,B;
  cin >> A >> B;
  double A_min,A_max,B_min,B_max;
  int ans = 0;
  A_min = A / 0.08;
  A_max = (A+1.0)/0.08;
  B_min = B / 0.1;
  B_max = (B+1) / 0.1;
  REP(i,B_max) {
    if(A_min<=i&&i<A_max&&B_min<=i) {
      ans = i;
      break;
    }
  }
  if(ans) {
    cout << ans << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

long long lcm(long long a, long long b){ return a/__gcd(a, b)*b; }

int main(){
    Init();
    ll n; cin >> n;
    ll ans = 1;
    rep(i, n){
        ll in; cin >> in;
        ans = lcm(ans, in);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    if(N == 3){
        printf("2 5 63\n");
        return 0;
    }
    else if(N <= 32){
        printf("2 3 4 9 ");
        for (int i = 4; i < N; i++) {
            printf("%d ", 6 * (i-3));
        }
        printf("\n");
        return 0;
    }
    else{
        for (int i = 0; i < ((N-1)/8)+1; i++) {
            printf("%d %d %d %d %d %d ", 12*i+2, 12*i+3, 12*i+4, 12*i+8, 12*i+9, 12*i+10);
        }
        for (int i = 0; i < 2*(((N-1)/8)+1) - (7 - (N-1)%8); i++) {
            printf("%d ", 6*(i+1));
        }
        printf("\n");
    }

}   

Measured memory_bytes: 3716
from collections import Counter

N = int(input())

A = list(map(int, input().split()))

set_A = set(A)

ans = 0
sens = {}
for value in Counter(A).items():
    key = value[0]
    v = value[1]
    ans += v * (v - 1) /2
    sens[key] = v * (v - 1) /2 - (v - 1) * (v - 2)/2

for a in A:
    print(int(ans - sens[a]))


Measured memory_bytes: 35768
function f(X,Y)
	for _=1:Y print('U')end
	for _=0:X print('R')end
	for _=0:Y print('D')end
	for _=1:X print('L')end
end
A,B,C,D=map(x->parse(Int,x),split(readline()))
f(C-A,D-B)
print("LULU")
f(C-A,D-B)
println()


Measured memory_bytes: 169596
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)


Measured memory_bytes: 9116
from collections import defaultdict
def solve():
    n = input()
    s = []
    m = defaultdict(list)
    mm = {}
    for i in range(0, int(n)):
        si, pi = map(str, input().split())
        s.append(si)
        m[si].append(int(pi))
        mm[int(pi)] = i + 1
    ss = set(s)
    sss = list(ss)
    sss.sort()
    for i in range (len(sss)):
        s2 = sss[i]
        pd = m[s2]
        pd.sort()
        pd.reverse()
        for j in range (len(pd)):
            print(mm[pd[j]])


if __name__ == "__main__":
    solve()

    


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

///0:left man
///1:right man
int dp[1000][1000];
int dp2[2000];
int N;
int c[1000],w[1000];
int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&c[i],&w[i]);
        dp[i][i]=w[i];
    }

    for(int i=2;i<=N;i++){
        for(int j=0;j+i-1<N;j++){
            if(dp[j+1][j+i-1]&&c[j]>=dp[j+1][j+i-1]){
                dp[j][j+i-1]=dp[j+1][j+i-1]+w[j];
            }
            if(dp[j][j+i-2]&&c[j+i-1]>=dp[j][j+i-2]){
                dp[j][j+i-1]=dp[j][j+i-2]+w[j+i-1];
            }
        }
    }

    for(int i=0;i<=N;i++)dp2[i]=i;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(dp[i][j-1]){
                dp2[j]=min(dp2[j],dp2[i]+1);
            }
        }
    }


    cout<<dp2[N]<<endl;
    return 0;
}

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

int main(){
    int N,M,ans=0;
    cin>>N>>M;
    int X[M];
    int Y[M-1];
    for(int i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X,X+M);
    for(int j=0;j<M-1;j++){
        Y[j]=X[j+1]-X[j];
    }
    sort(Y,Y+M-1);
    for(int k=0;k<M-N;k++){
        ans+=Y[k];
    }
    cout<<ans<<endl;
    return 0;
}

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

bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string s;
  cin >> s;
  bool ans = true;
  if (!isPalindrome(s)) ans = false;
  if (!isPalindrome(s.substr(0, s.size()/2))) ans = false;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  if (S[0] == T[0]) ++count;
  if (S[1] == T[1]) ++count;
  if (S[2] == T[2]) ++count;
  cout << count << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main ()
{
	char S[20],T[20],U[20];
	int A,B;
	scanf("%s %s\n%d %d\n%s", S,T,&A,&B,U);
	if((strcmp(S,U)) == 0) {
		printf("%d %d\n", A-1,B);
	}
	else if((strcmp (T,U))== 0) {
		printf("%d %d\n", A,B-1);
	}
}

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

using namespace std;

int n;
long long x[10000],y[10000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lld", &x[i]);
    for (int i = 0; i < n; i++)
        scanf("%lld", &y[i]);
    
    long long minus = 0LL, plus = 0LL;
    for (int i = 0; i < n; i++) {
        long long c = x[i] - y[i];
        if (c > 0LL)
            plus += c;
        else if (c < 0LL)
            minus -= c / 2;
    }
    if (minus >= plus)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 384
def selectsort(A):
	t=0
	for i in range(0,len(A)):
		mini=i
		for j in range(i, len(A)):
			if A[j]<A[mini]:
				mini=j
		if i!=mini:
			temp=A[i]
			A[i]=A[mini]
			A[mini]=temp
			t+=1
	return t		

input()
input=input()
A=[int(s) for s in input.split(' ')]
t=selectsort(A)
print (' '.join(map(str,A)))
print(t)

Measured memory_bytes: 5604
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll sm = 0, x;
	vector<string> sts;
	vector<ll> ints;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string a;
		ll b;
		cin >> a >> b;
		sts.push_back(a), ints.push_back(b);
	}
	string sng;
	cin >> sng;
	bool bien = 0;
	for(int i = 0; i < n; i++) {
		if(bien) sm += ints[i];
		if(sts[i] == sng) bien = 1;
	}
	cout << sm << '\n';
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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

int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	string s;
	cin >> s;
	bool flag = true;
	for (int i = 0; i < s.size(); i++)
	{
		if (i + 1 < s.size()) {
			flag &= (s[i] == s[i + 1]);
		}
	}

	if (flag) {
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	} 
	

	return 0;
}



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

signed main(){
  int N;
  cin>>N;
  vector<pair<pair<string,int>,int>> guid(N);
  rep(i,N){
    cin>>guid.at(i).first.first>>guid.at(i).first.second;
    guid.at(i).first.second*=-1;
    guid.at(i).second=i+1;
  }
  sort(guid.begin(),guid.end());
  for(auto &p:guid)
    cout<<p.second<<endl;
  return 0;
}

Measured memory_bytes: 256
import math

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

distance=0
for i in range(n):
  for j in range(i+1,n):
    distance+=math.sqrt((codes[i][0]-codes[j][0])**2+(codes[i][1]-codes[j][1])**2)
print(distance*2/n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
vector<int> G[100010];
long long n,k,ans;
void dfs(int v,int p){
  int b;
  if(p==0){
    b=k-1;
  }else{
    b=k-2;
  }
  for(auto e:G[v]){
    if(e==p)continue;
    ans=(ans*b)%1000000007;
    b--;
    dfs(e,v);
  }
}
int main(){
  cin>>n>>k;
  for(int i=0;i<n-1;i++){
    int a,c;cin>>a>>c;
    G[a].push_back(c);
    G[c].push_back(a);
  }
  ans=k;
  dfs(1,0);
  cout<<ans<<endl;
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a;
    long long all = 0;
    rep(i,n){
        long long temp;
        cin >> temp;
        a.push_back(temp);
        all = all^temp; 
    }
    
    rep(i,n){
        long long t;
        t=all^a.at(i);
        cout << t << " ";
    }
    cout << endl;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int p[30] ={};
	for(auto x: s){
		p[x-'a']++;
		if(p[x-'a'] > 1){
			puts("no"); return 0;
		}
	}
	puts("yes");
}



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

int main(){
  long long n,k;
  cin >> n >> k;
  vector<long long> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h.rbegin(),h.rend()); //降順
  long long sum=0;
  for(int i=k;i<n;i++){
    sum+=h[i];
  }
  cout << sum << endl;
}
  


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

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

    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++) cin >> D[i];
    int64_t total = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            total += D[i] * D[j];
        }
    }
    cout << total << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int keta(ll A)
{
    int cnt = 0;
    while (A)
    {
        cnt++;
        A /= 10;
    }
    return cnt;
}

int main()
{
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i, N) cin >> vec[i];
    sort(all(vec));
    int ans = 1000000000;
    for (int i = vec[0]; i < vec[N - 1] + 1; i++)
    {
        int cnt = 0;
        rep(j, N)
        {
            cnt += (vec[j] - i) * (vec[j] - i);
        }
        ans = min(cnt, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int>P;
const int len=2e5+10;
const LL mod=998244353;
const int inf=0x3f3f3f3f;
int main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    for(int i=0;i<str.size();++i)str[i]=(str[i]-'A'+n)%26+'A';
    cout<<str<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[105],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;++i)
	 cin>>a[i];
	for(int i=0;i<n;++i)
	 for(int j=i+1;j<n;++j)
	  for(int k=j+1;k<n;++k)
	   if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
	    if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
	     ++ans;
	cout<<ans;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

vector<int> r, g, b;

void solve() {
  int n; string s; cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') r.push_back(i);
    else if (s[i] == 'G') g.push_back(i);
    else b.push_back(i);
  }
  long long ans = 0;
  for (int i: r) {
    for (int j: g) {
      ans += b.size();
      int x[2] = {i, j};
      sort(x, x+2);
      auto y = lower_bound(b.begin(), b.end(), 2*x[1]-x[0]);
      if (y != b.end() && *y == 2*x[1]-x[0]) --ans;
      y = lower_bound(b.begin(), b.end(), (x[0]+x[1])/2);
      if (y != b.end()) {
        int z = *y;
        if (z-x[0] == x[1]-z) --ans;
      }
      y = lower_bound(b.begin(), b.end(), x[0]-(x[1]-x[0]));
      if (y != b.end() && *y == x[0]-(x[1]-x[0])) --ans;
    }
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3776
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for (int i=0;i<n;i++) {
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}

Measured memory_bytes: 23380
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int n;cin>>n;
if(n%1000) cout<<1000*(n/1000 +1)-n;
else cout<<0;
return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

lli t, n, tmp_a, tmp_b, sum = 0;
vector<lli> v;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	v.resize(n);
	vector<lli> cnts(100001, 0);
	
	for (int i = 0; i < v.size(); i++)
	{
		cin >> v[i];
		sum += v[i];
		++cnts[v[i]];
	}
	
	
	cin >> t;
	while(t--) {
		cin >> tmp_a >> tmp_b;
		sum -= cnts[tmp_a] * tmp_a;
		sum += cnts[tmp_a] * tmp_b;
		cnts[tmp_b] += cnts[tmp_a];
		cnts[tmp_a] = 0;
		cout << sum << "\n";
	}
	
	
	return 0;
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.end()
#define inf 1e9
#define Puts(x) puts(x? "YES":"NO")
const int mod = 1e9 + 7;

typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

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

  int n;
  cin >> n;
  vt<int> x(n), y(n), h(n);
  rep(i, 0, n) cin >> x[i] >> y[i] >> h[i];

  int k = 0;
  while(h[k] == 0) ++k;

  rep(cx, 0, 101) {
    rep(cy, 0, 101) {
      int H = h[k] + abs(x[k] - cx) + abs(y[k] - cy);
      bool ok = true;

      rep(i, 0, n) {
        if(h[i] !=  max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
          ok = false;
          break;
        }
      }
      if(ok) return cout << cx << " " << cy << " " << H << endl, 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    if (N%2 == 0) cout << N << endl;
    else cout << (N * 2) << endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int n; cin >> n;
	vector<int> a(n + 1), b(n);
	forn(i, n + 1)
	{
		cin >> a[i];
	}
	forn(i, n)
	{
		cin >> b[i];
	}
	ll res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] <= b[i])
		{
			b[i] -= a[i];
			res += a[i];
			res += min(b[i], a[i + 1]);
			a[i + 1] -= min(b[i], a[i + 1]);
		}
		else
		{
			res += b[i];
		}
		
	}
	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3936
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,set,n,x;
double h;

int main(){
	scanf("%d",&n);
	for(set=1;set<=n;set++){
		printf("Case %d:\n",set);
		scanf("%d",&x);
		for(i=0;i<10;i++){
			x=(x*x/100)%10000;
			printf("%d\n",x);
		}
	}
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, t=0;
	cin >> a >> b;
	c=b;
	do
	{
		c/=10;
		t++;
	}while(c!=0);
	for(int i=1;i<=t;i++)
	{
		a*=10;
	}
	a+=b;
	if(int(sqrt(a))==sqrt(a))
	{
		cout << "Yes"<<endl;
		return 0;
	}
	else
	{
		cout << "No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import statistics
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
per_lis = itertools.permutations(list(range(1,n+1)))
a=0
b=0
i=0
for elem in per_lis:
    i+=1
    if elem==p:
        a=i
    if elem==q:
        b=i
print(abs(a-b))

Measured memory_bytes: 78572