akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N,K;

void solve()
{
	if(K==1) cout << 0 << endl;
	else{
		int most = N-K+1;
		cout << most-1 << endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K;
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	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
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	l, r := readInt(), readInt()

	ans := 2018
	r = min(r, l+2019)
	for i := l; i < r; i++ {
		for j := l + 1; j <= r; j++ {
			mod := ((i % 2019) * (j % 2019)) % 2019
			ans = min(ans, mod)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String sStr = s.next();
        String tStr = s.next();

        int tLength = tStr.length();
        int i = sStr.length() - tLength;
        boolean found = false;
        List<String> goods = new ArrayList<>();
        if (sStr.contains(tStr)) {
            found = true;
            goods.add(sStr);
        } else {
            for (i = sStr.length() - tLength; i >= 0; i--) {
                boolean good = true;
                for (int j = 0; j < tLength; j++) {
                    if (sStr.charAt(j + i) != '?' && sStr.charAt(j + i) != tStr.charAt(j)) {
                        good = false;
                        break;
                    }
                }
                if (good) {
                    found = true;
                    String tmp = sStr.substring(0, i) + tStr + sStr.substring(i + tLength, sStr.length());
                    String a = "";
                    for (int j = 0; j < sStr.length(); j++) {
                        if (tmp.charAt(j) == '?') {
                            a += 'a';
                        } else {
                            a += tmp.charAt(j);
                        }
                    }
                    goods.add(a);

                }
            }
        }
        if (found) {
            Collections.sort(goods);
            sStr = goods.get(0);

            System.out.println(sStr);
        } else {
            System.out.println("UNRESTORABLE");
        }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
vector<int>x,y;
int dpx[8000][16005],dpy[8000][16005];
int main(void){
    char s[8005];
    cin>>s;
    int sl=strlen(s);
    int r=0;
    x.push_back(0);
    y.push_back(0);
    for(int i=0;i<sl;i++){
        if(s[i]=='F'){
            if(r==0)x.back()++;
            else y.back()++;
        }else{
            if(r==0)x.push_back(0);
            else y.push_back(0);
            
            r=(r+1)%2;
        }
    }
    int a,b;
    cin>>a>>b;
    dpx[0][x[0]+8000]=1;
    for(int i=1;i<x.size();i++){
        for(int j=0;j<=16001;j++){
            if(dpx[i-1][j]){
                if(j-x[i]>=0)dpx[i][j-x[i]]=1;
                if(j+x[i]<=16001)dpx[i][j+x[i]]=1;
            }
        }
    }
    dpy[0][8000]=1;
    for(int i=1;i<=y.size();i++){
        for(int j=0;j<=16001;j++){
            if(dpy[i-1][j]){
                if(j-y[i-1]>=0)dpy[i][j-y[i-1]]=1;
                if(j+y[i-1]<=16001)dpy[i][j+y[i-1]]=1;
            }
        }
    }
    if(dpx[x.size()-1][a+8000]&&dpy[y.size()][b+8000])cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 498048
import heapq
qq = int(input())
ans = 0
hq1 = []
hq2 = []
x = 10 ** 10
c = 0
p, q = 0, 0
for _ in range(qq):
    que = list(map(int, input().split()))
    if que[0] == 1:
        a, b = que[1:]
        ans += b
        if c % 2 == 0:
            if a <= x:
                heapq.heappush(hq1, -a)
                p += a
            else:
                heapq.heappush(hq2, a)
                q += a
                y = heapq.heappop(hq2)
                q -= y
                heapq.heappush(hq1, -y)
                p += y
        else:
            if a <= x:
                heapq.heappush(hq1, -a)
                p += a
                y = -heapq.heappop(hq1)
                p -= y
                heapq.heappush(hq2, y)
                q += y
            else:
                heapq.heappush(hq2, a)
                q += a
        x = -hq1[0]
        c += 1
    else:
        print(x, q - len(hq2) * x + len(hq1) * x - p + ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int P;

int mpow(int n,int m){
	int ret=1;
	while(m){
		if(m&1)ret=ret*n%P;
		n=n*n%P;
		m>>=1;
	}
	return ret;
}

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

const int SIZE=200;
int fact[222];
int finv[222];

/*
x y t


t : mode  (0 or 1)
0 : y->y+1
1 : x->x+1
*/
int dp[222][222][2];

int solve(int N,int K){
	int ret=0;
	for(int X=1;X<=K+1&&N-X>=1;X++){
		int Y=N-X;

		memset(dp,0,sizeof(dp));
		for(int a=1;a<X;a++){
			if(a+Y<=K+1&&X-a+1<=K+1)dp[a][1][0]=a;
		}

		for(int x=1;x<=X;x++){
			for(int y=1;y<=Y;y++){
				if(y+1+(X-x)<=K+1&&y+1<=Y){
					add(dp[x][y+1][0],dp[x][y][0]);
					add(dp[x][y+1][0],dp[x][y][1]);
				}
				if(x+1+(Y-y)<=K+1){
					add(dp[x+1][y][1],dp[x][y][1]);
					add(dp[x+1][y][1],dp[x][y][0]);
				}
			}
		}

		int tmp=dp[X][Y][1];
		add(ret,tmp);
	}
	ret=ret*fact[N-1]%P;
	return ret;
}

signed main(){
	int N,K;
	cin>>N>>K>>P;

	fact[0]=1;
	for(int i=1;i<=SIZE;i++)fact[i]=fact[i-1]*i%P;
	finv[SIZE]=mpow(fact[SIZE],P-2);
	for(int i=SIZE-1;i>=0;i--)finv[i]=finv[i+1]*(i+1)%P;
	
	int ans=0;
	for(int i=0;i<=N;i++){
		int n=N-i;
		int k=K-i;
		if(n<3)continue;
		if((n-1)/2>k)continue;
		int tmp=solve(n,k);
		tmp=tmp*fact[N]%P*finv[n]%P;
		add(ans,tmp);
	}
	if(K==N-1)add(ans,fact[N]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4376
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

using namespace std;

typedef pair<int, int> P;

bool pc1(const P& firstElof, const P& secondElof)
{//first降順
	return firstElof.first > secondElof.first;
}
bool pc2(const P& firstElof, const P& secondElof)
{//first昇順
	return firstElof.first < secondElof.first;
}
bool pc3(const P& firstElof, const P& secondElof)
{//second降順
	return firstElof.second > secondElof.second;
}
bool pc4(const P& firstElof, const P& secondElof)
{//second昇順
	return firstElof.second < secondElof.second;
}


int main() {
	int n; mp::uint256_t k;
	cin >> n >> k;
	vector<mp::uint256_t>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int>bit(42);
	for (int i =0 ; i < n; i++) {
		for (int j = 41; j >= 0; j--) {
			if (a[i] & (1LL << j)) {
				bit[j]++;
			}
		}
	}
	//for (int i = 0; i <= 39; i++) {
		//cout << bit[i] << endl;
	//}
	mp::uint256_t tmp= 0;
	mp::uint256_t ans= 0;
	for (int i = 41; i >=0; i--) {
		mp::uint256_t temp = tmp;
		if (bit[i] < n-bit[i]) {
			tmp |= (1LL << i);
		}
		else {
			tmp |= (0LL << i);
		}
		if (tmp <= k) {
			ans = tmp;
		}
		else {
			tmp = temp;
		}
	}
	
	//cout << ans << endl;
	mp::uint256_t sum = 0;
	for (int i =0 ; i < n; i++) {
		sum += ans xor a[i];
	}
	cout << sum << endl;
}




Measured memory_bytes: 4992
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2005;
const int M=35;
const int INF=0x3f3f3f;
const ull sed=31;
const ll mod=1e9+7;
const double eps=1e-8;
typedef pair<int,int>P;
typedef pair<double,double>Pd;

int n,m;
char s[N][N];
int h[N][N],w[N][N];
int s1[N*N],s2[N*N];
int cnt1,cnt2;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
    {
        int cnt=0;
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='#')
            {
                if(!cnt) continue;
                s1[cnt1++]=cnt;
                cnt=0;
            }
            else
            {
                h[i][j]=cnt1;
                cnt++;
            }
        }
        if(!cnt) continue;
        s1[cnt1++]=cnt;
    }
    for(int i=1;i<=m;i++)
    {
        int cnt=0;
        for(int j=1;j<=n;j++)
        {
            if(s[j][i]=='#')
            {
                if(!cnt) continue;
                s2[cnt2++]=cnt;
                cnt=0;
            }
            else
            {
                w[j][i]=cnt2;
                cnt++;
            }
        }
        if(!cnt) continue;
        s2[cnt2++]=cnt;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            ans=max(ans,s1[h[i][j]]+s2[w[i][j]]-1);
        }
    }
    printf("%d\n",ans);
    return 0;
}



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

string str;

bool check(long long n) {
	return (n & (n - 1)) == 0;
}

void hawawa()
{
	for (int i = 0; i < 3; i++) {
		string str;
		cin >> str;
		cout << str[i];
	}
	cout << "\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=2005;
int f[N][N],g[N][N],jb[N],jj[N],zs[N],n,m,ans;
char ch[N][N];
inline int get(int pos,int x){
	if(zs[pos]<x)return pos;
	else return get(jb[pos],x);
}
inline int ggg(int pos,int x){
	if(zs[pos]<x)return pos;
	else return ggg(jj[pos],x);
}
int main(){
	n=read(); m=read();
	ans=max(n,m);
	for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			f[i][j]=ch[i][j]==ch[i][j+1];
			g[i][j]=f[i][j]==f[i-1][j]?g[i-1][j]+1:1;
		}
	}
	zs[0]=zs[m]=-1e9;
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			jb[j]=get(j-1,zs[j]=g[i][j]);
		}
		for(int j=m-1;j;j--){	
			jj[j]=ggg(j+1,zs[j]);
			//cout<<i<<" "<<j<<" "<<zs[j]<<" "<<jj[j]<<" "<<jj[j]-jb[j]<<endl;
			ans=max(ans,(jj[j]-jb[j])*zs[j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35712
#!/usr/bin/python3
 
cmdvar_N=int(input())
cmdvar_numlist=input()
cmdvar_numlist_splited=[int(s) for s in cmdvar_numlist.split()]
sum=0

if cmdvar_N != len(cmdvar_numlist_splited):
    print("error")
    exit(-1)

cmdvar_numlist_splited.sort(reverse=True)
#print(cmdvar_numlist_splited)
top_max_number=cmdvar_numlist_splited[0]

for List in cmdvar_numlist_splited:
    sum=int(sum)+int(List)

if int(top_max_number) < sum-int(top_max_number):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
int main() {
    int n, s;
    long long dp[20][1010] = {};
    dp[0][0] = 1;
    repq(i,1,100) repr(j,15,0) repq(k,0,1000) {
        if(k - i < 0) continue;
        if(j != 0) dp[j][k] += dp[j-1][k-i];
    }
    while(std::cin >> n >> s, n || s)
        std::cout << dp[n][s] + dp[n-1][s] << std::endl;
    return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int N,n,X,Y,W,H,x,y,cnt;
  cin >> N;
  while(N--){
    cnt=0;
    cin >> X >> Y >> W >> H;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      if( x >= X && x <= X+W && y>=Y && y<=Y+H){
	cnt++;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <set>
#include <string>

using namespace std;


int main(){
    int n;
    cin >> n;
    int cnt4=0;
    int cnt2=0;
    int cnt1=0;
    for (int i=0;i<n;i++){
        int a=0;
        cin >>a;
        if (a%4==0){
            cnt4++;
        }else if(a%2==0){
            cnt2++;
        }else{
            cnt1++;
        }
    }
    if ((cnt1 <= cnt4 + 1 &&
        ( cnt2 == 0 || (cnt2 >= 2 && cnt4-cnt1>=0)||
        (cnt2 == 1 && cnt4 > 0 && (cnt4+1-cnt1) + cnt2 >= 2)))){
        cout <<"Yes"  <<endl;
    }else{
        cout <<"No"  <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <iostream>

int main(void){

  int a, b;

  std::cin >> a >> b;

  if (a < b){
    std::cout << "a < b" << std::endl;
  } else if (a > b){
    std::cout << "a > b" << std::endl;
  } else {
    std::cout << "a == b" << std::endl;
  }
 return 0;
}

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

int main() {
  int N,n;
  int S=0, k=0;

  cin >> N;
  n = N;
  while ( n / 10 > 0 ) {
    n = n / 10;
    k++;
  }

  n = N;
  for( int i = k; 0 <= i; i-- ) {
    S = S + (n / int(pow(10, i)) % 10);
    n = n % (int(pow(10, i)));
  }

  if ( N % S == 0 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())

for w in range(1, 3501):
    for h in range(w, 3501):
        if (4/N - 1/w - 1/h) < 0:
            continue
        if (4*h*w - N*h - N*w) == 0:
            continue
        
        n = (N*h*w)/(4*h*w - N*h - N*w)
        if n == int(n) and n > 0:
            print(int(n), h, w)
            exit()

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

using namespace std;

string s;

int ans(char x) {
 	return x == 'o' ? 100 : 0;
}

int main() {
	cin >> s;
	cout << 700 + ans(s[0]) + ans(s[1]) + ans(s[2]) << "\n";
	fprintf(stderr, "Solved time := %d ms\n", clock());
 	return 0;
}

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

# define    ll            long long 
# define    vi             std::vector<int>
# define    int            long long 
# define    setbits(x)     __builtin_popcountll(x)
# define    zrobits(x)     __builtin_ctzll(x)
# define    fast           ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
# define    pb             push_back
# define    fn             for(int i=0;i<n;i++)
# define    rep(i,a,b)      for(ll i=a;i<b;i++)
# define    all(x)         x.begin(), x.end()
# define    allr(a)        a.rbegin(), a.rend()
# define    PI             3.14159265358979323846
# define    mod            1000000007
# define    endl           "\n"
# define    pii            pair<ll,ll>
# define    deb1(x)        cout<<#x<<" "<<x<<endl;
# define    deb2(x,y)      cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
# define    deb3(x,y,z)    cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
 
void getio();

void solve()
{
	int x,k,d;
	cin>> x >> k >> d;

	x=abs(x);
	int req = x/d;
	if(req>k) cout << x-d*k << endl;
	// else if(x==d) { if(k%2) cout << 0 << endl; else cout << x <<endl;}
	else { k-=req; if(k%2) cout << abs(x-d*req-d) << endl; else cout << x-d*req << endl;}
}



int32_t main()
{
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	getio();
    // int t; cin>>t; while(t--) 
    solve();
}

void getio()
{
    fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(){
    int a,b,r = 0;
    char op = 0;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if ( op == '?' ) break;
        switch (op){
            case '+': r = a + b; break;
            case '-': r = a - b; break;
            case '*': r = a * b; break;
            case '/': r = a / b; break;
        }
        printf("%d\n", r );
    }
    return 0;
}

Measured memory_bytes: 1776
n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000

for i in range(n+1):
    for j in range(n-i+1):
        if y - i * a - j * b == (n - i - j)* c:
            print(i, j, n - i - j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const long long INF=(long long)0x3f3f3f3f3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    //freopen("output.txt","w+",stdout);
    //freopen("input.txt","r+",stdin);
    vector<long long> sum(8);
    vector<vector<long long>> sign,ans(8);
    for(int i=-1;i<=1;i+=2)
        for(int j=-1;j<=1;j+=2)
            for(int k=-1;k<=1;k+=2)
                sign.push_back(vector<long long>{i,j,k});
    long long n,m,a,b,c,mx=0;
    cin>>n>>m;
    while(n--&&cin>>a>>b>>c)
        for(int i=0;i<8;i++)
            ans[i].push_back(sign[i][0]*a+sign[i][1]*b+sign[i][2]*c);
    for(int i=0;i<8;i++)
        sort(ans[i].rbegin(),ans[i].rend());
    for(int i=0;i<8;i++)
        for(int j=0;j<m;j++)
            sum[i]+=ans[i][j];
    for(int i=0;i<8;i++)
        mx=max(mx,sum[i]);
    cout<<mx;
    return 0;
}


Measured memory_bytes: 3728
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m, l = list(map(int, input().rstrip('\n').split()))
    wn = n
    wm = m
    inf = 10 ** 11
    wl = [[inf] * wn for _ in range(wn)]
    for i in range(wn):
        wl[i][i] = 0

    for i in range(wm):
        wa, wb, wc = list(map(int, input().rstrip('\n').split()))
        wl[wa - 1][wb - 1] = wc
        wl[wb - 1][wa - 1] = wc

    for i in range(wn):
        for j in range(wn):
            for k in range(wn):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    wn = n
    wm = m
    inf = 10 ** 11
    wl2 = [[inf] * wn for _ in range(wn)]
    for i in range(wn):
        wl2[i][i] = 0

    for i in range(wn):
        for j in range(wn):
            if wl[i][j] <= l:
                wl2[i][j] = 1

    for i in range(wn):
        for j in range(wn):
            for k in range(wn):
                wl2[j][k] = min(wl2[j][k], wl2[j][i] + wl2[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        print(wl2[s-1][t-1] - 1 if wl2[s-1][t-1] != inf else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 57308
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c = na()

if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b and b == c:
    print(-1)
    exit(0)
ans = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    ta = b // 2 + c // 2
    tb = a // 2 + c // 2
    tc = a // 2 + b // 2
    a, b, c = ta, tb, tc
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string n;
    cin>>n;
    ll s=0;
    for(ll i=0;i<n.length();i++)
    {
        s+=(int)n[i]-'0';
    }
    if(s%9==0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}



Measured memory_bytes: 3724
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//int powm(int x, int y, int m = 1e18) {
//	x = x % m; int res = 1; while (y)
//	{if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
//}
//int modi(int a, int m = MOD) {return powm(a, m - 2, m);}
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int n;
int a[23][23];
int dp[(1 << 22) + 10][23];
int vl = 0;
int fn(int mask, int wmn)
{	if (mask == vl)
	{	//cout << "ddd";
		return 1;
	}
	if (wmn > n)
		return 0;
	if (dp[mask][wmn] != -1)
		return dp[mask][wmn];
	int rs = 0;
	//fn(mask, wmn + 1);
	for (int i = 0; i < n; i++)
	{	//int tp = mask & (1 << i);
		//cout << i << endl;
		if ((mask & (1 << i)) == 0 && a[i][wmn])
		{	int tp = (mask | (1 << i));
			//cout << tp << endl;
			rs += fn(tp, wmn + 1) % MOD;
			rs %= MOD;
		}
	}
	//cout << rs << endl;
	rs %= MOD;
	dp[mask][wmn] = rs;
	return rs;
}
int32_t main()
{	pre();
	//case
	{	cin >> n;
		int x;
		memset(dp, -1, sizeof(dp));
		vl = powl(2, n) - 1;
		for (int i = 0; i < n; i++)
		{	for (int j = 0; j < n; j++)
				cin >> a[i][j];
		}

		cout << fn(0, 0);
	}
	return 0;
}

Measured memory_bytes: 753920
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll dp[10005][2][100];
string s;
ll n,d;
ll solve(ll pos,ll tight,ll mo)
{
    if(pos==n)
    {
        return (mo==0);
    }
    if(dp[pos][tight][mo]!=-1)
    return dp[pos][tight][mo];
    ll ret=0;
        ll up=(tight?(s[pos]-'0'):9);
        //cout<<up<<" ";
        for(ll di=0;di<=up;di++)
        {
            ret=(ret%mod+solve(pos+1,(tight&(di==up)),(mo+di)%d)%mod)%mod;
        }
    return dp[pos][tight][mo]=ret;
}
int main()
{
    cin>>s>>d;
    memset(dp,-1,sizeof dp);
    n=s.length();
    ll ans=solve(0,1,0);
    ans=(ans%mod-1+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 16768
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


 int k;
 cin>>k;

 cout<<( k / 2 ) * ( ( k + 1 ) / 2 )<<endl;



 return 0;
}

Measured memory_bytes: 3580
#include <iostream>

void call(int n) {
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            std::cout << " " << i;
            continue;
        } 
        do {
            if (x % 10 == 3) {
                std::cout << " " << i;
                break;
            }
            x /= 10;
        } while (x);
    }
    std::cout << std::endl;
}

int main() {
    int n;
    std::cin >> n;
    call(n);
}



Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

int n,k,ans;
char a;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a=='I') ++k;
		else --k;
		if(k>ans) ans=k;
	}
	cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    ll K;
    cin >> n >> K;

    vector< vector<int> > warp(60, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> warp[0][i];
        --warp[0][i];
    }

    for (int i = 1; i < 60; ++i) {
        for (int j = 0; j < n; j++) {
            warp[i][j] = warp[i - 1][warp[i - 1][j]];
        }
    }

    int ans = 0;
    for (int i = 0; i < 60; i++) {
        if (K >> i & 1) {
            ans = warp[i][ans];
        }
    }
    cout << ans + 1 << newl;
    return 0;
}

Measured memory_bytes: 50904
M,D=gets.split.map &:to_i

ans=0
1.upto(M){|m|
	1.upto(D){|d|
		d1 = d%10
		d10 = d/10
		ans += 1 if d1>=2 && d10>=2 && d1*d10==m
	}
}
p ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
vector<int>g[100000];
int dp[100000][2];
void dfs(int s, int p){
    int temp = 0;
    int mi = 1000000;
    int id = 0;
    for(int x:g[s]){
        if(x == p)continue;
        dfs(x,s);
        dp[s][0] += dp[x][1];
    }
    for(int x:g[s]){
        if(x == p)continue;
        dp[s][1] = max(dp[s][1], dp[s][0] + 1 - dp[x][1] + dp[x][0]);
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,-1);
    if(n%2==0 and dp[0][1] == n/2){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 6656
# -*- coding: utf-8 -*-


'''Snippets for prime.
Available functions:
- is_included: Determine whether it is a prime number.
- generate: Generate a list of prime numbers using sieve of Eratosthenes.
'''


class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance#2to3fixer-isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

        for i in range(2, int(sqrt(self.number)) + 1):
            if self.number % i == 0:
                return False

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def count_combinations(n, k, mod):
    ans = 1

    for i in range(1, k + 1):
        ans *= n - i + 1
        ans %= mod
        ans *= pow(i, mod - 2, mod)
        ans %= mod

    return ans


def main():
    from math import sqrt

    n, m = map(int, input().split())
    _prime = Prime(int(sqrt(m)) + 1)
    primes = _prime.generate()
    mod = 10 ** 9 + 7
    ans = 1

    for prime in primes:
        count = 0

        while m % prime == 0:
            count += 1
            m //= prime

        ans *= count_combinations(n + count - 1, count, mod)
        ans %= mod

    if m != 1:
        ans *= count_combinations(n, 1, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3508
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.Stream;
import java.util.stream.IntStream;
import java.lang.StringBuilder;

public class Main {
  public static void main(String[] args ){

    // 10^15以上は、打ち切りでよい
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    long K = sc.nextLong();

    int idx = 0;
    for(int i = 0; i < K - 1; i++) {
      if (S.length() <= i ) {
        idx = S.length() - 1;
        break;
      } else if (S.charAt(i) != '1') {
        // = (int)(S.charAt(i) - '0');
        idx = i;
        break;
      }

      idx++;
    }

    System.out.println(S.charAt(idx));
  }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  char c;
  string ans = "";
  for(int i = 0;i < a;i++){
    cin >> c;
    if(i == b-1){
      if(c == 'A'){
        ans += "a";
      }else if(c == 'B'){
        ans += "b";
      }else if(c == 'C'){
        ans += "c";
      }
    }else{
      ans += c;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int main(){
	int n;
	while(scanf("%d",&n),n){
		int m=0,v[4][2] = {{0,-1},{-1,0},{1,-1},{-1,-1}},map[257][257] = {{0}};
		for(int y=1;y<=n;y++)
			for(int x=1;x<=n;x++)scanf("%1d",&map[x][y]);

		for(int i=0;i<4;i++){
			int dp[257][257] = {{0}};
			for(int k=1;k<=n;k++)
				for(int j=1;j<=n;j++)m = std::max(m,dp[j][k] = map[j][k]?map[j][k] + dp[j+v[i][0]][k+v[i][1]]:0);
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int p[9][9];
 for(int i=0;i<9;i++){
   for(int j=0;j<9;j++){
	p[i][j]=0;
   }
 }
for(int i=1;i<=n;i++){
  if(i%10==0)continue;
int top;
int tail;
  if(i<10){top=i;
           tail=i;
          }
  else{ 
		tail=i%10;
    int x=i;
    while(x){
		top=x;
      x/=10;
    }
      }
  p[top-1][tail-1]++;
}
  long sum=0;
  for(int i=0;i<9;i++){
   for(int j=0;j<9;j++){
	sum+=p[i][j]*p[j][i];
   }
 }
  
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] a = new int[N];
        int cnt2 = 0;
        int cnt4 = 0;
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            if (a[i] % 4 == 0) {
                ++cnt4;
            } else if (a[i] % 2 == 0) {
                ++cnt2;
            }
        }
        if (cnt2 == 0 && cnt4 >= N - cnt4 - 1) {
            _out.println("Yes");
        } else if (cnt2 > 0 && cnt4 >= N - cnt4 - cnt2) {
            _out.println("Yes");
        } else {
            _out.println("No");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 50524
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;
  vector<set<int>> s(N);
  rep(i, N) {
    int gomi;
    cin >> gomi;
    rep(j, gomi) {
      int d;
      cin >> d;
      s.at(i).insert(d);
    }
  }
  bool ok = true;
  int count = 0;
  rep(i, M+1) {
    ok = true;
    rep(j, N) {
      if (!s.at(j).count(i)){
        ok = false;
      }
    }
    if (ok) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
from collections import deque

N,Q = list(map(int,input().split()))

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N
for i in range(Q):
    p,x = list(map(int,input().split()))
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.appendleft(u)


ans = ' '.join([str(x) for x in c])

print(ans)

Measured memory_bytes: 75812
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ka = []
ans = 0
for i in range(n):
    ka_memo = list(map(int, input().split()))
    ka.append(ka_memo[1:])

for i in range(1, m + 1):
    flg = True
    for j in range(n):
        if i not in ka[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
int N,R;
  cin>>N>>R;
  if(N>=10){cout<<R<<endl;}
  else{cout<<R+100*(10-N)<<endl;}
  
}

Measured memory_bytes: 256
N=int(input())

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

A=X.copy()
A.sort(reverse=True)

left=A[int(N/2)-1]
right=A[int(N/2)]

for i in range(N):
  if X[i]>=left:
    print(right)
  else:
    print(left)

Measured memory_bytes: 26180
n,l = map(int,input().split())
s = []

for i in range(n):
	s.append(input())

for i in range(n-1):
	for j in range(n-1,i,-1):
		if s[j-1] > s[j]:
			s[j],s[j-1] = s[j-1],s[j]

print(*s,sep='')

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

using namespace std;

string judge(string temp,string T,int count){
    if(count == temp.size()) return "No";
    else{
    if(temp==T) return "Yes";
    else return judge(temp.substr(1)+temp[0],T,count+1);
}
}

int main(){
string S,T,ans;
    cin >>S;
    cin >>T;
    ans=judge(S,T,0);
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
c = 0
ans = 0
for i in range(N-1):
    if H[i]>= H[i+1]:
        c += 1
    else:
        ans = max(c, ans)
        c = 0
ans = max(c,ans)
print(ans)

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

int64_t ans = 0;

namespace UnionTree {
template <typename T>
int root(vector<T> &u, int x) {
    if (x < 0 || u.size() <= x) return -1;
    if (u[x].parent == -1)
        return x;
    else
        return u[x].parent = root(u, u[x].parent);
}
template <typename T>
bool connect(vector<T> &u, int a, int b) {
    a = root(u, a), b = root(u, b);
    if (a == b || a < 0 || b < 0) return false;
    {
        ans -= u[a].size * u[b].size;
        u[a].size += u[b].size;
    }
    u[b].parent = a;
    return true;
}
};  // namespace UnionTree

struct Node {
    int parent;
    int size;
};

int main() {
#ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
#endif
    using namespace UnionTree;
    int64_t N, M;
    cin >> N >> M;
    vector<Node> tree(N, {-1, 1});
    vector<int> A(M), B(M);
    vector<int64_t> ans_buf(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }
    ans = N * (N - 1) / 2;
    for (int i = M - 1; i >= 0; i--) {
        ans_buf[i] = ans;
        connect(tree, A[i], B[i]);
    }
    for (int i = 0; i < M; i++) {
        cout << ans_buf[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>

int gcd(int a, int b){
	return (b>0?gcd(b,a%b):a);
}

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

int mod_inverse(int a, int m){
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int main(){
	int n;
	std::cin >> n;
	std::cin.ignore();
	for(;n--;){
		std::string s;
		std::getline(std::cin, s);
		for(int a=1;a<26;a++){
			if(gcd(a, 26) != 1)continue; //素ではない(1,26だと素なんですね)
			int b = 0;
			for(;b<26;b++){
				std::string new_s = s;
				int inverse_a = mod_inverse(a, 26);
				std::transform(new_s.begin(), new_s.end(), new_s.begin(),
											 [inverse_a, b](char c){
												 if(c < 'a' || c > 'z')return c;
												 int x = c - 'a';
												 int new_x = inverse_a * (x>b?x-b:x-b+26) % 26;
												 return static_cast<char>(new_x + 'a');
											 });
				if(new_s.find("this") != std::string::npos ||
					 new_s.find("that") != std::string::npos){
					std::cout << new_s << std::endl;
					break;
				}
			}
			if(b < 26){break;}
		}
	}
}

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

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

int main(void)
{
    ll n;
    cin >> n;
    vector<ll> d1(n), d2(n);
    bool ok = false;
    rep(i,n){
        cin >> d1[i] >> d2[i];
    }
    rep(i,n-2){
        if(d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2]) ok=true;
    }
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++)
  {
    cin >> a.at(i);
  }
  
  vector<vector<bool>> save(H, vector<bool>(W, true));

  for (int i = 0; i < H; i++)
  {
    bool ok = false;
    for (int j = 0; j < W; j++)
    {
      if (a.at(i).at(j) == '#')
      {
        ok = true;
        break;
      }
    }
    if (!ok)
    {
      for (int k = 0; k < W; k++)
      {
        save.at(i).at(k) = false;
      }
    }
  }

  for (int j = 0; j < W; j++)
  {
    bool ok = false;
    for (int i = 0; i < H; i++)
    {
      if (a.at(i).at(j) == '#')
      {
        ok = true;
        break;
      }
    }
    if (!ok)
    {
      for (int k = 0; k < H; k++)
      {
        save.at(k).at(j) = false;
      }
    }
  }
  
  for (int i = 0; i < H; i++)
  {
    bool ok = false;
    for (int j = 0; j < W; j++)
    {
      if (save.at(i).at(j))
      {
        cout << a.at(i).at(j);
        ok = true;
      }
    }
    if (ok) cout << endl;
  }
}

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

int main() {
	string S; cin >> S;
	int len = S.size();
	int K = len;

	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] != S[i + 1]) {
			K = min(K, max(i + 1, len - (i + 1)));
		}
	}
	cout << K << endl;

	return 0;
}

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

typedef long long ll;

const int N = 100010;
const int mod = 1e9 + 7;

char s[N];
int d, n, a[N];
int f[10010][110];

int dfs(int cnt, int limit, int lead, int s) {
	if(!cnt) return !s && !lead;
	if(~f[cnt][s] && !limit && !lead) return f[cnt][s];
	int sum = 0, ed = limit ? a[cnt] : 9;
	for(int i = 0; i <= ed; ++i) {
		(sum += dfs(cnt - 1, limit && (i == ed), lead && (!i), (s + i) % d)) %= mod;
	}
	if(!limit && !lead) return f[cnt][s] = sum;
	return sum;
}

int main() {
	memset(f, -1, sizeof(f));
	scanf("%s%d", s + 1, &d);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i) a[i] = s[i] - '0';
	reverse(a + 1, a + n + 1);
	printf("%lld\n", dfs(n, 1, 1, 0));
}

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

using namespace std;

string in;
vector<string> V;

string change(string a, int j){
  for(int i = 0; i < a.length(); i++) 
    if(a[i] == 'X') a[i] = j+'0';
  return a;
}

string p(string a, string b){
  if(a.length() < b.length()) swap(a,b);
  int diff = a.length() - b.length();
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  for(int i = 0; i < diff; i++) b+="0";
  int status = 0;
  for(int i = 0; i < a.length(); i++){
    if(status){
      a[i]++;
      status = 0;
    }
    if(a[i]+(b[i]-'0') > '9'){
      a[i] += (b[i]-'0')-10;
      status = 1;
    }
    else a[i] += b[i]-'0';
  }
  if(status) a+="1";
  reverse(a.begin(),a.end());
  return a;
}

int check(string a,string b,string c,int num){
  string ans = p(a,b);
  //cout << ans << " " << c << endl;
  if(ans == c){
    cout << num << endl;
    return 1;
  }
  return 0;
}


int where_X(){
  for(int i = 0; i < V.size(); i++){
    string s = V[i];
    if(s[0] == 'X' && s.length() > 1) return 1;
  }
  return 0;
}
void solve(){
  string s[3];
  int start = where_X();
  for(int i = start; i < 10; i++){
    for(int j = 0; j < 3; j++) s[j] = change(V[j],i); 
    if(check(s[0],s[1],s[2],i)) break;
    if(i == 9) cout << "NA" << endl;
  }
}

int main(){
  while(cin >> in){
    V.clear();
    in += '+';
    string out = "";
    for(int i = 0; i < in.length(); i++){
      if(in[i] == '+' || in[i] == '='){
	V.push_back(out);
	out = "";
      }else out += in[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)

bool overlaps(ii a, ii b) {
    int x1 = a.first;
    int x2 = b.first;
    int w1 = a.second - a.first;
    int w2 = b.second - b.first;
    if (x2 < x1 + w1 && x1 < x2 + w2) {
        return true;
    }
    return false;
}

vi readList(int n) {
    vi a(n);
    for (int i = 0 ; i < n ; i++) {
        cin >> a[i];
    }
    return a;
}

void printList(vi a) {
    for (int i = 0 ; i < a.size() ; i++) {
        cout << a[i];
        if (i < a.size() - 1) {
            cout << " ";
        }
    }
    cout << endl;
}

bool comp(ll a, ll b) {
    if (a < b) {
        return false;
    }
    return true;
}

void solve() {
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    
}

void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        int ans = 0;
        for (int i = a; i <= b; i ++) {
                string s = to_string(i);
                string t = s;
                reverse(s.begin(), s.end());
                if (s == t) {
                        ans ++;
                }
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 384