akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n,y;
int p=-1,q=-1,r=-1;
bool flag=false;

int main() {
    cin >> n >> y;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=n-i;++j){
            int k=n-i-j;
            if (i*10000+j*5000+k*1000==y){
                p=i,q=j,r=k;
                flag=true;
                break;
            }
        }
        if (flag==true) break;
    }
    cout << p << " " << q << " " << r << endl;
}

Measured memory_bytes: 256
import itertools

H = 'MARCH'
N = int(input())
S = [input() for _ in range(N)]

march = {i: 0 for i in H}
for s in S:
    if s[0] in H:
        march[s[0]] += 1

ans = 0
for i, j, k in itertools.combinations(H, 3):
    ans += march[i] * march[j] * march[k]

print(ans)

Measured memory_bytes: 9776
def insertSort(li,num):
	for i in range(1,num):
		j = i
		while li[j] < li[j-1] and j > 0 :
			tmp = li[j]
			li[j] = li[j-1]
			li[j-1] = tmp
			j -=1

		for k in range(len(li)):
			if k != len(li)-1:
				print(li[k],"",end="")
			else:
				print(li[k])

if __name__ == '__main__':
	num = int(input())
	li = list(map(int,input().split()))

	for i in range(len(li)):
		if i != len(li)-1:
			print(li[i],"",end="")
		else:
			print(li[i])

	insertSort(li,num)


Measured memory_bytes: 6308
#include<iostream>
using namespace std;
 
int main(){
  int W,a,b;
  while(cin>>W>>a>>b){
    if(b+W>=a&&b<=a+W)
      cout<<0<<endl;
    else if(b>a+W)
      cout<<b-a-W;
    else
      cout<<a-b-W;
  }
  return 0;
}

Measured memory_bytes: 3188
N, K = map(int, input().split())
d = {}
for x in map(int, input().split()):
    n = d.get(x, 0) + 1
    d[x] = n

cnt = len(d)
ret = 0
for k, v in sorted(d.items(), key=lambda item: item[1]):
    if K >= cnt:
        print(ret)
        exit()

    ret += v
    cnt -= 1


Measured memory_bytes: 41120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define pri(x) (printf("%d", x))
#define prll(x) (printf("%lld", x))
#define sci(x) (scanf("%d", &x))
#define scll(x) (scanf("%lld", &x))
#define endl printf("\n");
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n;
  ll a[99999];
  sci(n);
  for(int i = 0; i < n; i++) scll(a[i]);

  ll b = 0; int s = -1;
  for(int i = 0; i < n; i++){
    s *= -1;
    b += s * a[i];
  }
  prll((b));printf(" ");
  for(int i = 1; i < n; i++){
    b = -b + 2 * a[i - 1];
    prll((b )); printf(" ");
  }
  return 0;
}


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

int main() {
 int n;
 string s;
 bool flag = true;
 cin >> n;
 for(int i = 0;i < n;i++){
   cin >> s;
   if(s == "Y"){
     cout << "Four" << endl;
     flag = false;
     break;
   }
 }
 if(flag){
  cout << "Three" << endl;
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std; 
int main()
{
    ll n,k;
    cin>>n;//>>k;
    k=2;
    ll h[n];
    for(ll i=0;i<n;i++)cin>>h[i];
    ll dp[n];
    memset(dp,mod,sizeof(dp));
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        
        for(ll j=i-1;j>=i-k&&j>=0;j--)dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
    }
    cout<<dp[n-1];
}

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

int main() {
  int N,A,B;
  int x=0,y=0,z=0;
  cin>>N>>A>>B;
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    if(p<=A)
      x++;
    else if(p>=B+1)
      z++;
    else y++;
  }
  if(x<=y&&x<=z)
    cout<<x<<endl;
  else if(y<=z)
    cout<<y<<endl;
  else cout<<z<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val cards = StdIn.readLine().split(" ").map(_.toInt).toList.sorted.reverse
  val aliceCards = for {
    i <- 0 until N
    if (i % 2 == 0)
  } yield cards(i)
  val bobCards = for {
    i <- 0 until N
    if (i % 2 == 1)
  } yield cards(i)
  println(aliceCards.sum - bobCards.sum)
}


Measured memory_bytes: 27320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a - b >= 0)
    cout << "delicious" << endl;
  else if (b - a > x)
    cout << "dangerous" << endl;
  else
    cout << "safe" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(a + b > 23 ? a + b - 24 : a + b);
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int n, m, x;

// 買う参考書の番号リスト
vector<int> buyList;

vector<int> c;
vector<vector<int>> a;
const int INF = 1e9;
int ans = INF;

// 再帰
void dfs(int pos /* 何番目の参考書の処理を行うか？(0-indexed) */) {
  if (pos == n) {
    // 参考書を買って成長度の条件を満たすかチェックする
    vector<int> r(m, 0);
    int price = 0;
    for (int i : buyList) {
      price += c[i];
      for (int j = 0; j < m; j++) {
        r[j] += a[i][j];
      }
    }
    // 全部x以上か？
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (r[j] < x) {
        ok = false;
      }
    }
    if (ok) {
      ans = min(ans, price);
    }
    return;
  }

  // 使わないとき
  dfs(pos + 1);

  // 使うとき
  buyList.push_back(pos);
  dfs(pos + 1);
  // 今の番号を削除
  buyList.pop_back();
}

int main() {
  cin >> n >> m >> x;
  c = vector<int>(n);
  a = vector<vector<int>>(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  dfs(0);
  if (ans == INF) {
    ans = -1;
  }
  cout << ans << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, T;
    cin >> A >> B >> T;

    ll i = 1;
    ll ans = 0;
    while(T > 0){
        T -= A*i;
        if(T+0.5>0) ans += B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn main(){
    let mut n:i32 = getline().trim().parse().unwrap();
    let mut c = 0;
    while n >= 2 {
        n /= 2;
        c += 1;
    }
    while c > 0 {
        n *= 2;
        c -= 1;
    }
    println!("{}", n);
}

fn getline() -> String{
    let mut __ret=String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}


Measured memory_bytes: 4352
open Bytes
let s = read_line ()
let b = of_string s
let i = ref 0
let _ = String.iter (function 'B' -> i := max 0 @@ !i - 1 | c -> set b !i c; incr i) s;
  iteri (fun j c -> if j < !i then print_char c) b; print_newline ()

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main()
{int N; cin >> N;
 int ans = 0;
 for(int i = 1; i <= N; i += 2){
   int cnt = 0;
   for(int j = 1; j <= i; j++){
     if( i % j == 0){ cnt++;}}
     if(cnt == 8){ans++;}}
 
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,m;
int x[1010101],y[1010101],pre[1010101],nxt[1010101];
ll dp[1010101];
ll tr[1010101];
struct node{
	int x,y;
}T[1010101];
int cac[1010101],tot,cnt;
inline bool cmp(node a,node b){
	return a.x==b.x?a.y>b.y:a.x<b.x;
}
inline void add(int x,ll y){
	for (;x<=tot;x+=x&-x) tr[x]=(tr[x]+y)%ljc;
}
inline ll query(int x){
	ll ans=0;
	for (;x;x-=x&-x) ans=(tr[x]+ans)%ljc;
	return ans;
}
signed main(){
	n=read(),m=read();
	for (int i=1;i<=n;i++) x[i]=read();
	for (int i=1;i<=m;i++) y[i]=read();
	sort(x+1,x+1+n),sort(y+1,y+1+m);
	y[0]=-1,y[m+1]=1e9+1;
	int i=1,j=0;
	for (;i<=n;i++){
		for (;j<m&&y[j+1]<x[i];j++);
		pre[i]=y[j];
	}
	j=m+1;
	for (i=n;i;i--){
		for (;j>1&&y[j-1]>x[i];j--);
		nxt[i]=y[j];
	}
	for (int i=1;i<=n;i++){
		if (nxt[i]!=y[m+1]&&pre[i]!=-1){
			T[++cnt].x=x[i]-pre[i],T[cnt].y=nxt[i]-x[i];
		}
	}
	for (int i=1;i<=cnt;i++) cac[++tot]=T[i].x,cac[++tot]=T[i].y;
	sort(cac+1,cac+1+tot);
	tot=unique(cac+1,cac+1+tot)-cac-1;
	for (int i=1;i<=cnt;i++) T[i].x=lower_bound(cac+1,cac+1+tot,T[i].x)-cac;
	for (int i=1;i<=cnt;i++) T[i].y=lower_bound(cac+1,cac+1+tot,T[i].y)-cac;
	sort(T+1,T+1+cnt,cmp);
	ll _=0,tmp=0;
	for (int i=1;i<=cnt;i++){
		dp[i]=(query(T[i].y-1)+1)%ljc;
//		tmp+=dp[i];tmp%=ljc;
		if (T[i].y!=T[i+1].y||T[i].x!=T[i+1].x)	/*add(T[i].y,tmp),tmp=0;*/
			_=(_+dp[i])%ljc,add(T[i].y,dp[i]);
	}
	cout<<(_+1)%ljc;
	return 0;
}



Measured memory_bytes: 8636
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {

  int n[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << n[k-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>


int main(){
	int a, b, c;
	std::cin >> a >> b >>c;
	std::cout << std::max(b+c-a,0) << std::endl; 
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	int res = 0;
	rep(i, n){
		cin >> a[i];
		res += (a[i] % 2);
	}
	cout << (!res ? "second" : "first") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;
int n;
int a[109][30];
int p[109][13];
long long ans=-100000000000;
void check(bool s[13])
{
    long long sum=0,is=0;
    for(int i=1;i<=n;i++)
    {
        int k=0;
        for(int j=1;j<=10;j++)
            if(a[i][j]&&s[j]){is=1;k++;}
        sum=sum+p[i][k];
    }
    if(is==0)return ;
    ans=max(ans,sum);
}
void ssss(int i,bool s[13])
{
    if(i==11)
    {
        check(s);return ;
    }
    s[i]=1;
    ssss(i+1,s);
    s[i]=0;
    ssss(i+1,s);
    return ;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=10;j++)
            cin>>a[i][j];
    for(int i=1;i<=n;i++)
        for(int j=0;j<=10;j++)
            cin>>p[i][j];
        bool o[30];
        memset(o,0,sizeof(o));
        ssss(0,o);
cout<<ans;
}


Measured memory_bytes: 256
def main
  n = gets.chomp.to_i
  numbers = gets.chomp.split(' ').map(&:to_i).sort
  
  combi = []

  (n-2).times do |_i|
    x = numbers.shift
    y = numbers.pop
    c = if (x - y).abs > (y - x).abs
          [x, y]
        elsif (x - y).abs < (y - x).abs
          [y, x]
        elsif (x - y).abs == (y - x).abs
          if numbers[-1] <= -1 
            x-y >= y-x ? [x, y] : [y, x]
          else
            [x, y]
          end
        end
    
    diff =  c[0] - c[1]
    combi << [c[0],c[1]]
    if numbers[-1] <= diff
      numbers.push(diff)
    else
      numbers.unshift(diff)
    end
  end

  combi << [numbers[1], numbers[0]]
  numbers = numbers[1] - numbers[0]
  
  puts numbers
  combi.each {|x,y| puts"#{x} #{y}" }
end


main

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N, D; cin >> N >> D;
    VV<int> x(N);
    rep(i, N) {
        rep(j, D) {
            int a; cin >> a;
            x[i].pb(a);
        }
    }
    int ans = 0;
    rep(i, N) {
        rep(j, i) {
            int t = 0;
            rep(k, D) t += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            bool ok = 0;
            for (int a = 1; a * a <= t; ++a) {
                if (a * a == t) {
                    ok = 1;
                }
            }
            ans += ok;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

    string s;
    cin >> s;

    char c;
    for(int i=0;i<s.size();i++){
        c = s[i] + n;
        if(c > 'Z'){
            c = c - 26;
            cout << c;
        }else{
            cout << c;
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int N;
int a, b, c, d;
int e[1000000];	//10^6
int ans;

void solve() {
	cin >> a >> b;
	if (a > b) cout << a - 1 << endl;
	else cout << a << endl;
}

int main() {
	solve();
	return 0;
}

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

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    data.assign(n, -1);
  }
  int root(int k) {
    if (data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int k) {
    return -data[root(k)];
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      uf.unite(x, y);
    } else {
      cout << uf.same(x, y) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3132
l = [0] * 5
for i in range(5):
  l[i] = int(input())
k = int(input())

#print(l, k)

for i in range(5):
  for j in range(5):
    if abs(l[i] - l[j]) > k:
      print(':(')
      exit()

print('Yay!')

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

int main() {
  string S;
  cin >> S;
  int ame=0;
  for(int i=0;i<3;i++) {
    if(S.at(i)=='R') {
      if(i<=1) {
        if(S.at(i+1)=='R') {
          if(i==0) {
            if(S.at(i+2)=='R') {
              ame=3;
              break;
            } else {
              ame=2;
              break;
            }
          } else {
            ame=2;
            break;
          }
        } else {
          ame=1;
          break;
        }
      } else {
        ame=1;
        break;
      }
    }
  }
  cout << ame << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using namespace std;
using lint = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define rep_inv(i, n) for (lint i = (n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

//constexpr lint mod = 998'244'353LL;
constexpr lint Mod = 1000'000'007LL;
constexpr lint Inf = 3'000'000'000'000'000'007LL; //3e18+7
constexpr double Pi = 3.141592653589793;

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

bool pri(lint x) { 
	for (lint i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return 1 < x; 
}

lint fact[3000000];
void fact_init(lint n, lint m = Mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1] % m;
	}
}

lint modpow(lint x, lint n, lint m = Mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = Mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

int main() {
	lint n, d, ans = 0;
	cin >> n >> d;
	rep(i, n) {
		lint x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
}

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

int main(){
  int num;
  rep(i,5){
    cin >> num;
    if(num==0){
      cout << i;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
//cin.tie(NULL);
   long long int n,sum=0,curr_sum=0,ans=0,t;
   cin>>n;
for(long long int i=1;i<=n;i++)
{
    if(i%3==0||i%5==0)
        continue;
    else
        ans+=i;
}
  cout<<ans<<endl;
}


Measured memory_bytes: 3640
package main

import (
	"fmt"
	"math"
	"reflect"
)

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func main() {
	// Code for C - Count Order
	var N int
	fmt.Scanf("%d", &N)

	P := make([]int, N)
	Q := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &P[i])
	}

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &Q[i])
	}

	a := make([]int, 0)
	for i := 1; i <= N; i++ {
		a = append(a, i)
	}

	var n = len(a) - 1
	var i, j int
	var ans1, ans2 int

	if reflect.DeepEqual(a, P) {
		ans1 = 1
	}
	if reflect.DeepEqual(a, Q) {
		ans2 = 1
	}

	for count := 2; count <= factorial(len(a)); count++ { // 3! = 6:
		i = n - 1
		j = n
		for a[i] > a[i+1] {
			i--
		}
		for a[j] < a[i] {
			j--
		}
		a[i], a[j] = a[j], a[i]
		j = n
		i++
		for i < j {
			a[i], a[j] = a[j], a[i]
			i++
			j--
		}

		if reflect.DeepEqual(a, P) {
			ans1 = count
		}
		if reflect.DeepEqual(a, Q) {
			ans2 = count
		}
	}

	fmt.Println(int(math.Abs(float64(ans2 - ans1))))
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		int n=sc.nextInt();
		String s=sc.next();
		char[] c=new char[n];
		c=s.toCharArray();
		int sum=0;
		int max=0;
		for(int i=0;i<n;i++){
			if(c[i]=='I') sum=sum+1;
			if(c[i]=='D') sum=sum-1;
			if(max<sum) max=sum;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 23636
package main

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

const MaxW = 1000
const MaxN = 1000

type Tuple struct {
	Value  int
	Weight int
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func solve(w int, n int, vws []Tuple) Tuple {
	var dp [MaxN + 1][MaxW + 1]int

	for i := 0; i < n; i++ {
		for j:= w; j > 0; j-- {
			if j < vws[i].Weight {
				dp[i + 1][j] = dp[i][j]
			} else {
				dp[i + 1][j] = int(math.Max(float64(dp[i][j]), float64(dp[i][j - vws[i].Weight] + vws[i].Value)))
			}
		}
	}

	maxValue := dp[n][w]
	minWeight := w

	for j := w - 1; j > 0; j-- {
		if maxValue == dp[n][j] {
			minWeight = j
		} else {
			break
		}
	}

	return Tuple{Value: maxValue, Weight: minWeight}
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	index := 1
	for {
		var w, n int
		w, _ = strconv.Atoi(nextLine(sc))
		if w == 0 {
			return
		}
		n, _ = strconv.Atoi(nextLine(sc))

		vws := make([]Tuple, n, n)
		for i := 0; i < n; i++ {
			array := strings.Split(nextLine(sc), ",")
			v, _ := strconv.Atoi(array[0])
			w, _ := strconv.Atoi(array[1])
			vws[i] = Tuple{Value: v, Weight: w}
		}

		t := solve(w, n, vws)
		fmt.Printf("Case %d:\n", index)
		fmt.Println(t.Value)
		fmt.Println(t.Weight)
		index++
	}
}



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

const int N = 100005;
bool used[N * 3];

int n;
int a[4][N];
int r[N];
int sign[N];
int c[N], m; // for solve()
int inv[2];
int flip[2];

void No() { printf("No\n"); exit(0); }

struct FenwickTree {
	int T[N];
	FenwickTree() { memset(T, 0, sizeof T); }
	void upd(int x) { for (; x < N; x += x & -x) T[x]++; }
	int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; }
} bit;

int solve() {
	long long res = 0;
	bit = FenwickTree();
	for (int i = m; i >= 1; --i) {
		res += bit.get(c[i]); bit.upd(c[i]);
	}
	return (int)(res & 1);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= 3; ++i) {
		for (int j = 1; j <= n; ++j) cin >> a[i][j], used[a[i][j]] = 1;
	}
	for (int val = 1; val <= 3 * n; ++val) if (!used[val]) No();

	for (int i = 1; i <= n; ++i) {
		int val = a[1][i];
		val += 3;
		for (int row = 1; row <= 3; ++row) {
			if ((val - row) % 3 == 0) {
				int col = (val - row) / 3;
				if (row == 1) r[i] = +col; else r[i] = -col;
				break;
			}
		}
		val -= 3;
		if (r[i] == 0) No();
		if (r[i] > 0 && (a[2][i] != val + 1 || a[3][i] != val + 2)) No();
		if (r[i] < 0 && (a[2][i] != val - 1 || a[3][i] != val - 2)) No();

		if (r[i] < 0) r[i] = -r[i], sign[i] = 1; 
		if (r[i] % 2 != i % 2) No();
 	}
 	
 	// solve odd
  m = 0;
 	for (int i = 1; i <= n; i += 2) c[++m] = r[i], flip[1] ^= sign[i];
 	inv[1] = solve();

 	// solve even
 	m = 0;
 	for (int i = 2; i <= n; i += 2) c[++m] = r[i], flip[0] ^= sign[i];
 	inv[0] = solve();
 	

 	if (flip[0] != inv[1] || flip[1] != inv[0]) No();
 	printf("Yes\n");
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    
    if(N % 2 == 1) PR(0);
    else {
        N /= 2;
        ll d = 1, cnt = 0;
        while(N / d > 0) {
            d *= 5;
            cnt += N / d;
        }
        PR(cnt);
    }

    return 0;
}

/*

f(2n) = (2n) * (2n-2) * ... * 4 * 2
      = (2^n) * n * (n-1) * ... * 2 * 1

*/

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

// 'P', 'Q', 'R' ツづー '1', '2', '3' ツづ可置ツつォツ環キツつヲツづゥ
void PQR_change(string& s ,char p , char q , char r ){
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == 'P' ) s[i] = p;
		if( s[i] == 'Q' ) s[i] = q;
		if( s[i] == 'R' ) s[i] = r;
	}
}

// "--"(ツ連ツ堕アツつキツづゥ2ツづつづ個マツイツナツス) ツづー "" ツづ可置ツつォツ環キツつヲツづゥ
void minus_erace(string& s){
	for(int i=1 ; i < s.size() ; i++ ){
		if( s[i] == '-' && s[i-1] == '-' ){
			s.erase( i-1 , 2 );
			i = 0;
		}
	}
}

// "-0", "-1", "-2" ツづー "2", "1", "0" ツづ可置ツつォツ環キツつヲツづゥ
void minus_calc(string& s){
	for(int i=1 ; i < s.size() ; i++ ){
		if( s[i-1] == '-' && ( s[i] == '0' || s[i] == '1' || s[i] == '2' ) ){
			if( s[i] == '0' ){
				s.replace( i-1 , 2 , "2" );
			}else if( s[i] == '1' ){
				s.replace( i-1 , 2 , "1" );
			}else if( s[i] == '2' ){
				s.replace( i-1 , 2 , "0" );
			}
			i = 0;
		}
	}
}

// "(0+0)", ... , "(2*2)" ツづー "0", ... , "2" ツづ可置ツつォツ環キツつヲツづゥ (18ツ津環づィ) 
void calc(string& s){
	string ex[18] = {
		"(0+0)", "(0+1)", "(0+2)",
		"(1+0)", "(1+1)", "(1+2)",
		"(2+0)", "(2+1)", "(2+2)",
		"(0*0)", "(0*1)", "(0*2)",
		"(1*0)", "(1*1)", "(1*2)",
		"(2*0)", "(2*1)", "(2*2)"
	};
	string result[18] = {
		"0", "1", "2",
		"1", "1", "2",
		"2", "2", "2",
		"0", "0", "0",
		"0", "1", "1",
		"0", "1", "2"
	};
	for(int i=0 ; i+4 < s.size() ; i++ ){
		for(int j=0 ; j < 18 ; j++ ){
			if( s.substr(i,5) == ex[j] ){
				s.replace( i , 5 , result[j] );
				i = -1;
				break;
			}
		}
	}
}

int main(){
	string s;
	while( cin >> s , s != "." ){
		int ans = 0;
		for(char p = '0' ; p <= '2' ; p++ ){
			for(char q = '0' ; q <= '2' ; q++ ){
				for(char r = '0' ; r <= '2' ; r++ ){
					string s_ = s;
					// 'P', 'Q', 'R' ツづー '1', '2', '3'ツづ可置ツつォツ環キツつヲツづゥ
					PQR_change( s_ , p , q , r );
					// "--"(ツ連ツ堕アツつキツづゥ2ツづつづ個マツイツナツス) ツづー ""ツづ可置ツつォツ環キツつヲツづゥ
					minus_erace( s_ );
					
					// "0", "1", "2" ツづ個値ツづ可づ按づゥツづ慊づ繰ツづィツ陛板つオツ嘉算ツづ湘ヲツ算ツづーツ計ツ算ツつキツづゥ
					while( s_.size() > 1 ){
						// "-0", "-1", "-2" ツづー "2", "1", "0" ツづ可置ツつォツ環キツつヲツづゥ
						minus_calc( s_ );
						// "(0+0)", ... , "(2*2)" ツづー "0", ... , "2" ツづ可置ツつォツ環キツつヲツづゥ (18ツ津環づィ) 
						calc( s_ );
						// cout << "debug : " << s_ << endl;
					}
					if( s_ == "2" ){
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}	
}

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

int main() {
	int a, b, c ,d = 0 ;
	cin >> a >> b >> c;
	if (a != b)d++;
	if (b != c)d++;
	if (c != a)d++;
	if (a == b && b == c && c == a)d++;
	cout << d << endl;
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

string s;
int main () {
	cin >> s;
	cout << s[0] << s[1] << s[2];
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define MAXN 1000000
using namespace std;
 
int main()
{
	//freopen("t.txt","r",stdin);
	string s;
	cin>>s;
	int n=s.length();
	int MAX=0;
	int d=0;
	for (int i=0;i<n;i++){
 
		for (int j=i;j<n;j++){
			d=0;
			for (int k=i;k<=j;k++){
				if (s[k]== 'A'||s[k]== 'C'||s[k]== 'G'||s[k]== 'T')
				{ 
				 d++; 
				 if (d== j-i+1) MAX =max(MAX,d);	
				}
			}
			
		 }	
		}
		
		cout<<MAX;
	}
 

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var s int64
	s = 0
	c := 0
	posmin := 1000000000
	negmax := -1000000000
	for i := 0; i < n; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a >= 0 {
			s += int64(a)
			if a < posmin {
				posmin = a
			}
		} else {
			s -= int64(a)
			if a > negmax {
				negmax = a
			}
			c++
		}
	}

	if c % 2 == 0 {
		fmt.Println(s)
	} else {
		if posmin > -negmax {
			fmt.Println(s + int64(negmax) * 2)
		} else {
			fmt.Println(s - int64(posmin) * 2)
		}
	}
}


Measured memory_bytes: 2176
A,B,C = map(int,input().split())
max_ABC = max(A,B,C)
dif = [max_ABC - A,max_ABC - B,max_ABC - C]
odd_dif = [i for i in dif if i % 2 == 1]
even_dif = [i for i in dif if i % 2 == 0] 

if len(even_dif) == 3:
	ans = sum(dif)/ 2
elif len(even_dif) == 2:
	ans = (sum(dif) + 3) / 2
else:
	ans = sum(dif) / 2
	
print(int(ans))

Measured memory_bytes: 3064
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <ll>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key){
 
    if((double)mid*mid > key) {
             return true;
     } else {
              return false;
     }
}

 int binary_search(double key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


bool isKaibun(string st){
    bool ans = true;
    int n = st.length();
    REP(i,n/2){
        if(st[i] != st[n-i-1]){
            return false;
        }
    }
    return true;
}

int toInt(char a){
    return a-'0';
}

void solve() {
    int N;
    cin >> N;
    int a,b;
    a = N/500;
    N-=a*500;
    b = N/5;
    cout << a*1000+b*5;
}
signed main() {
 
    solve();
 
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];
			var nums = new long[n];
			for (int i = 0; i < m; i++) {
				var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				nums[ab[0] - 1]++;
				nums[ab[1] - 1]++;
			}

			for (int i = 0; i < n; i++) {
				if (nums[i] % 2 != 0) {
					Console.WriteLine("NO");
					return;
				}
			}

			Console.WriteLine("YES");
		}
	}
}


Measured memory_bytes: 18016
M=int(input())
A=list(input())
flag=1
if M%2==1:
    print("No")
else:
    a=M//2
    for i in range(a):
        if A[i]!=A[i+a]:
            print("No")
            flag=0
            break
    if flag==1:
        print("Yes")

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S[3];
    REP(i, 3)
    {
        cin >> S[i];
    }
    REP(i, 3)
    {
        cout << (char)(S[i][0] - 32);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i = 1; i <= 3500;i++) {
		for (int j = 1; j <= 3500; j++) {
			if ((4 * i*j - N*i - N*j) > 0) {
				if ((N*i*j) % (4 * i*j - N*i - N*j) == 0) {
					cout << i << " " << j << " " << (N*i*j) / (4 * i*j - N*i - N*j) << endl;
					return 0;
				}
			}
		}
	}
	//cout << res << endl;
}

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

int main(){
  string W;
  cin >> W;
  bool exist_odd =false;
  for(char C='a';C<'z';C++){
    int count=0;
    for(int i=0;i<W.size();i++){
      if(W.at(i)==C){
        count++;
      }
    }
    if(count%2==1){
      exist_odd=true;
      break;
    }
  }
  if(exist_odd){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	ll d = extend_gcd(b,a%b,y,x);
	y -= a/b * x;
	return d;
}

ll mod(ll a,ll m){
	return (a%m+m)%m;
}

ll modinv(ll a,ll m){
	ll x,y;
	extend_gcd(a,m,x,y);
	return mod(x,m);
}

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

	vector<int> A,Ainv;
	REP(i,26){
		if(gcd(i+1,26)==1){
			A.push_back(i+1);
		}
	}
	int N;
	char S[280];
	cin.getline(S,sizeof(S));
	sscanf(S,"%d",&N);
	REP(n,N){
		cin.getline(S,sizeof(S));
		auto T = split_naive(string(S),' ');
		bool exist = false;
		int ansA,ansB;
		for(auto& alpha:A){
			for(int beta=0;beta<26;beta++){
				string THAT = "that";
				string THIS = "this";
				for(int i=0;i<4;i++){
					THAT[i] = (char)((alpha*(THAT[i]-'a')+beta)%26)+'a';
					THIS[i] = (char)((alpha*(THIS[i]-'a')+beta)%26)+'a';
				}
				for(auto& x:T){
					if(x==THAT || x==THIS){
						exist = true;
						break;
					}
				}
				if(exist){
					ansB = beta;
					break;
				}
			}
			if(exist){
				ansA = alpha;
				break;
			}
		}
		for(int i=0,ei=280;i<ei;i++){
			if(S[i]>='a' && S[i]<='z'){
				S[i] = (char)((modinv(ansA,26)*mod((S[i]-'a')-ansB,26))%26)+'a';
			}
		}
		out(S);
	}

	return 0;
}



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

int main() {
  int N = 5;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i);
  for (int i = 0; i < N; i++) {
    if (X.at(i) == 0) return cout << i + 1 << "\n", 0;
  }
}

Measured memory_bytes: 3628
import Foundation


    func solveGCD(_ a: Int, _ b: Int) -> Int {
        if a == 0 || b == 0 {
            fatalError("Fount zero value in the arguments")
        }
        var i = a, j = b
        
        if i < j {
            swap(&i, &j) // a < b だとwhile内で処理が a >= b のときより一度だけ多く行われて計算の無駄
         }
        
        while let l: Int = i%j, l != 0 {
            i = j
            j = l
        }
        
        return abs(j) //最小公倍数は常に正の整数とする
    }
    func solveGCD(numbers numbers_: Int...) -> Int {
        if numbers_.count < 2 {
            fatalError("No enough arguments")
        }
        var numbers = numbers_
        while numbers.count != 2 {
            numbers[1] = solveGCD(numbers[0], numbers[1])
            numbers.remove(at: 0)
        }
        return solveGCD(numbers[0], numbers[1])
    }
 
let inputLine: String = readLine()!
 
let k: Int = Int(inputLine)!

let a = 1
let b = 1
let c = 1
 
var ans = 0;

for a in 1...k {
  for b in 1...k {
    for c in 1...k {
      ans += solveGCD(numbers: a, b, c)
    }
  }
}


 
print(ans)


Measured memory_bytes: 13196
S = [input() for _ in range(5)]
T = []
U = []
for i in range(5):
  T.append(S[i])
  if int(T[i][-1]) == 0:
    U.append(9)
  else:
    U.append(int(T[i][-1]))
del T[U.index(min(U))]
import math
a = 0
for i in range(4):
  a += math.ceil(int(T[i])*0.1)*10
a += int(S[U.index(min(U))])
print(a)

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i-1]) {cout << "no"; return 0;}
	}
	cout << "yes";
	return 0;
}

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

int main(){
    string s;
    int ans;
    
    ans = 0;
    cin >> s;
    for ( int i = 0; i < s.size() ;i++ ) {
        if (s[i] == '+') {
            ans ++;
        } else {
            ans --;
        }
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<math.h>


#define MAX 20

int main()
{
	int n;
	double a, b, c, d, e, f, x1, x2, x3, y1, y2, y3, px, py, r;

	scanf("%d", &n);
	while (n)
	{
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

		a = (x2 - x1)*2;
		b = (y2 - y1)*2;
		c = x2*x2 - x1*x1 + y2*y2 - y1*y1;

		d = (x3 - x1)*2;
		e = (y3 - y1)*2;
		f = x3*x3 - x1*x1 + y3*y3 - y1*y1;

		px = (c*e - b*f) / (a*e - b*d);
		py = (a*f - c*d) / (a*e - b*d);
		r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));

		printf("%.3f %.3f %.3f\n", px,py,r);

		--n;
	}





	return 0;
}


Measured memory_bytes: 664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
 
    pair<int, int> rl[n];
    rep(i, n){
        int x, l;
        cin >> x >> l;
 
        rl[i] = make_pair(x+l, x-l);
    }
 
    sort(rl, rl+n);
 
    int pr = rl[0].first;
    int res = n;
    rep1(i, n){
      	int r = rl[i].first;
        int l = rl[i].second;
 
        if(l < pr) --res;
        else pr = r;
    }
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int INF = 1001001001;
int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N, 0);
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }
    int ans = INF;
    for (int i = 0; i < 1<<N; ++i) {
        int cost = 0;
        vector<int> D(M, 0);
        for (int j = 0; j < N; ++j) {
            if (i>>j&1) {
                cost += C[j];
                for (int k = 0; k < M; ++k) D[k] += A[j][k];
            }
        }
        bool T = true;
        for (int k = 0; k < M; ++k) if (D[k] < X) T = false;
        if (T) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    string str;
    std::cin >> a>>b>>c;
    
    if(b<c){
        if(a<b)
        str="Yes";
        else
        str="No";
    }
    else 
    str="No";
    std::cout << str << std::endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    string S;
    cin >> S;
    cout << ((S == "ABC") ? "ARC" : "ABC") << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
double x,ans;
int i,n;
char s[5];
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%lf%s",&x,s);
		if (s[0]=='J') ans+=x;
		else ans+=x*380000;
	}
	printf("%lf",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


int main() {
    ll X;
    cin >> X;
    int ma = 1;
    int p;
    for(int i=2; i<=X; i++){
        p = 2;
        while(1){
            if(pow(i, p) > X){
                break;
            }
            ma = max(ma, (int)pow(i, p));
            p++;
        }
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	generate_prime_list(2000);
	auto res = prime_list.filter!(a => a.to!string[$-1] == '7').array;
	foreach(i; 0..N) {
		if(i != N-1)
			"%d ".writef(res[i]);
		else
			res[i].writeln;
	}
	
	foreach(i; 0..55-5) {
		if(prime_list.canFind(res[i]+res[i+1]+res[i+2]+res[i+3]+res[i+4])){
			"bad".writeln;
		}
	}
	
}

int[] prime_list;

void generate_prime_list(int N) {
	prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
}

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

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

void run() {
	string s, t;
	cin >> s >> t;
	int n = szof(s), m = szof(t);
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	vector<vector<pair<int, int>>> p(n + 1, vector<pair<int, int>>(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (dp[i][j] == dp[i - 1][j]) {
				p[i][j] = {i - 1, j};
			} else {
				p[i][j] = {i, j - 1};
			}
			if (s[i - 1] == t[j - 1]) {
				int r = dp[i - 1][j - 1] + 1;
				if (r > dp[i][j]) {
					dp[i][j] = r;
					p[i][j] = {i - 1, j - 1};
				}
			}
		}
	}
	int i = n, j = m;
	string ans;
	while (i && j) {
		if (p[i][j] == make_pair(i - 1, j - 1)) {
			ans += s[i - 1];
		}
		tie(i, j) = p[i][j];
	}
	reverse(all(ans));
	cout << ans << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


Measured memory_bytes: 105984