akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int t[8]={0,1,2,3,4,5,6,7};

int main(){
    int n;cin>>n;
    cout<<((n%2==0)?(n-2)/2:(n-1)/2)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int n,x,i,j,k,c;
while(1){
scanf("%d %d",&n,&x);
if(n==0&&x==0)break;
c=0;
for(i=1;i<=n;i++){
   for(j=i+1;j<=n;j++){
      for(k=j+1;k<=n;k++){
         if(i+j+k==x)c++;
      }
   }
}
printf("%d\n",c);
}
return 0;
}

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

int main () 
{ ios::sync_with_stdio(false);
cin.tie(0);
// cout.tie(0);
int t=1;
// cin>>t;
while(t--){
  ll k;
  cin>>k;
  ll n=7;
   if(!(k&1)) {cout<<-1; return 0;}
   ll cnt=1;
  while(1){
    if(n%k==0){
		cout<<cnt;
		return 0;
	}
	if(cnt>k){
		cout<<-1;
		return 0;
	}
	n=((n%k)*10+7)%k;
	++cnt;
  }
}
	return 0; 
	} 

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;

signed main(){
	int sum=0,num=1;
	cin>>n;
	for(int i=1;i<=1000000;i++){
		sum+=7*num;
		num*=10;
		sum%=n;
		num%=n;
		if(sum%n==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define PI 3.141592653589793

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::cout.precision(10);

    double a, b, x;
    std::cin >> a >> b >> x;
    if (x <= a * a * b / 2) {
        double otherSL = (2 * x) / (a * b);
        std::cout << (atan(b / otherSL) * 180 / PI) << '\n';
    } else {
        double otherArea = a * a * b - x;
        double otherSL = (2 * otherArea) / (a * a);
        std::cout << (atan(otherSL / a) * 180 / PI) << '\n';
    }
    return 0;
}

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

int N, M, X;

int main () {
  cin >> N >> M >> X;
  vector<int> A(M);
  rep(i,M) cin >> A[i];

  int a = 0, b = 0;
  rep(i,M) {
    if(A[i] > X) {
      a++;
    } else {
      b++;
    }
  }
  cout << min(a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
m = [int(i) for i in input().split()]
for i in range(len(m)):
    if(m[0]>m[1]):
        m[0],m[1] = m[1],m[0]
    elif(m[0]>m[2]):
        m[0],m[2] = m[2],m[0]
    elif(m[1]>m[2]):
        m[1],m[2] = m[2],m[1]
print("{0} {1} {2}".format(m[0],m[1],m[2]))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef unsigned long long u64;
const u32 P=998244353;
int cnt;
u32 f[301][301], g[301][301], h[301][301];
char s[305];
std::vector<int> a;
void ps() {
	for(int i=0; i<=cnt; ++i) {
		for(int j=0; j<=cnt; ++j) {
			g[i][j]=h[i][j]=f[i][j];
			if(i>0) g[i][j]=(g[i-1][j]+g[i][j])%P;
			if(i>0 && j>0) h[i][j]=(h[i-1][j-1]+h[i][j])%P;
		}
	}
}
int main() {
	int k;
	u32 ans=0;
	scanf("%s%d", s, &k);
	for(int i=0; s[i]; ++i) {
		if(s[i]=='0') {
			a.push_back(cnt);
			cnt=0;
		} else
			++cnt;
	}
	a.push_back(cnt);
	cnt=std::count(s, s+strlen(s), '1');
	f[0][0]=1;
	ps();
	for(int n: a) {
		for(int i=0; i<=cnt; ++i) {
			for(int j=0; j<=cnt; ++j)
				f[i][j]=(g[std::min(cnt, i+n)][j]+P-g[i][j]+h[i][j])%P;
		}
		ps();
	}
	for(int i=0; i<=cnt&&i<=k; ++i) ans=(ans+f[0][i])%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 4896
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b, c; 
    cin >> a >> b >> c;
    map<int, int> m;
    m[a]++; m[b]++; m[c]++;

    if (m[5] == 2 && m[7]==1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      Dice dice3a = new Dice(br.readLine().split(" "));
      Dice dice3b = new Dice(br.readLine().split(" "));
      String result = "No";

      dice3b.setFrontPosition(dice3a.getFrontSide());

      for(int i=0; i<4; i++)  {
        for(int j=0; j<4; j++) {
          if( dice3a.equals(dice3b) ) {
            result = "Yes";
            break;
          }
          else dice3b.rotate("W");
        }
        if( dice3a.equals(dice3b)) break;
        dice3b.rotate("N");
      }
      System.out.println(result);
    }
  }
}

class Dice {
  private int[] side;

  public Dice( int[] ia ) {
    side = Arrays.copyOf(ia, ia.length);
  }
  public Dice( String[] s ) {
    side = new int[s.length];
    for ( int i=0; i < 6; i++)
      side[i] = Integer.parseInt(s[i]);
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof Dice)) return false;
    Dice r = (Dice) o;

    if(
      (side[0] == r.side[0]) &&
      (side[1] == r.side[1]) &&
      (side[2] == r.side[2]) &&
      (side[3] == r.side[3]) &&
      (side[4] == r.side[4]) &&
      (side[5] == r.side[5])
      ) return true;
    else return false;
  }

  public int getUpperSide() {
    return side[0];
  }
  public int getLowerSide() {
    return side[5];
  }
  public int getFrontSide() {
    return side[1];
  }
  public int getBackSide() {
    return side[4];
  }
  public int getRightSide() {
    return side[2];
  }
  public int getLeftSide() {
    return side[3];
  }

  public void setFrontPosition(int n) {
    for(int i=0; i < 3; i++){
      if(getUpperSide() != n) rotate("N");
    }
    for(int i=0; i < 3; i++){
      if(getUpperSide() != n) rotate("W");
    }
    rotate("S");
  }

  public int doRotate(String s) {
    for ( int i=0; i < s.length(); i++ ) {
      rotate(s.substring(i, i+1));
    }
    return side[0];
  }

  public void rotate(String o) {
    switch(o) {
      case "N" :
        rotateN();
        break;
      case "S" :
        rotateS();
        break;
      case "W" :
        rotateW();
        break;
      case "E":
        rotateE();
        break;
      default :
    }
  }

  private void rotateN() {
    int tmp = side[0];
    side[0] = side[1]; side[1] = side[5]; side[5] = side[4];
    side[4] = tmp;
  }
  private void rotateS() {
    int tmp = side[0];
    side[0] = side[4]; side[4] = side[5]; side[5] = side[1];
    side[1] = tmp;
  }
  private void rotateW() {
    int tmp = side[0];
    side[0] = side[2]; side[2] = side[5]; side[5] = side[3];
    side[3] = tmp;
  }
  private void rotateE() {
    int tmp = side[0];
    side[0] = side[3]; side[3] = side[5]; side[5] = side[2];
    side[2] = tmp;
  }
}


Measured memory_bytes: 24528
import sys


def resolve():
    N_BILLS, YEN_TOTAL = [int(x) for x in sys.stdin.readline().split()]

    is_answer_found = False
    for i_ten in range(N_BILLS + 1):
        for i_five in range(N_BILLS + 1 - i_ten):
            i_one = N_BILLS - i_ten - i_five
            if i_ten * 10000 + i_five * 5000 + i_one * 1000 == YEN_TOTAL:
                is_answer_found = True
                print("{} {} {}".format(i_ten, i_five, i_one))
                break
        if is_answer_found:
            break
    if not is_answer_found:
        print("-1 -1 -1")


if __name__ == "__main__":
    resolve()

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)


Measured memory_bytes: 6320
# -*- coding:utf-8 -*-
def check_para(x1,y1,x2,y2,x3,y3,x4,y4):
    if x1 == x2 and x4 == x3:
        print('YES')
        return 0
    elif x1 == x2 or x3 == x4:
        print('NO')
        return 0
    k1 = (y2-y1)/(x2-x1)
    k2 = (y4-y3)/(x4-x3)
    if abs(k1-k2) < 1e-10:
        print('YES')
    else:
        print('NO')

n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    check_para(x1,y1,x2,y2,x3,y3,x4,y4)

Measured memory_bytes: 7696
#include<bits/stdc++.h>
using namespace std;
void f()
{
    long long int x,k,d;
    cin>>x>>k>>d;
    vector<long long int >v;
     cin>>x>>k>>d;
    x=abs(x); 
        long long int y=x/d;
      
        long long int z=k-y;
        if(y>=k)
        {
            cout<<abs(x-k*d);
        }
        else
        {
            long long int x1=x-(y*d);
            long long int x2=abs(x-(y+1)*d);
            if(x1<=x2)
            {
                if(z%2==1)
                {
                    cout<<x2;
                }
                else
                {
                    cout<<x1;
                }
            }
            else
            {
                if(z%2==1)
                {
                    cout<<x2;
                }
                else
                {
                    cout<<x1;
                }
            }
        }
}
int main()
{
     f();
}


Measured memory_bytes: 3628
// AOJ 2233 Carrot Tour
// 2018.2.1 bal4u

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-8
#define PI 3.1415926535897932384626433832795

int x[21], y[21];
double d[21][21];
double dp[2][21][21];
int to[21][21][21], hi[21][21];
char f[2][21][21];

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

double angle(int k, int i, int j)
{
	double a, b, c;
	
	a = hypot(x[k]-x[i], y[k]-y[i]);
	b = hypot(x[i]-x[j], y[i]-y[j]);
	c = (double)(x[k]-x[i])*(x[i]-x[j]) + (double)(y[k]-y[i])*(y[i]-y[j]);
	return acos(c/(a*b));
}

int main()
{
	int n, i, j, k, m, k1, k2, ok, ans;
	double r, a, t;
	char buf[30];

	n = in();
	fgets(buf, 30, stdin), sscanf(buf, "%lf%lf", &r, &a);
	a *= PI/180;
	for (i = 0; i < n; i++) x[i] = in(), y[i] = in();

	for (i = 0; i < n; i++) for (j = i+1; j < n; j++)
		d[i][j] = d[j][i] = hypot(x[i]-x[j], y[i]-y[j]);

	for (i = 0; i < n; i++) for (j = 0; j < n; j++) if (j != i) {
		for (k = 0; k < n; k++) if (k != i) {
			if (angle(k, i, j) < a + EPS) to[i][j][hi[i][j]++] = k;
		}
	}

	ok = 0;
	for (j = 1; j < n; j++) if (d[0][j] < r + EPS) {
		ok = 1, dp[0][j][0] = d[0][j], f[0][j][0] = 1;
	}

	ans = 0;
	for (k1 = 0, k2 = 1; ok; k1 = k2, k2 = !k2) {
		ans++;
		ok = 0;
		memset(f[k2], 0, sizeof(f[k2]));
		for (i = 0; i < n; i++) for (j = 0; j < n; j++) {
			if (i == j || !f[k1][i][j]) continue;
			for (m = 0; m < hi[i][j]; m++) {
				k = to[i][j][m];
				if ((t = dp[k1][i][j] + d[i][k]) < r + EPS) {
					if (!f[k2][k][i] || dp[k2][k][i] > t) {
						dp[k2][k][i] = t, f[k2][k][i] = 1, ok = 1;
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2148
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int A[100000];
int ind[100000];
long long res[100000];
int main(){
  int i;
  wmem = memarr;
  int mi = 1073709056;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    ind[i] = i;
  }
  sortA_L(N, A, ind);
  for(i=(N)-1;i>=(0);i--){
    chmin(mi, ind[i]);
    if(i){
      res[mi] += (long long) (A[i] - A[i-1]) * (N - i);
    }
    else{
      res[mi] += (long long) (A[i]) * (N - i);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=(0);KL2GvlyY<(N);KL2GvlyY++){
      wt_L(res[KL2GvlyY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// int N, A[1d5];
// int ind[1d5];
// ll res[1d5];
// {
//   int mi = int_inf;
//   rd(N,A(N));
//   rep(i,N) ind[i] = i;
//   sortA(N, A, ind);
//   rrep(i,N){
//     mi <?= ind[i];
//     res[mi] += (ll) (if[i, A[i] - A[i-1], A[i]]) * (N - i);
//   }
//   wtLn(res(N));
// }


Measured memory_bytes: 5120
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  string s;
  cin >> s;

  int cnt = 0, ans = 0;
  REP(i, s.size()){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      cnt++;
    }
    else cnt = 0;
    ans = max(ans, cnt);
  }

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


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

mod0 = X.count("1") + 1
mod1 = X.count("1") - 1

full0 = 0
full1 = 0
for i in range(N):
    if X[i] == "1":
        full0 = (full0 + pow(2, N - i - 1, mod0)) % mod0
        if mod1 > 0:
            full1 = (full1 + pow(2, N - i - 1, mod1)) % mod1

ans = [0] * N
for i in range(N):
    if X[i] == "0":
        cur = (full0 + pow(2, N - i - 1, mod0)) % mod0
        res = 1
    else:
        if mod1 > 0:
            cur = (full1 - pow(2, N - i - 1, mod1)) % mod1
            res = 1
        else:
            cur = 0
            res = 0

    while cur > 0:
        cur %= bin(cur).count("1")
        res += 1
    ans[i] = res

print(*ans, sep="\n")


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


int main()
{

    int n;

    cin >> n;

    int a;
    int prev = 1000000001;
    int res = 0;
    int currStep = 0;
    while(n--)
    {
        cin >> a;
        if(a <= prev)
        {
            currStep++;
            prev = a;
            res = max(currStep, res);
        }else
        {
            res = max(currStep, res);
            currStep = 1;
            prev = a;
        }
    }
    res--;
    cout << res << endl;

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

  int a,b,c;
  cin>>a>>b>>c;
  int z,d = a-b;
  if(c>d)
    z= c-d;
  else
    z = 0;
  cout<<z<<endl;
	return 0;
}

Measured memory_bytes: 256
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np

N = int(input())
b = np.array(input().split(), dtype=int)

data = np.ones(2*N, dtype=int)
col = np.arange(2 * N) // 2
row = np.zeros(2 * N, dtype=int)
row[0] = N - 1
row[1:] = col[:-1]

A = csr_matrix((data, (row, col)), shape=(N, N))

ans = (spsolve(A, b) * 2).astype(int)
print(*ans)


Measured memory_bytes: 64500
#include<stdio.h>
#include<string.h>
void qz(long long a,long long b,long long*bs,long long*ys)
{
	long long r,t,j;
	j=a*b;
	if(a<b)
	{
		t=a;
		a=b;
		b=t;
	}
	while(b!=0)
	{
		r=a%b;
		a=b;
		b=r;
	}
	*bs=j/a;
	*ys=a; 
}
int main()
{
	char s[100001],t[100001];
	int i;
	long long bs,ys,n,m;
	scanf("%ld",&n);
	scanf("%ld",&m);
	getchar();
	gets(s);
	gets(t);
	if(s[0]!=t[0])
	{
		printf("-1\n");
		return 0;
	}
	qz(n,m,&bs,&ys);
	if(n>m&&n%m==0)
	{
		for(i=1;i<m;i++)
		{
			if(s[m/n*i]!=t[i])
			printf("-1\n");
			return 0;
		}
	}
	else if(m>n&&m%n==0)
	{
		for(i=1;i<m;i++)
		{
			if(t[m/n*i]!=s[i])
			printf("-1\n");
			return 0;
		}
	}
	for(i=1;i<=ys;i++)
	{
		if(s[bs/m*i]!=t[bs/n*i])
		{
			printf("-1\n");
			return 0;
		}
	}
		printf("%ld",bs);
	return 0;
	 
} 

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

int main() {
	int n;
	cin >> n;
	double ave = 0;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ave += x;
		a.push_back(x);
	}
	ave /= n;

	double minimum = 99999999.0;
	int count = -1;
	for (int i = 0; i < n; i++) {
		if (minimum > abs(a[i] - ave)) count = i;
		minimum = min(minimum, abs(a[i] - ave));
	}

	cout << count << endl;

	return 0;
}

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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	
	string s;
	cin >> s;
	string y="",m="",d="";
	for(int i=0;i<4;i++){
		y += s[i];
	}
	for(int i=5;i<7;i++){
		m += s[i];
	}
	for(int i=8;i<10;i++){
		d += s[i];
	}
	string yCek="2019",mCek="04",dCek="30";
	
	if(y<=yCek){
		if(m<=mCek){
			if(d<=dCek){
				cout << "Heisei" << endl;
			} else {
				cout << "TBD" << endl;
			}
		} else {
			cout << "TBD" << endl;
		}
	} else {
		cout << "TBD" << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

int main() {
    ll N, K;
    cin >> N >> K;
    ll b;
    ll ans = 0;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    for (b = K + 1; b <= N; ++b) {
        ll cnt = b - K;
        ans += (N + 1) / b * cnt;
        ans += max((N + 1) % b - K, 0ll);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
(function(input) {
  'use strict';
  const lines = input.split("\n")
  lines.forEach(line => {
    if (!line) return
    const NM = line.split(' ')
    const N = NM[0]
    const M = NM[1]

    const MaxD = Math.floor(M/N)

    let i = MaxD

    while(i){
      if (M%i === 0) {
        console.log(i)
        break;
      }
      i--
    }
  })
})(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 9420
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

A, P = rl()

print((A*3+P) // 2)


Measured memory_bytes: 68360
// atcoder/abc144/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    bool f = false;
    for (int i = 1; i <= 9; ++i) {
      for (int j = 1; j <= 9; ++j) {
        f = f || (i * j == n);
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> a(N);
  rep (i, N) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  long foo = 0;
  long bar = 0;

  rep (i, N) if (i % 2) foo += a[i]; else bar += a[i];

  cout << abs(foo - bar) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) {
      return console.log(n, 0, 0)
    } else if (remain < 0 && i === n) {
      break
    }
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) {
        return console.log(i, j, sen)
      } else if (result < 1000) {
        break
      }
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))


Measured memory_bytes: 7500
#include<stdio.h>

int main(){
    int n, t, c, f, min=1001;
    scanf("%d %d", &n, &t);
    while(n--){
        scanf("%d %d", &c, &f);
        if(f<=t){
            if(c<=min){
                min=c;
            }
        }
    }
    if(min==1001){
        printf("TLE\n");
    }
    else{
        printf("%d\n", min);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
  int i;
  int n,fmax=0,a[3010];
  scanf("%d",&n );
  for(i=0;i<n;i++){
  scanf("%d",&a[i]);
  fmax+=a[i]-1;
}

  printf("%d\n",fmax );
}


Measured memory_bytes: 128
#include <iostream>
#define int long long
using namespace std;

int N,k;

int ceil(int a, int b) {
  return (a + b - 1) / b;
}

#if 0
signed main(void) {
  cin >> N >> k;

  int x = 0;
  N--;
  while (true) {
    int i = ceil(x + 1, k - 1);
    int z = i * k - 1 - i;

    int c = ceil(z - x + 1, i);
    if (c >= N) {
      cout << x + N * i << endl;
      break;
    }
    x = c * i + x;
    N -= c;
  }
  return 0;
}
 
# else 
signed main(void) {
  cin >> N >> k;
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    int add = ans / (k - 1) + 1;
    ans += add;
  }
  cout << ans << endl;
  return 0;
}
#endif


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vector<i64> a(n);
    map<pii, i64> cnt;
    forn(i, n) {
        double x;
        cin >> x;
        a[i] = x * 1000000000 + 0.5;
        pii p = mp(-9, -9);
        while (a[i] % 2 == 0) a[i] /= 2, ++p.fi;
        while (a[i] % 5 == 0) a[i] /= 5, ++p.se;
        ++cnt[p];
    }

    vector<pii> ps;
    vi64 cs;
    for (auto w: cnt) ps.pb(w.fi), cs.pb(w.se);
    
    i64 ans = 0;
    forn(i, ps.size()) {
        pii p = ps[i];
        if (p.fi >= 0 && p.se >= 0) ans += cs[i] * (cs[i] - 1) / 2;
        forn(j, i) if (p.fi + ps[j].fi >= 0 && p.se + ps[j].se >= 0) ans += cs[i] * cs[j];
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4776
#include <cstdio>
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
using namespace std;
char s[1000010], t[1000010];
int n, now, tag, l, r;
int q[1000010];
int ans;
int main(){
	scanf("%d%s%s", &n, s + 1, t + 1);
	now = n; tag = 0; l = 1, r = 0;
	FORD(i, n, 1){
		while ((now && s[now] != t[i]) || now > i) now--;
		if (!now) return puts("-1"), 0;
		if (q[r] + tag != now){
			tag--;
			q[++r] = now - tag;
			while (l <= r && q[l] + tag >= i) l++;
			if (r - l >= ans) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			int num = Integer.parseInt(reader.readLine());
			String[] numData = reader.readLine().split(" ");
			outputMinMaxTotal(numData);

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	private static void outputMinMaxTotal(String[] numData) {

		int min = 1000000;
		int max = -1000000;
		long total = 0;
		for(int i=0;i<numData.length;i++){
			int target = Integer.parseInt(numData[i]);
			if(min > target){
				min = target;
			}
			if(max < target){
				max = target;
			}
			total = total + target;
		}
		System.out.println(min + " " + max + " " + total);

	}

}

Measured memory_bytes: 28360
import java.util.*;
import java.io.* ;
/*
NOTES:
-more than 10 digits (10^10), use long
-prefix sum of 1's and -1's to control flow of highlighting a region
-log(a)/log(b) = log base b of a
-create a position array if trying to see if elements show up next to each other sequentially
 i.e. elements 1,2,3 are within 3 spots of each other in an array
      arr[scannedInt - 1] = i; (position of i at p[i] in original)
- use a freq array when counting instances of an element occurring
- increment the counter first before simulating anything turn-based (two player game)

 */

public class Main {
    static long mod = (long)(Math.pow(10, 9) + 7);
    public static String alpha = "zabcdefghijklmnopqrstuvwxy";
    public static void main(String[] args) throws IOException{
        Scanner scan = new Scanner(System.in);
        long t = 1;
        while (t-- > 0) {
            for(int i = 0; i<5; i++){
                if(scan.nextInt() == 0){
                    System.out.println(i+1);
                    break;
                }
            }
        }
        scan.close();

    }

    static ArrayList factors(int n ){
        ArrayList<Integer> facts = new ArrayList<>();
        for(int i = 1; i<=(int)Math.sqrt(n); i++){
            if(n%i == 0){
                if( i == Math.sqrt(n)) facts.add(i);
                else{
                    facts.add(i);
                    facts.add(n/i);
                }
            }
        }
        Collections.sort(facts);
        return facts;
    }

    static boolean isPrime (int n){
        if(factors(n).size() ==2) return true;
        else return false;
    }





    static long GCD(long a, long b) {
        // Everything divides 0
        if (a == 0) return b;
        if (b == 0) return a;

        // base case
        if (a == b) return a;

        // a is greater
        if (a > b) return GCD(a-b, b);
        return GCD(a, b-a);
    }
    static long LCM(long a, long b){
        return (a*b)/(GCD(a,b));
    }
    static String rev(String s){
        char[] arr = s.toCharArray();
        for(int i = 0; i<(s.length()+1)/2; i++){
            char temp = arr[i];
            arr[i] = arr[s.length()-i-1];
            arr[s.length()-i-1] = temp;
        }
        String fin = new String(arr);
        return fin;
    }
    static long pow(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a;
        else {
            long R = pow(a,N/2);
            if (N % 2 == 0) {
                return R*R;
            }
            else {
                return R*R*a;
            }
        }
    }

    static long powMod(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a % mod;
        else {
            long R = powMod(a,N/2) % mod;
            R *= R;
            R %= mod;
            if (N % 2 == 1) {
                R *= a;
                R %= mod;
            }
            return R % mod;
        }
    }

}

Measured memory_bytes: 35644
import scala.io.StdIn._
object Main extends App {
  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val h = readLine.split(" ").map(_.toInt)

  val dp = Array.fill(n)(Int.MaxValue)
  dp(0) = 0
  for (i <- 0 until n; j <- 1 to k if (i + j) < n) {
    dp(i + j) = math.min(dp(i + j), dp(i) + math.abs(h(i) - h(i + j)))
  }
  println(dp(n - 1))
}


Measured memory_bytes: 48248
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A,B,K= map(int, sys.stdin.readline().split())
    l = []
    for i in range(1,min(A,B)+1):
        if A % i ==0 and B%i ==0:
            l.append(i)
    l.reverse()
    print(l[K-1])


Measured memory_bytes: 5356
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/

int main() {
	ll A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

	//
	ll sum1 = X * A + Y * B;
	ll sum2 = 0;
	ll sum3 = 0;
	if (X >= Y) {
		sum2 = (X - Y)*A + Y * 2 * C;
		sum3 = X * 2 * C;
	}
	else {
		sum2 = (Y - X)*B + X * 2 * C;
		sum3 = Y * 2 * C;
	}
	ll min = sum1;
	if (min > sum2) min = sum2;
	if (min > sum3) min = sum3;
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

S=input()

ans = 0
res = 0
for s in S:
    if s in ['A','C','G','T']:
        res += 1
    else:
        ans = max(ans,res)
        res = 0
ans = max(ans,res)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define EPS (1E-10)
const int maxn=100000+10;
int n;

struct Point
{
    int x,y;
    Point() {}
    Point(int _x,int _y):x(_x),y(_y) {}
    Point operator -(Point p)
    {
        return Point(x-p.x,y-p.y);
    }
    bool operator <(Point p)
    {
        return x==p.x?y<p.y:x<p.x;
    }
    int cross(Point p)
    {
        return x*p.y-y*p.x;
    }
    int dot(Point p)
    {
        return x*p.x+y*p.y;
    }
    int norm()
    {
        return x*x+y*y;
    }

};
vector<Point> ps;

int ccw(Point p,Point p1,Point p2)
{
    #define COUNT_CLOCKWISE 1
    #define CLOCKWISE -1
    #define ONLINE_FRONT 2
    #define ONLINE_BACK -2
    #define ON_SEGMENT 0
    Point a=p1-p;
    Point b=p2-p;
    if(a.cross(b)<-EPS) return CLOCKWISE;
    if(fabs(a.cross(b)<EPS)) return CLOCKWISE;
    if(a.cross(b)>EPS) return COUNT_CLOCKWISE;
    if(a.dot(b)<-EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;

}
int is_contain(vector<Point> ps,Point p)
{
    Point a,b;
    int n=(int)ps.size();
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        a=ps[i]-p;
        b=ps[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<=0.0&&b.y>0.0&&a.cross(b)>0.0) flag=!flag;
        if(a.cross(b)==0.0&&a.dot(b)<=0) return 1;
    }
    return flag?2:0;
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        ps.push_back(Point(x,y));
    }
    int q;
    Point p;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&p.x,&p.y);
        printf("%d\n",is_contain(ps,p));
    }



    return 0;

}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = false;
    for(int i=1; i<=100; i++){
	if(a*i%b == c)
	    flag = true;
    }

    cout << (flag ? "YES": "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n];
    int sum = 0;
    for(int i=0;i<n;i++){
      cin>>arr[i]; 
      sum+=arr[i];
    }
    int m; 
    cin>>m;
    int p[m],x[m];
    for (int i=0;i<m;i++){
      cin>>p[i]>>x[i];
    }
    for(int i=0;i<m;i++){
        int a=sum-arr[p[i]-1]+x[i];
        cout<<a<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e6+10, mod = 1e9+7;
int n,h,d,sum,fac[N],f[N],pre[N];

inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}

inline int Query(int l,int r){
	int ret=pre[r];
	if (l>0) ret=Mod(ret+mod-pre[l-1]);
	return ret;
}

int main(){
	n=read(),h=read(),d=read();
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod,sum=Mod(sum+fac[i]);
	f[0]=fac[n],pre[0]=f[0];
	For(i,1,h){
		f[i]=1ll*Query(max(0,i-d),i-1)*sum%mod;
		pre[i]=Mod(pre[i-1]+f[i]);
	}
	printf("%d\n",1ll*f[h]*power(sum,mod-2)%mod);
}

Measured memory_bytes: 15408
//============================================================================
// Name        : one.cpp
// Author      : Lich_Ning
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
//#include<fstream>
#include<string>
using namespace std;
//ofstream fout;
//ifstream fin;
struct node
{
	int data;
	node * l;
	node * r;
	node(){data=0;l=r=nullptr;}
	node(int x){data=x;l=r=nullptr;}
};
struct tree
{
	node * root;
	tree(){root=nullptr;}
	tree(int x){root=new node(x);}
	void insert(int);
	void inorder(node * p);
	void preorder(node * p);
	node * find(int);
	node * findParent(int x);
	void Delete(int);
};
int main() {
	ios::sync_with_stdio(false);
	//fout.open("out");
	//fin.open("in.");
	int n;
	cin>>n;
	tree bt;
	int data;
	string t;
	string a="insert";
	string b="print";
	string c="find";
	string d="delete";
	for(int i=0;i<n;i++){
		cin>>t;
		if(t==a){
			cin>>data;
			bt.insert(data);
		}
		if(t==b){
			bt.inorder(bt.root);
			cout<<endl;
			bt.preorder(bt.root);
			cout<<endl;
		}
		if(t==c){
			cin>>data;
			if(bt.find(data))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		if(t==d){
			cin>>data;
			bt.Delete(data);
		}
	}
	//fout.close();
	//fin.close();
	return 0;
}
void tree::insert(int x)
{
	if(root==nullptr){
		root=new node(x);
	return;
	}
	node * p=root;
	node * q=root;
	while(p!=nullptr){
		q=p;
	if(p->data>x)
		p=p->l;
	else
		p=p->r;
	}
	if(q->data>x)
		q->l=new node(x);
	else
		q->r=new node(x);
}
void tree::inorder(node * p)
{
	if(p==nullptr)
		return ;
	inorder(p->l);
	cout<<' '<<p->data;
	inorder(p->r);
}
void tree::preorder(node * p)
{
	if(p==nullptr)
		return ;
	cout<<' '<<p->data;
	preorder(p->l);
	preorder(p->r);
}
node * tree::find(int x)
{
	node * p=root;
	while(p!=nullptr){
		if(p->data==x)
			return p;
		else if(x<p->data)
			p=p->l;
		else
			p=p->r;
	}
	return 0;
}
node * tree::findParent(int x)
{
	node * p=root;
	if(p->data==x) return 0;
	while(p!=nullptr){
		if(p->l->data==x||p->r->data==x)
			return p;
		else if(x<p->data)
			p=p->l;
		else
			p=p->r;
	}
	return 0;
}
void tree::Delete(int x)
{
	node * p=find(x);
	if(p==nullptr) return;
	node * q=findParent(x);
	if(q==nullptr){
		if(p->r!=nullptr){
			root=p->r;
			node * t=p->r;
			while(t->l!=nullptr) t=t->l;
			t->l=p->l;
			delete p;
			return;
		}
		else {
			root=p->l;
			delete p;
			return;
		}
	}
	if(p->l==nullptr||p->r==nullptr){
		if(p->l==nullptr&&p->r==nullptr){
			if(q->l==p){q->l=nullptr;delete p;return ;}
			else{q->r=nullptr;delete p;return ;}
			}
		else if(p->l!=nullptr){
			if(q->l==p){q->l=p->l;delete p;return;}
			else{q->r=p->l;delete p;return ;}
		}
		else{
			if(q->l==p){q->l=p->r;delete p;return;}
			else{q->r=p->r;delete p;return;}
		}
	}
	else{
		if(q->l==p){
			node * t=p->l;
			while(t->r!=nullptr) t=t->r;
			q->l=t;
			t->r=p->r;
			delete p;
			return ;
		}
		else{
			node * t=p->r;
			while(t->l!=nullptr) t=t->l;
			q->r=t;
			t->l=p->l;
			delete p;
			return;
		}
	}
}

Measured memory_bytes: 18768
def resolve():
    N = int(input())
    p = list(map(int, input().split()))
    a = []
    for i in range(N):
        if p[i] != i+1:
            a.append(i)

    if len(a) == 0:
        print('YES')
        return

    if len(a) != 2:
        print('NO')
        return

    p[a[0]], p[a[1]] = p[a[1]], p[a[0]]

    for i in range(N):
        if p[i] != i+1:
            print('NO')

    print('YES')



if __name__ == "__main__":
    resolve()


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

long long med(vector<long long> v){
    int n = v.size();
    sort(v.begin(), v.end());
    if(n % 2 == 0)return (v[n / 2] + v[n / 2 - 1]) / 2;
    else return v[n / 2];
}

int main(){
    int N;
    scanf("%d", &N);
    vector<long long> A(N);
    vector<long long> Aplus(N);
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        Aplus[i] = A[i] - (i + 1);
    }
    
    long long minu = med(Aplus), ans = 0;
    for(int i = 0; i < N; i++)ans += abs(Aplus[i] - minu);
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<string.h>

using namespace std;

int dice[6] ={1, 3, 2, 6, 4, 5};
int sub[6];
int total = 0;

char East[] = "East";
char West[] = "West";
char North[]= "North";
char South[]= "South";
char Right[]= "Right";
char Left[] = "Left";

void copy_arr(void){
	for(int i = 0; i < 6; i++){
		sub[i] = dice[i];
	}
}

void change_dice(char s[]){
	if(strcmp(East,s) == 0){
		copy_arr();
		dice[0] = sub[4];		
		dice[1] = sub[0];
		dice[3] = sub[1];
		dice[4] = sub[3];
	}
	else if(strcmp(West,s) == 0){
		copy_arr();
		dice[0] = sub[1];		
		dice[1] = sub[3];
		dice[3] = sub[4];
		dice[4] = sub[0];
	}
	else if(strcmp(North,s) == 0){
		copy_arr();
		dice[0] = sub[2];		
		dice[2] = sub[3];
		dice[3] = sub[5];
		dice[5] = sub[0];
	}
	else if(strcmp(South,s) == 0){
		copy_arr();
		dice[0] = sub[5];		
		dice[2] = sub[0];
		dice[3] = sub[2];
		dice[5] = sub[3];
	}
	else if(strcmp(Right,s) == 0){
		copy_arr();
		dice[1] = sub[5];
		dice[2] = sub[1];
		dice[4] = sub[2];
		dice[5] = sub[4];
	}
	else if(strcmp(Left,s) == 0){
		copy_arr();
		dice[1] = sub[2];
		dice[2] = sub[4];
		dice[4] = sub[5];
		dice[5] = sub[1];
	}
	else{
		cout << "ERR" << endl;
	}
	total += dice[0];
}

int main()
{
	int n;
	for(;;){
		total = 0;
		char s[10000][6] = {0};
		dice[0] = 1;
		dice[1] = 3;
		dice[2] = 2;
		dice[3] = 6;
		dice[4] = 4;
		dice[5] = 5;
		
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> s[i];
		}
		
		for(int i = 0; i < n; i++){
			change_dice(s[i]);
		}
		cout << total+1 << endl;
	}
}

Measured memory_bytes: 0
S = dict()
S["a"] = input()
S["b"] = input()
S["c"] = input()

turn = 'a'

while True:
    if len(S[turn]) == 0:
        break
    next_turn = S[turn][0]
    S[turn] = S[turn][1:]
    turn = next_turn

print(turn.upper())


Measured memory_bytes: 8908
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
char str[maxn];
int main()
{
    while(~scanf("%s",str+1))
    {
        int len = strlen(str+1);
        int idxs = 0, idxe = 0;
        for(int i = 1; i <= len; i++)
        {
            if(!idxs && str[i] == 'A') idxs = i;
            if(str[i] == 'Z' && idxs) idxe = i;
        }
        int s = idxe - idxs;
        if(s > 0) printf("%d\n",s+1);
        else printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 512
// unihernandez22
// https://atcoder.jp/contests/abc060/tasks/abc060_b
// implementation

import std.stdio: readf, writeln;

void main() {
	int a, b, c;
	"%s %s %s\n".readf(&a, &b, &c);

	int modulo = c % b;

	int limit = a*100;
	int i = a;
	while (i < limit) {
		if (i % b == modulo) {
			writeln("YES");
			return;
		}
		i += a;
	}
	writeln("NO");
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(std::string S){
	ll max = 0, tmp = 0;
	REP(i, S.size()) {
		if (S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') {
			tmp++;
		}else tmp = 0;
		chmax(max, tmp);
	}
	cout << max << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
#include<stdlib.h>
using namespace std;
typedef long long ll;
#include<stdio.h>

//最大公約数をユークリッドの互除法で、再帰的に求める
ll gcd(ll x, ll y) {
	ll r = y%x;
	if (r == 0)return x;
	else gcd(r, x);
}

int main(void) {
	ll a,b;
	cin >> a >> b;
	if (a + b == 15)cout << "+\n";
	else {
		if (a*b == 15)cout << "*\n";
		else cout << "x\n";
	}
	return 0;
}

Measured memory_bytes: 256