akhauriyash/Code-Regression huggingface dataset:
def main():
    N, L, T = map(int, input().split())
    collision = 0
    ants = []
    for i in range(N):
        x, w = map(int, input().split())
        if w == 1:
            collision += (x + T) // L
            a = (x + T) % L
        else:
            collision += (x - T) // L
            a = (x - T) % L
        ants.append(a)

    collision %= N
    ants.sort()
    ants = ants[collision:] + ants[:collision]
    for ant in ants:
        print(ant)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8604
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        Console.WriteLine(F(ab[0] - 1) ^ F(ab[1]));
    }

    static long F(long b)
    {
        return new long[] { b, 1, b + 1, 0 }[(b + 4) % 4];
    }
}

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

int main(){
    int N;
    cin>>N;
    vector<int64_t> V(3*N);
    for(auto &a:V) cin>>a;
    vector<int64_t> head_sum(N+1),tail_sum(N+1);
    priority_queue<int64_t, vector<int64_t>, greater<int64_t> > head_queue;
    for(int i=0;i<N;i++){
        head_sum[0]+=V[i];
        head_queue.push(V[i]);
    }
    for(int i=0;i<N;i++){
        head_queue.push(V[i+N]);
        head_sum[i+1]=head_sum[i]+V[i+N]-head_queue.top();
        head_queue.pop();
    }
    priority_queue<int64_t> tail_queue;
    for(int i=0;i<N;i++){
        tail_sum[0]+=V[3*N-1-i];
        tail_queue.push(V[3*N-1-i]);
    }
    for(int i=0;i<N;i++){
        tail_queue.push(V[2*N-1-i]);
        tail_sum[i+1]=tail_sum[i]+V[2*N-1-i]-tail_queue.top();
        tail_queue.pop();
    }
    int64_t ans=-1e17;
    for(int i=0;i<=N;i++){
        ans=max(ans,head_sum[i]-tail_sum[N-i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6516
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)
	defer wr.Flush()

	n := scanInt()
	a := scanInts(n)

	cnt := make([]int, 13)
	cnt[0]++
	for _, e := range a {
		cnt[e]++
	}

	for i := 0; i < 13; i++ {
		if cnt[i] > 2 || (cnt[i] > 1 && (i == 0 || i == 12)) {
			fmt.Fprintln(wr, 0)
			return
		}
	}

	s := 0
	bitExhaustiveSearch(13, func(b []bool) {
		arr := []int{}
		for i := 0; i < 13; i++ {
			if cnt[i] == 0 {
				continue
			}
			if cnt[i] == 1 {
				if !b[i] {
					arr = append(arr, i)
				} else {
					arr = append(arr, (24-i)%24)
				}
			} else {
				arr = append(arr, i, (24-i)%24)
			}
		}

		mi := 24
		for i := 0; i < len(arr); i++ {
			for j := i+1; j < len(arr); j++ {
				d := abs(arr[i]-arr[j])
				mi = min(mi, min(24-d,d))
			}
		}
		s = max(s, mi)
	})

	fmt.Fprintln(wr, s)
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


Measured memory_bytes: 4608
//aea ctmr


#include <iostream>
#include <map>

using namespace std;

map <string, int> m;

int main(){

	int n;
	cin >> n;

	while(n--){
		string s;
		cin >> s;
		m[s] = 1;
	}

	cout << m.size() << endl;

}

Measured memory_bytes: 18764
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 1e5;
const int MOD = 1e9 + 7;

int sub(int a, int b) {
	a -= b;
	if (a < 0)
		return a + MOD;
	return a;
}

void add(int& a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int Plus(int a, int b) {
	add(a, b);
	return a;
}

long long sum[N];

long long getsum(int l, int r) {
	if (l == 0)
		return sum[r];
	return sum[r] - sum[l - 1];
}

int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

template <class T>
void relax(T& a, T b) {
	a = min(a, b);
}

vector <int> G[N];
int dp[N][2];
void dfs(int v, int p = -1) {
	int any = 1;
	int whites = 1;
	for (auto x : G[v]) {
		if (x == p)
			continue;
		dfs(x, v);
		any = mult(any, Plus(dp[x][0], dp[x][1]));
		whites = mult(whites, dp[x][0]);
	}
	dp[v][0] = any;
	dp[v][1] = whites;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(0);
	cout << Plus(dp[0][0], dp[0][1]) << "\n";

	return 0;
}

Measured memory_bytes: 13440
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    vector< pair<string, int> > music;
    string X;
    cin >> N;
    music.resize(N);
    int s;
    rep (i, N)
    {
        cin >> X >> s;
        music[i] = make_pair(X, s);
    }

    cin >> X;
    int idx;
    for (idx = 0; music[idx].first != X && idx < N; ++idx);

    ++idx;
    int ans = 0;
    for (int i = idx; i < N; ++i)
    {
        ans += music[i].second;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
const int N = 6+2,C = 50+1,M = 300+5,S = 1<<5;
int m,n,l,a[N],b[N]; db ans;
db dp[M][S];
inline void solve(){
	register int i,j,s,v;
	memset(dp,0,sizeof(dp));
	dp[a[n-1]][(1<<n-1)-1] = 1;
	for (i = 1; i <= l; ++i) if (i % n)
	for (v = i%n-1,j = i; j <= l; ++j)
	for (s = 0; s < 1<<n-1; ++s) if (s>>v&1) dp[min(l,max(j,i+a[v]))][s^(1<<v)] += dp[j][s];
	ans += dp[l][0];
}
bool vis[N];
inline void dfs(int dep){
	if (dep == n-1){ solve(); return; }
	for (int i = 0; i < n-1; ++i) if (!vis[i]) a[dep] = b[i],vis[i] = 1,dfs(dep+1),vis[i] = 0;
}
int main(){
	int i,j;
	cin >> n >> m,l = n*m;
	for (i = 0; i < n; ++i) cin >> a[i],a[i] *= n; sort(a,a+n);
	for (i = 0; i < n; ++i) b[i] = a[i];
	dfs(0);
	for (i = 2; i <= n; ++i) ans /= m,ans /= i; ans *= n;
	cout << fixed << setprecision(20) << ans << '\n';
	return 0;
}

Measured memory_bytes: 3876
n=list(input())
a=1
for i in n:
    if not ((a%2==1 and (i=="R" or i == "U" or i == "D")) or (a%2==0 and (i=="L" or i == "U" or i == "D"))):
        print("No")
        exit()
    a+=1
print("Yes")

Measured memory_bytes: 38256
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

n, m = an()
py = []
for _ in range(m):
  py.append(list(an()) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))

d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

Measured memory_bytes: 36380
#include <iostream>

using namespace std;

auto main() -> int{
    int A,B,C;
    cin >> A >> B >> C;
    if(A ==B && B == C && C == A){ cout << "No" << endl; return 0; }
    if(A != B && B != C && C != A){ cout << "No" << endl; return 0; }

    if(A == B && B != C && C != A){ cout << "Yes" << endl; return 0; }
    if(A != B && B == C && C != A){ cout << "Yes" << endl; return 0; }
    if(A != B && B != C && C == A){ cout << "Yes" << endl; return 0; }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
int main() {
	int a,b; cin >> a >> b;
	vi N = {13,1,2,3,4,5,6,7,8,9,10,11,12};
	if (N[a-1] < N[b-1]){
		cout << "Bob" << endl;
	}else if(N[a-1] > N[b-1]){
		cout << "Alice" << endl;
	}else{
		cout << "Draw" << endl;
	}
	return 0;
}





Measured memory_bytes: 256
n = int(input())
ans = [0 for x in range(10001)]

for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            v = i*i + j*j + k*k + i*j + i*k + j*k
            if v < 10001:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9220
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	vi vr, vc;

	rep(i,h) {
		int flag = 0;
		cin >> a[i];
		rep(j,w) {
			if(a[i][j] == '#') {
				flag = 1;
				break;
            }
		}
		if(flag) vr.pb(i);
	}
	
	rep(j,w){
		int flag = 0;
		rep(i,h){
			if(a[i][j] == '#') {
				flag = 1;
				break;
			}
		}
		if(flag) vc.pb(j);
	}
  
	for(auto i : vr) {
		for(auto j : vc){
      		cout << a[i][j];
		}
		cout << endl;
    }
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	ans := 0
	for i := 0; i < 1<<(len(S)-1); i++ {
		now := 0
		for j := 0; j < len(S); j++ {
			now = now*10 + int(S[j]) - '0'
			if (i>>j)&1 == 1 {
				ans += now
				now = 0
			}
		}
		ans += now
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const ll INF = 101010101000;
ll dp[110][101010]; //N*Vの配列。最低の重さ。

int main(){
  int n, W;
  ll max_v = 0;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,n) max_v += v[i];
  //初期化
  rep(i,n+1){
    rep(j,max_v+1){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  
  rep(i,n){
    ll w_i = w[i];
    ll v_i = v[i];
    rep(j,max_v+1){
      if(j-v_i>=0) dp[i+1][j] = min(dp[i][j],dp[i][j-v_i]+w_i);
      else dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
    }
  }
  /*rep(i,n+1){
    rep(j,max_v+1){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  ll ans = 0;
  rep(i,max_v+1){
    if(dp[n][i]<=W){
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <map>
using namespace std;
const int maxn=3e5+10;
struct point {
    int x,y;
}p[maxn];
map<int,int>xcnt,ycnt;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int x,y,maxr=0,maxc=0;
    for(int i=1; i<=k; i++){
        cin>>x>>y;
        p[i]={x,y};
        xcnt[x]++,ycnt[y]++;
        maxr=max(maxr,xcnt[x]),maxc=max(maxc,ycnt[y]);
    }
    int num1=0,num2=0;
    for(auto tmp:xcnt)if(tmp.second==maxr)num1++;
    for(auto tmp:ycnt)if(tmp.second==maxc)num2++;
    int cnt=0;
    for(int i=1; i<=k; i++){
        x=p[i].x,y=p[i].y;
        if(xcnt[x]==maxr&&ycnt[y]==maxc)cnt++;
    }
    if(cnt==num1*num2)cout<< (maxc+maxr-1) <<endl;
    else cout<< (maxc+maxr) <<endl;
    return 0;
}


Measured memory_bytes: 33648
#include<iostream>
#include<cstring>
using namespace std;
string s1,s2;
int main(){
	cin>>s1>>s2;
	int l1=s1.size(),l2=s2.size();
	int ans=2e9+10;
	for(int i=0;i<=l1-l2;i++){
		int s=0;
		for(int j=0;j<l2;j++)
			if(s1[i+j]!=s2[j])
				s++;
		ans=min(ans,s);
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	long long ans[31];
	int a, i;
	
	ans[0] = ans[1] = 1;
	ans[2] = 2;
	for (i = 3; i < 31; i++){
		ans[i] = ans[i - 1] + ans[i - 2] + ans[i - 3];
	}
	
	while (1){
		scanf("%d", &a);
		
		if (!a){
			break;
		}
		
		printf("%lld\n", ans[a] / 3650 + ((a % 3650 == 0) ? 0 : 1));
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int third[][7] = {
  {0, 0, 0, 0, 0, 0, 0}, // 0
  {0, 0, 3, 5, 2, 4, 0}, // 1
  {0, 4, 0, 1, 6, 0, 3}, // 2
  {0, 2, 6, 0, 0, 1, 5}, // 3
  {0, 5, 1, 0, 0, 6, 2}, // 4
  {0, 3, 0, 6, 1, 0, 4}, // 5
  {0, 0, 4, 2, 5, 3, 0}  // 6
};

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

int N, T[102], F[102], state[102][102][102];

void solve() {
  memset(state, -1, sizeof state);
  const int cx = 50, cy = 0, cz = 50;
  rep(t,N) {
    int top = T[t], front = F[t], side = third[top][front];
    int x = cx, y = cy, z = cz;
    while (state[x][y][z] != -1) ++y;
    while (1) {
      bool ok = false;
      int ntop, nfront, nside, dir, nx, nz;
      for (int i = 6; i >= 4; --i) {
        if (top == i || (top + i == 7)) continue;
        if (front == i || side == i) {
          if (front == i) {
            nfront = top, ntop = 7 - front, nside = side, dir = 2;
          } else if (side == i) {
            nside = top, ntop = 7 - side, nfront = front, dir = 1;
          }
        } else {
          if (i == 7 - front) {
            ntop = front, nfront = 7 - top, nside = side, dir = 0;
          } else if (i == 7 - side) {
            ntop = side, nside = 7 - top, nfront = front, dir = 3;
          }
        }
        nx = x + dx[dir], nz = z + dz[dir];
        if ((y-1 >= 0) && (state[nx][y-1][nz] == -1)) {
          ok = true; break;
        }
      }
      if (!ok) {
        state[x][y][z] = top; break;
      }
      top = ntop, front = nfront, side = nside, x = nx, z = nz;
      while (y - 1 >= 0 && state[x][y-1][z] == -1) --y;
    }
  }
  vector<int> ans(6, 0);
  rep(xx,100) rep(zz,100) {
    for (int yy = 100; yy >= 0; --yy) {
      if (state[xx][yy][zz] != -1) {
        ++ans[state[xx][yy][zz]-1];
        break;
      }
    }
  }
  rep(i,6) {
    if (i) putchar(' ');
    printf("%d", ans[i]);
  }
  puts("");
}

int main() {
  while (scanf("%d", &N), N) {
    rep(i,N) scanf("%d%d", T+i, F+i);
    solve();
  }
  return 0;
}

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        bool ok=false;
        cin>>a[i];
        if(i>=k){
            if(a[i-k] < a[i]) ok=true;
            
            if(ok) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}

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

int main() {
  bool flag1=false,flag2=false;
  ll n,ans1,ans2,p=0;
  cin >> n;
  vector<int> a(n),b(n),c2(n);
  int c1[n];
  r(i,n)cin >> a[i];
  r(i,n)cin >> b[i];
  r(i,n)c1[i]=i+1;
  while(flag1==false||flag2==false){
    r(i,n)c2[i]=c1[i];
    if(equal(a.begin(),a.end(),c2.begin())){
      ans1=p; flag1=true;
    }
    if(equal(b.begin(),b.end(),c2.begin())){
      ans2=p; flag2=true;
    }
    next_permutation(c1,c1+n);
    p++;
  }
  cout<<abs(ans1-ans2)<<endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
#sys.setrecursionlimit(200000)
#input = sys.stdin.readline
n = int(input())
#x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
mai = 0
maigo = 0
for i in range(n):
    c.append(a[i]-b[i])
    if a[i]-b[i]<0:
        mai += 1
        maigo -= a[i]-b[i]
c.sort(key=lambda x:-x)
if mai == 0:
    print(0)
    exit()
ans = mai
for i in range(n):
    if c[i] < 0:
        print(-1)
        exit()
    maigo -= c[i]
    ans += 1
    if maigo <= 0:
        print(ans)
        exit()

Measured memory_bytes: 86960
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i32,
        K: i32,
        X: i32,
        Y: i32,
    }

    if N <= K {
        let ans = X * N;
        println!("{}", ans);
        return;
    }

    let ans = X * K + Y * (N - K);
    println!("{}", ans);
}


Measured memory_bytes: 2112
#include<map>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

auto p(int x){
  int s=x,t=x%10;
  while(x){
    s=x;
    x/=10;
  }
  return make_pair(s,t);
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  map<pair<int,int>,int> mp;
  rep(i,n){
    int x=i+1;
    mp[p(x)]++;
  }
  li ans=0;
  repa(i,1,10){
    li temp=mp[pair<int,int>(i,i)];
    ans+=temp*temp;
  }
  repa(i,1,9){
    repa(j,i+1,10){
      li t1=mp[pair<int,int>(i,j)];
      li t2=mp[pair<int,int>(j,i)];
      ans+=t1*t2*2;
    }
  }
  cout << ans;
}

/// confirm df==0 ///


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

using namespace std;

namespace {
vector<char> chars{'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'};  
}

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  string str = "";
  for (char c : S) {
    int idx = c - 'A';
    size_t res_idx = (idx + N) % 26;
    str += chars[res_idx];
  }
  cout << str << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
ll n, m;
bool vis[300005];
pll a[300005];
vll ans;
vpll adj[300005];
ll dfs(ll u, ll par = -1){
	vis[u] = 1;
	ll ret = a[u].se;
 	for (ll i = 0; i < adj[u].size(); i++){
 		pll v = adj[u][i];
 		if (!vis[v.fi]) ret ^= dfs(v.fi, v.se);
	}
	if (ret){
		if (par == -1){
			cout << -1 << endl; exit(0);
		}
		ans.pb(par);
	}
	return ret;
}
int main(){
	cin >> n >> m;
	for (ll i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se;
	sort(a + 1, a + n + 1);
	for (ll i = n + 1; i > 0; i--) a[i].se ^= a[i - 1].se;
	for (ll i = 1; i <= m; i++){
		ll l, r; cin >> l >> r; 
		l = lower_bound(a + 1, a + n + 1, mp(l, -1LL)) - a;
		r = upper_bound(a + 1, a + n + 1, mp(r, 2LL)) - a;
		if (l == r) continue;
		adj[l].pb(mp(r, i)); adj[r].pb(mp(l, i));
	}
	for (ll i = 1; i <= n; i++){
		if (!vis[i]) dfs(i);
	}
	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for (ll i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}

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

int main(){
  int n;
  cin>>n;
  long long ans=0;
  
  rep(i,n+1){
    if(i%3==0 or i%5==0)continue;
    else ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3648
#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(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();



int main(){
  int n,res=0; cin>>n; 
  int say_honest[n][n];
  REP(i,n)REP(j,n)say_honest[i][j]=0;
  
  //say_honest[i][jは]i番の人がj番目の人をdishonestと考えるとき-1、そうでなちゃ1
  REP(i,n){
    int a,res=0; cin>>a;
    REP(j,a){
      int x,y;
      cin>>x>>y;
      if(y==0)say_honest[i][x-1]=-1;
      if(y==1)say_honest[i][x-1]=1;
    }
  }
  

for(int bit=0;bit<(1<<n);bit++){
  bool flag=1;
  REP(i,n){
    if(!(bit&(1<<i)))continue;
   REP(j,n){
     if(say_honest[i][j]==-1&&(bit&(1<<j))){
       flag=0;
       break;
     }else if(say_honest[i][j]==1&&!(bit&(1<<j))){
       flag=0;
       break;
     }
   }
  }
  if(!flag)continue;
  int num=0;
  REP(i,n)if(bit&(1<<i))num++;
  res=max(res,num);
}

cout<<res<<endl; 

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm> 
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int *num=new int[n];
		for(int i=0;i<n;i++){
			cin>>num[i];
		}
		int sum=0;//初始化
		sort(num,num+n);
		cout<<num[n-1]-num[0]<<endl;
//		for(int i=0;i<n;i++){
//			cout<<num[i]<<" ";
//		}
		delete[] num;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut a = vec![Vec::new(); N];
    for i in 0..N {
        let A: usize = sc.get();
        for _ in 0..A {
            let x: usize = sc.get::<usize>()-1;
            let y: usize = sc.get();
            a[i].push((x, y));
        }
    }
    let mut ans = 0;
    for bit in 0..1<<N {
        let mut s = HashSet::new();
        for i in 0..N {
            if (bit>>i) & 1 != 0 {
                s.insert(i);
            }
        }
        let mut ok = true;
        'outer: for &si in &s {
            for &(x, y) in &a[si] {
                if (y == 0 && s.contains(&x)) || (y == 1 && !s.contains(&x)) {
                    ok = false;
                    break 'outer;
                }
            }
        }
        if ok {
            ans = max(ans, s.len());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld double_t
#define mod (li)(1e9+7)
const int MX1=1e2+5;
const int MX2=1e3+5;
const li inf=1e18;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n,m,x[MX2],y[MX2],mark[MX2],dis[MX1][MX1],c[MX2];

void solve(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=1e9+7;
		}
		dis[i][i]=0;
	}
	for(int i=1;i<=m;i++){
		cin>>x[i]>>y[i]>>c[i];
	}
	for(int i=1;i<=m;i++){
		dis[x[i]][y[i]]=min(dis[x[i]][y[i]],c[i]);
		dis[y[i]][x[i]]=min(dis[y[i]][x[i]],c[i]);
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=m;k++){
				if(dis[i][x[k]]+c[k]+dis[y[k]][j]==dis[i][j]){
					mark[k]=1;
				}
			}
		}
	}
	for(int i=1;i<=m;i++){
		if(mark[i]==0) ans++;
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")

int gcd(int a, int b)
{
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

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

	int MAXN = 1000100, n, i, j, k, g, ct;
	bool pairwise, setwise;

	cin >> n;
	vector<int> a(n);
	vector<int> used(MAXN, 0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) g = a[i];
		else g = gcd(g, a[i]);
		used[a[i]]++;
	}

	pairwise = true;
	for (i = 2; i < MAXN; i++) {
		ct = 0;
		for (j = i; j < MAXN; j += i) ct += used[j];
		if (ct > 1) pairwise = false;
	}

	if (pairwise) cout << "pairwise coprime\n";
	else if (g == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";


	return 0;
}



Measured memory_bytes: 11076
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e6 + 5;
int n;
int arr[maxn][3];
int dp[maxn][3];
int rek(int at, int prev){
    if(at == n){
        return 0;
    }
    if(dp[at][prev] != -1){
        return dp[at][prev];
    }
    int ret = -INF;
    for(int i = 0; i < 3; i ++){
        if(i == prev) continue;
        ret = max(ret, rek(at + 1, i) + arr[at][i]);
    }
    return dp[at][prev] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    cin >> n;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < 3; j ++){
            cin >> arr[i][j];
            dp[i][j] = -1;
        }
    }
    cout << max(rek(1, 0) + arr[0][0], max(rek(1, 1) + arr[0][1], rek(1, 2) + arr[0][2]));
    return 0;
}


Measured memory_bytes: 11776
n,k=map(int,input().split())
mod=1000000007
a=list(map(int,input().split()))
zenbu=sorted(a)
aa=[]
ans=0
for i in range(n):
  kouhan=a[i:]
  kouhan.sort()
  b1=int(zenbu.index(a[i]))
  b2=int(kouhan.index(a[i]))
  #print(b1,b2)
  #print((k*(k-1)*b1/2)+k*b2)
  ans=ans+k*(k-1)*b1//2+k*b2
  ans=int(ans)%mod
print(ans)


Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

 */
int x,a,b;
int main(){
  cin >> x>>a>>b;
  if (abs(x-a)>abs(x-b)) {
    cout << "B" << endl;
  } else {
    cout << "A" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int

int N;
vector<ll> aa;
vector<ll> raa;
vector<vector<ll>> dp;

ll calc(int l, int r){
  if(r-l <= 0){
    return 0;
  }else if(r-l == 1){
    return aa[l]+aa[r];
  }else{
    if(dp[l][r] != -1){
      return dp[l][r];
    }else{
      ll tmp = LLONG_MAX;
      for (int s = l; s < r; s++) {
        tmp = min(calc(l,s)+calc(s+1,r)+raa[r+1]-raa[l],tmp);
      }
      dp[l][r] = tmp;
      return tmp;
    }
  }
}


int main(void){
  cin >> N;
  ll tmp = 0;

  aa.assign(N,0);
  raa.assign(N+1,0);
  dp.assign(N,vector<ll>(N,-1));
  for (size_t i = 0; i < N; i++){
    cin >> aa[i];
    tmp += aa[i];
    raa[i+1] = tmp;
  }

  cout << calc(0,N-1) << endl;

}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,m,k;

int main(){
    cin>>n>>m>>k;
    if(k == 0){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int s = n * m;
            s -= (n - i) * j;
            s -= (m - j) * i;
            if(s == k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;




int a[100005];

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

  int al,bl;
  cin >> al >> bl;
  a[0] = 0;
  rep1(i,1000) a[i] = a[i-1]+i;

  prints(a[bl-al] - bl);


  return 0;

}


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

using namespace std;

int dp[123456], a[123456];
const int inf = 0x7f7f7f7f;
int main(){
//    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i)dp[i] = inf;
    dp[0] = 0;
    for(int i = 0; i < n ; ++i){
        for(int j: {i+1, i+2}){
            if(j < n)
            dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    a = [input() for i in range(h)]
    d = defaultdict(lambda : 0)
    for i in a:
        for j in i:
            d[j] += 1
    l = []
    s = deque()
    for i in d.keys():
        if d[i]&1:
            l.append(i)
        elif d[i]&3:
            s.append(i)
    if len(l) > 1:
        print("No")
        return

    if (h&1) and (w&1):
        if not l:
            print("No")
            return
        d[l[0]] -= 1
        if d[l[0]]&3:
            s.append(l[0])
    n = (h>>1)*(w&1)+(w>>1)*(h&1)
    for i in range(n):
        if not s:
            break
        x = s.pop()
        d[x] -= 2
        if d[x]&3:
            s.append(x)
    if not s:
        print("Yes")
        return
    print("No")
    return


#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n = sc.nextInt();
		//String[][] array = new String[100][500];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();

		int n = sc.nextInt();
		String s = sc.next();

		if(n>=3200) {
			System.out.println(s);
		}

		else {
			System.out.println("red");
		}
		}

}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define endl '\n'
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
int main(){
    //まず素数表を完成させる->エラストテネスのふるい
    bitset<MAX_B>is_prime(0);
    for(int i=2;i<MAX;i++)is_prime.set(i);
    for(int i=2;i<MAX;++i){
        if(is_prime[i]){
            for(int j=i*2;j<MAX;j+=i){
                is_prime.set(j,0);
            }
        }
    }
    //2017-like
    bool a[MAX];
    for(int i=1;i<MAX;i+=2){
        if(is_prime[i] && is_prime[(i+1)/2]){
            a[i]=1;
        }
    }
    //累積和
    int sum[MAX];
    sum[1]=0;
    for(int i=1;i<MAX;i++){
        sum[i+1]=sum[i]+a[i];
    }
    //あとは問題の処理
    int q,l,r;
    cin>>q;
    rep(i,q){
        cin>>l>>r;
        cout<<sum[r+1]-sum[l]<<endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int prime[20000000];
int a[300001];
map<int, int> mp;
vector<int> pr;
void sieve(int n)
{

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == 0)
        {

            for (int i = p * p; i <= n; i += p)
                prime[i] = p;
        }
    }
    for (int i = 2; i <= 20000000;i++){
        if(prime[i]==0)
            pr.pb(i);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    sieve(20000000);
    //cin >> tc;
    while (tc--)
    {
        string s;
        cin >> s;
        if(s=="ABC"){
            cout << "ARC";
            
        }
        else{
            cout << "ABC";
        }
    }

    return 0;
}

Measured memory_bytes: 89632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,w;
    cin>>n>>w>>w;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    if(n==1)cout<<abs(a[0]-w)<<endl;
    else cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w))<<endl;
}


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

int main(){
  int n;
  cin >> n;
  int s=0;
  int t=n;
  while(t!=0){
    s+=t%10;
    t/=10;
  }
  if(n/s*s==n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long giant;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int q=1e9+7;
const giant mod=(LLONG_MAX/q-1)*q;
const int maxn=3;
const int maxm=1e5+1;
const int maxj=31;
int n,m,c[maxm];
struct mat {
	int n,m;
	int a[maxn][maxn];
	mat () {clear();}
	mat (int _n,int _m):n(_n),m(_m) {clear();}
	inline void clear() {
		memset(a,0,sizeof a);
	}
	void init_A() {
		n=m=3;
		a[0][0]=2,a[0][1]=2,a[0][2]=1;
		a[1][0]=1,a[1][1]=1,a[1][2]=1;
		a[2][0]=1,a[2][1]=0,a[2][2]=1;
	}
	void init_B() {
		n=m=3;
		a[0][0]=1,a[0][1]=2,a[0][2]=1;
		a[1][0]=0,a[1][1]=1,a[1][2]=1;
		a[2][0]=0,a[2][1]=0,a[2][2]=1;
	}
	void init_f() {
		n=3,m=1;
		a[0][0]=1,a[1][0]=1,a[2][0]=1;
	}
	inline void eye(int _n,int _m) {
		n=_n,m=_m;
		assert(n==m);
		clear();
		for (int i=0;i<n;++i) a[i][i]=1;
	}
	mat operator * (const mat &b) const {
		assert(m==b.n);
		mat ret(n,b.m);
		for (int i=0;i<n;++i) for (int j=0;j<b.m;++j) {
			giant tmp(0);
			for (int k=0;k<m;++k) if ((tmp+=1ll*a[i][k]*b.a[k][j])>=mod) tmp-=mod;
			ret.a[i][j]=tmp%q;
		}
		return ret;
	}
} mi[maxj],A,B,f;
mat go(int y) {
	mat ret;
	ret.eye(3,3);
	for (int j=0;j<maxj;++j) if (y>>j&1) ret=ret*mi[j];
	return ret;
}
int main() {
	n=read(),m=read(),generate_n(c+1,m,read);
	A.init_A(),B.init_B(),f.init_f();
	mi[0]=A;
	for (int j=1;j<maxj;++j) mi[j]=mi[j-1]*mi[j-1];
	int now=1;
	for (int i=1;i<=m;++i) {
		f=B*go(c[i]-now)*f;
		now=c[i]+1;
	}
	f=go(n-now)*f;
	int ans=f.a[0][0];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#define REP(i,n) for(int i=0;i<(int)n;++i)
#ifdef __GNUC__
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T val){
  val = val - ((val >> 1) & 0x55555555);
  val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
  val = (val + (val >> 4)) & 0x0f0f0f0f;
  val += val >> 8;
  val += val >> 16;
  return (int)(val & 0x0000003f);
}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
ll getTen(int a){return (a<=0)?1:(getTen(a-1)*10);}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}


int N,M;
int L[2001];
bool dp[1001][1<<12];
pii tos[1001][1<<12];
int main(){

  while(cin>>N>>M&&(N|M)){
    for(int i=0;i<N;i++)cin>>L[i];
    const int delOverBitMask=((1<<M)-1);
    for(int i=N;i>=0;i--){
      for(int mask=0;mask<(1<<M);mask++){
        bool res=false;
        if(i==N)res=true;
        else{
          if(popcount(mask)==L[i]){
            int nmask=(mask<<1)&delOverBitMask;
            res|=dp[i+1][nmask];
            if(dp[i+1][nmask])tos[i][mask]=pii(i+1,nmask);
            nmask|=1;
            res|=dp[i+1][nmask];
            if(dp[i+1][nmask])tos[i][mask]=pii(i+1,nmask);
          }
        }
        dp[i][mask]=res;
      }
    }
    // 条件を満たす開始posを探す
    for(int smask=0;smask<(1<<M);smask++){
      if(dp[0][smask]){
        int cpos=0;
        int cmask=smask;
        for(int i=M-1;i>=1;i--)cout<<((smask>>i)&1);
        while(cpos<=N-1){
          cout<<(cmask&1);
          pii to=tos[cpos][cmask];
          cpos=to.first;
          cmask=to.second;
        }
        cout<<endl;
        break;
      }
      if(smask==(1<<M)-1)cout<<"Goofy"<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 37216
d, g = map(int, input().split())
PC = [0] + [[int(i) for i in input().split()] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    
    n = min(g // (100 * i), PC[i][0])
    score = n * 100 * i
    
    if n == PC[i][0]:
        score += PC[i][1]
        
    if g > score:
        n += dfs(g - score, i - 1)
        
    return min(n, dfs(g, i - 1))

print(dfs(g, d))    

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#define MAX 200000
using namespace std;

const long long mod = 2019;
long long dp[2020];

//aC2を返す
long long choose(long long a){
    long long ans;
    ans = a*(a - 1)/2;

    return ans;
}

int main(){
    string s;
    cin >> s;
    int sl = s.size(); //sのサイズ
    //cout << sl << endl;
    //sの累積和を入れる
    vector<int> t(sl),tt(sl); //累積和
    long long ten = 1; //10の累乗
    long long ss; //s.at(i)のlong long 型

    //cout << endl;

    for(int i = sl - 1;i >= 0;i--){
        ss = (s.at(i) - '0');
        t.at(i) = (ten*ss)%mod;
        ten *= 10;
        ten = ten%mod; 
        //cout << i << ":";
        //cout << ten << " ";
        //cout << t.at(i) << endl;
    }

    //累積
    tt.at(0) = t.at(0);
   // cout << tt.at(0) << endl;
    dp[tt.at(0)]++;
    for(int i = 1;i < sl;i++){
        tt.at(i) = (tt.at(i - 1) + t.at(i))%mod;
        //cout << tt.at(i) << endl;
        dp[tt.at(i)]++;
    }

    //mod2019の値が等しいものを見つける

    long long ans = dp[0];

    for(int i = 0;i < mod;i++){
        if(dp[i] >= 2){
            ans += choose(dp[i]);
            //cout << "aaa" << endl;
        }
    }

    cout << ans << endl;

    

    return 0;
}


Measured memory_bytes: 5192
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_a
# A - ABD

# A_ABD.py

N = int(input())

C_or_D = (N-1) // 999


name = ""

if C_or_D == 0:
    name += "ABC"
    #n = N
elif C_or_D == 1:
    name += "ABD"
    #n = '{0:03d}'.format(N - 999)

#ame += str(n)

print(name)


Measured memory_bytes: 2940
a, b = map(int,input().split())
s=list(input())
f=0
for i in range(0,a):
   # print(s[i])
    if(s[i]<'0' or s[i]>'9'):
        f=1
        break

if(s[a]!='-'):
    f=1
               
for i in range(a+1,a+1+b):
   # print(s[i])
    if(s[i]<'0' or s[i]>'9'):
        f=1
        break
if(f==0):
    print("Yes")
else:
    print("No")


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

using namespace std;

typedef long long int ll;

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

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

void ans(vector<int> x){
	for(int i = 1; i < x.size(); i++){
		cout << x[i] << (i!=x.size()?" ":"");
	}printf("\n");
}

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

	vector<int> a(n+1),b(n+1);
	for(int i = 1; i <= n; i++){
		a[i] = 3*1e4*(i);
		b[i] = 3*1e4*(n-i)+1;
	}
	for(int i = 0; i < n; i++){
		b[p[i]] += i;
	}

	ans(a);
	ans(b);

	return 0;
}

Measured memory_bytes: 896