akhauriyash/Code-Regression huggingface dataset:
// javac Main.java && java _

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int n;
	char[] S;
	
	Main() {
		n = in.nextInt();
		S = in.next().toCharArray();
		int len = S.length;
		for (int i = 0; i < len; i++) {
			int nu = (S[i] - 'A' + n) % 26;
			S[i] = (char) (nu + 'A');
		}
		out.println((new String(S)));
		out.close();
	}
	
	

	int min(int a, int b) { if (a < b) return a; return b; }	
	int max(int a, int b) { if (a > b) return a; return b; }	
	long min(long a, long b) { if (a < b) return a; return b; }	
	long max(long a, long b) { if (a > b) return a; return b; }	

	boolean z(int x) { if (x == 0) return true; return false; }
	boolean z(long x) { if (x == 0) return true; return false; }
	
	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  list<int> l;
  list<int>::iterator p;
  string s;
  int x;
  
  rep(i, 0, n) {
    cin >> s;
    if(s == "insert") {
      cin >> x;
      l.push_front(x);
    }
    if(s == "deleteFirst") l.pop_front();
    if(s == "deleteLast") l.pop_back();
    if(s == "delete") {
      cin >> x;
      for(p = l.begin(); p != l.end(); p++) {
        if(*p == x) {
          l.erase(p);
          break;
        }
      }
    }
  }    
  for(p = l.begin(); p != l.end(); p++) {
    if(p != l.begin()) 
      cout << " ";
    cout << *p;
  }
  cout << "\n";

}



Measured memory_bytes: 34444
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    System.out.println(num * (num - 1) / 2 - num / 2);
    for(int i = 1; i <= num; i ++) {
      for(int j = 1; j < i; j ++) {
        if(i + j == num / 2 * 2 + 1) { continue; }
        System.out.println(i+" "+j);
      }
    }
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a;
set<ll> a2;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		a2.insert(a);
	}
	if (sz(a2) == n) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

bool devisor8(int n){
  int tmp = 0;
  for (int i = 1; i <= n; i++)
  {
    if(n % i == 0)tmp++;
  }
  if (tmp == 8)return true;
  else return false;
}



int main(){
  int n; cin>>n;
  ll ans = 0;
  for (int i = 1; i <= n; i += 2)
  {
    if(devisor8(i))ans++;
  }
  
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    bool ans = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 1) ans = true;
    }
    cout << (ans ? "first" : "second") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 어떻게 xor basis까지 사랑하겠어...
//
bool chosen[100000];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	ll all = 0;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		all ^= a[i];
	}
	for(int b=59; b>=0; b--) {
		if(all&(1ll<<b)) continue;
		for(int i=0; i<n; i++) {
			if(chosen[i]) continue;
			if(a[i]&(1ll<<b)) {
				//printf("at b=%d, %lld at position %d is chosen\n", b, a[i], i);
				chosen[i] = 1;
				ll v = a[i];
				for(int j=0; j<n; j++) {
					if(i==j) continue;
					if(a[j]&(1ll<<b))
						a[j] ^= v;
				}
/*				for(int j=0; j<n; j++) {
					printf("%lld ", a[j]);
				}
				puts("");*/
				break;
			}
		}
	}
	memset(chosen, 0, sizeof chosen);
	ll add = 0;
	for(int b=59; b>=0; b--) {
		if(all&(1ll << b)) continue;
		for(int i=0; i<n; i++) {
			if(chosen[i]) continue;
			if(a[i]&(1ll<<b)) {
				//printf("b=%d: added %lld\n", b, a[i]);
				chosen[i] = 1;
				add ^= a[i];
			}
		}
	}
	cout << (add + (all^add));
}

Measured memory_bytes: 1152
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
n=int(input())
if(n<1200):
    print("ABC")
elif(n<2800):
    print("ARC")
else:
    print("AGC")
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

bool alice[105],bob[105];

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	for (int i = a; i <= b; i++) {
		alice[i] = true;		
	}
	for (int i = c; i <= d; i++) {
		bob[i] = true;
	}
	int ans = 0;
	for (int i = 0; i <= 100; i++) {
		if (alice[i] && bob[i])ans++;
	}
	cout << (ans?ans-1:0) << endl;

	return 0;
}

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

int main(void)
{
    double r, area, circ;
    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%lf", &r);
    area = r * r * M_PI;
    circ = 2 * r * M_PI;
    printf("%.6lf %.6lf\n", area, circ);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>

int main() {
  int abc_like[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999 };
  int n;  // 100 <= n <= 999 
  std::cin >> n;

  int abc_in = 0;
  int i = 0;
  while (abc_in == 0) {
    if (n <= abc_like[i]) {
      abc_in = abc_like[i];
    }
    ++i;
  }
  std::cout << abc_in << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define SIDE 100

void push(int);
int pop(void);

int stack[SIDE];
int top = 0;

void push(int x){
  stack[++top] =x;
}


int pop(){
  top--;
  return stack[top+1];
}

int main(){
  int a,b,sum;
  top=0;
  char s[1000000];

  while(scanf("%s",s) != EOF){
    if(s[0]=='+'){
      a = pop();
      b = pop();
      push(b + a);
    }
    else if(s[0]=='-'){
      a = pop();//a=4
      b = pop();//b=3
      push(b - a);   //1 
    }
    else if(s[0]=='*'){
      a = pop();
      b = pop();
      push(b * a);    
    }
    else{
      push(atoi(s));
    }
  }
  
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2104
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int R = int.Parse(ipt[1]);
    Console.WriteLine((10 <= N) ? R : R + (100 * (10 - N)));
  }
}

Measured memory_bytes: 11092
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
const long long inf = 1LL << 62;
struct edge {
	int to, sum;
	edge() : to(-1), sum(0) {};
	edge(int to_, int sum_) : to(to_), sum(sum_) {};
};
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> U(M), V(M), S(M);
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; ++i) {
		cin >> U[i] >> V[i] >> S[i]; --U[i], --V[i];
		G[U[i]].push_back(edge(V[i], S[i]));
		G[V[i]].push_back(edge(U[i], S[i]));
	}
	vector<long long> val(N);
	vector<int> sgn(N, -1);
	queue<int> que; que.push(0); sgn[0] = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (edge e : G[u]) {
			if (sgn[e.to] == -1) {
				val[e.to] = e.sum - val[u];
				sgn[e.to] = sgn[u] ^ 1;
				que.push(e.to);
			}
		}
	}
	long long la = 1, ra = inf;
	for (int i = 0; i < M; ++i) {
		if (sgn[U[i]] ^ sgn[V[i]]) {
			if (val[U[i]] + val[V[i]] != S[i]) {
				la = inf;
				ra = -inf;
			}
		}
		else {
			long long t = S[i] - val[U[i]] - val[V[i]];
			if (sgn[U[i]] == 1) {
				t = -t;
			}
			if (t & 1) {
				la = inf;
				ra = -inf;
			}
			else {
				la = max(la, t / 2);
				ra = min(ra, t / 2);
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		if (sgn[i] == 0) {
			la = max(la, 1 - val[i]);
		}
		else {
			ra = min(ra, val[i] - 1);
		}
	}
	cout << (la > ra ? 0 : ra - la + 1) << '\n';
	return 0;
}

Measured memory_bytes: 9332
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	if (N < 1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}


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

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int minSum = 0x7fffffff;
    for (int i = 1; i <= (N >> 1); i++) {
        int a = i;
        int b = N - i;
        int sum = 0;
        while (a) {
            sum += a % 10;
            a /= 10;
        }
        while (b) {
            sum += b % 10;
            b /= 10;
        }
        if (sum < minSum) minSum = sum;
    }
    printf("%d\n", minSum);
    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin (aka white_space)
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    bool ok=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK\n";
            ok=1;
            break;
        }
    }
    if(!ok)cout << "NG\n";
    return 0;
}
///Alhamdulillah



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll t,m,a,sum=0;
    cin>>t>>m;
    while(m--)
    {
        cin>>a;
        sum=sum+a;

    }
    if((sum)>t)cout<<-1<<endl;
    else cout<<t-sum<<endl;



}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
string field[2020];

    int l[2020][2020];
    int r[2020][2020];
    int u[2020][2020];
    int d[2020][2020];
int main()

{
    int h,w;

    cin >> h >> w;
    rep(i,h){
        cin >> field[i];
        }
    rep(i,h){
        rep(j,w){
            if (field[i][j] == '#'){
                l[i][j] = 0;
                u[i][j] = 0;
            }

            else {
                
                u[i][j] = (i== 0)?1:u[i-1][j]+1;
                l[i][j] = (i == 0)?1:l[i][j-1]+1;

            }
        }
    }
    for (int i = h-1;i>= 0;i--){
        for (int j = w-1;j>=0;j--){
            if (field[i][j] == '#'){
                r[i][j] = 0;
                d[i][j] = 0;
            }

            else {
                
                d[i][j] = (i== h-1)?1:d[i+1][j]+1;
                r[i][j] = (i == w-1)?1:r[i][j+1]+1;
        }   }
    }
    int res = 0;
    rep(i,h){
        rep(j,w){
            if(field[i][j] == '#')continue;
            res = max(res,r[i][j]+l[i][j]+u[i][j]+d[i][j]-3);

        }
        
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 68096
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int a, b, c;

void solve() {
    if (c - a - b <= 0) {
        No();
        return;
    }
    Yes(4 * a * b < (c - a - b) * (c - a - b));
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;


    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	int a, b;
	cin>> a;
	lp(i, 1, 10)
	{
		lp(j, 1, 10)
		{
			if(i*j == a)
				return cout<< "Yes", 0;
		}
	}
	cout<< "No";
	return 0;
}

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    string s;
    void input() {
        cin >> s;
    }

    void solve() {
        int n = 0;
        bool f = false;
        for (int i = 0; i < s.size(); i++) {
            char c = s[i];
            if (!f && s[i] == 'A') {
                f = true;
                n++;
            } else if (f && s[i] == 'Z') {
                f = false;
                n++;
            }
        }
        if (f) n--;
        if (n == 0) {
            cout << -1 << endl;
        } else {
            assert(n % 2 == 0);
            for (int i = 0; i < n / 2; i++) {
                cout << "AZ";
            }
            cout << endl;
        }
    }
}

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

Measured memory_bytes: 1184
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double>> pq;
    for (ll i = 0; i < N; i++) {
        double v;
        cin >> v;
        pq.push(v);
    }

    for (ll i = 0; i < N - 1; i++) {
        double fi = pq.top();
        pq.pop();
        double se = pq.top();
        pq.pop();
        pq.push((fi + se) / 2);
    }

    cout << fixed << setprecision(10) << pq.top() << endl;
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
void solve(void)
{
    int a, b;
    cin >> a >> b;
    int ans = INF;
    for (int i = 1; i < 999; ++i)
    {
        int x = i * (i + 1) / 2;
        int y = x + i + 1;
        if (x - a == y - b)
            ans = min(ans, x - a);
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m, p[10];
vector<int> v[10];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int x;
		cin >> x;
		inc(j, x) {
			int s;
			cin >> s;
			s--;
			v[i].PB(s);
		}
	}
	inc(i, m) { cin >> p[i]; }
	
	int ans = 0;
	inc(b, 1 << n) {
		bool f = true;
		inc(i, m) {
			int c = 0;
			RF(e, v[i]) { c += bit(b, e); }
			f &= (c % 2 == p[i]);
		}
		if(f) { ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if [h, w].all?(&:zero?)

  tile_map = Array.new
  tile_already_arrived = Array.new

  h.times do
    tile_map << gets.chomp.split('')
    tile_already_arrived << Array.new(w, false)
  end

  x = y = 0

  while true
    tile_present = tile_map[y][x]

    if tile_already_arrived[y][x] == true
      goal = "LOOP"
      break
    else
      tile_already_arrived[y][x] = true
      case tile_present
      when '>' 
        x += 1
      when '<'
        x -= 1
      when 'v'
        y += 1
      when '^'
        y -= 1
      when '.'
        goal = "#{x} #{y}"
        break
      end
    end
  end

  puts goal
end

Measured memory_bytes: 6892
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> a(n+10);
   a[0]=0;
   a[n+1]=0;
   long long sum=0;
   long long ans;
   for(int i=1;i<n+1;i++)cin>>a[i];
   for(int i=0;i<n+2;i++){
      sum += abs(a[i]-a[i+1]);
   }
   for(int i=1;i<n+1;i++){
      ans=sum;
      ans -= (abs(a[i]-a[i-1])+abs(a[i+1]-a[i]));
      ans += abs(a[i+1]-a[i-1]);
      cout<<ans<<endl;
   }

}

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10000)

n=int(input())
a=[[0]*(n-1) for i in range(n)]
id=[[-1]*(n) for i in range(n)]
MAXV=n*(n-1)//2
to=[[]*(n) for i in range(MAXV)]
  
def toId(i,j):
  if (i>j):
    i,j=j,i
  return id[i][j]


visited=[False]*MAXV
calculated=[False]*MAXV
dp=[0]*MAXV
def dfs(v):
  if visited[v]:
    if not calculated[v]:
      return -1
    return dp[v]
  visited[v]=True
  dp[v]=1
  for u in to[v]:
    res = dfs(u)
    if res==-1:
      return -1
    dp[v]=max(dp[v], res+1)
  calculated[v]=True
  return dp[v]


def main():
  for i in range(n):
    a[i]=list(map(lambda x:int(x)-1,input().split()))
  v=0
  for i in range(n):
    for j in range(n):
      if i<j:
        id[i][j]=v
        v+=1
  for i in range(n):
    for j in range(n-1):
      a[i][j]=toId(i,a[i][j])
    for j in range(n-2):
      to[a[i][j+1]].append(a[i][j])
      
  ans=0
  for i in range(v):
    res=dfs(i)
    if res==-1:
      print(-1)
      exit(0)
    ans=max(ans, res)

  print(ans)
  
  
  
if __name__=='__main__':
  main()

Measured memory_bytes: 207352
/*
*   Bismillahir Rahmanir Rahim
*   Imtiaz Rafi
*   PCIU
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  stack<int> st;
  string s;

  while(cin >> s){
    if(isdigit(s[0])){
      st.push(atoi(s.c_str()));
    }
    else{
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();

      if(s == "+") st.push(b + a);
      if(s == "-") st.push(b - a);
      if(s == "*") st.push(b * a);
    }
  }

  cout << st.top() << endl;
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    ll n, m, k, ans = 0; cin >> n >> m >> k;
    vector<ll> a(n),b(m),A(n+1),B(m+1);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    for(int i = 1; i < n+1; i++) A[i] = a[i-1] + A[i-1];
    for(int i = 1; i < m+1; i++) B[i] = b[i-1] + B[i-1];
    //for(auto i : B) cout << i << " ";
    for(int i = 0; i < n+1; i++){
        if(A[i] <= k){
            auto iter = lower_bound(B.begin(),B.end(),k-A[i]);
            ll idx = distance(B.begin(),iter); //cout  << "idx=" << idx << endl;
            //cout << "i=" << i << "idx=" << idx << endl;
            if(idx != m+1) if( *(iter) == k-A[i]) idx++;
            ans = max(ans,idx+i-1);
        }else{
            break;
        }
    }
    cout << ans << endl;

}




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

int main() {
int N,M;
  cin >> N >> M;
  int ndayo = 0, mdayo = 0;
  if(N != 0){
  	ndayo = N*(N-1)/2;
  }
  if(M != 0){
  	mdayo = M*(M-1)/2;
  }
  cout << ndayo + mdayo << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  a.insert(a.begin(), -1);
  std::vector<int> m(n + 1, 0);
  for (int i = n; i >= 1; i--) {
    int par = 0;
    for (int j = 2 * i; j <= n; j += i) {
      par ^= m.at(j);
    }
    m.at(i) = par ^ a.at(i);
  }
  std::vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (m.at(i)) ans.push_back(i);
  }
  int sz = ans.size();
  std::cout << sz << std::endl;
  for (int i = 0; i < sz; i++) {
    std::cout << (i > 0 ? " " : "") << ans.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3516
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
LL ans,maxs;
int n,m,a[maxn],b[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
inline LL abs_(LL x){return x>0?x:-x;}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	
	int mid=(n+1)/2,L=1,R=n;m=0;
	b[++m]=a[mid];for (int i=1;i<mid;i++) b[++m]=a[L++],b[++m]=a[R--];if (!(n&1)) b[++m]=a[R--];
	ans=0;for (int i=2;i<=n;i++) ans+=abs_(b[i]-b[i-1]);maxs=max(maxs,ans);
	
	mid=(n+1)/2,L=1,R=n;m=0;
	b[++m]=a[mid];for (int i=1;i<mid;i++) b[++m]=a[R--],b[++m]=a[L++];if (!(n&1)) b[++m]=a[R--];
	ans=0;for (int i=2;i<=n;i++) ans+=abs_(b[i]-b[i-1]);maxs=max(maxs,ans);
	printf("%lld\n",maxs);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int c = stoi(s + t);
  for(int i = 0; i < 1000; i++){
    if( c == i*i){
      cout << "Yes" << endl;
      return 0;
    }
  }
      cout << "No" << endl;
    
  
}

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

using namespace std;

int h, w;
char str[15][15];

int p;
int rp[11000][15];

int trp[15];
void bt(int cnt) {
    int i;
    if (cnt==h) {
        for (i=0;i<h;i++) rp[p][i] = trp[i];
        p++;
        return;
    }
    if (trp[cnt]!=cnt) {
        bt(cnt+1);
        return;
    }
    for (i=cnt+1;i<h;i++) {
        if (trp[i]!=i) continue;
        trp[cnt] = i; trp[i] = cnt;
        bt(cnt+1);
        trp[i] = i;
    }
    trp[cnt] = cnt;
}

int bit[15];
int wp[15];
bool good(int cnt, int rem) {
    int i;
    if (cnt==w) return true;
    if (wp[cnt]!=cnt) {
        return good(cnt+1,rem);
    }
    for (i=cnt;i<w;i++){
        if ((!rem)&&i==cnt) continue;
        if (wp[i]!=i) continue;
        if (bit[cnt]>>i&1) {
            wp[cnt] = i; wp[i] = cnt;
            if (good(cnt+1,rem-(i==cnt))) return true;
            wp[i] = i;
        }
    }
    wp[cnt] = cnt;
    return false;
}

bool rchk() {
    int i, j, k, l;
    for (k=0;k<p;k++) {
        for (j=0;j<w;j++) bit[j] = (1<<w)-1;
        for (i=0;i<h;i++) {
            if (rp[k][i]<i) continue;
            for (j=0;j<w;j++) {
                for (l=0;l<w;l++) {
                    if (str[i][j]!=str[rp[k][i]][l]||
                        str[i][l]!=str[rp[k][i]][j]) bit[j] &= ~(1<<l);
                }
            }
        }
        for (j=0;j<w;j++) wp[j] = j;
        if (good(0,w%2)) return true;
    }
    return false;
}

void print(bool a) {
    puts(a?"YES":"NO");
    exit(0);
}

int main() {
    int i, j;

    scanf("%d%d",&h,&w);
    for (i=0;i<h;i++) scanf("%s",str[i]);
    for (i=0;i<h;i++) trp[i] = i;
    if (h&1) {
        bt(1);
        for (i=0;i<h;i++) {
            for (j=0;j<w;j++) swap(str[0][j],str[i][j]);
            if (rchk()) print(1);
        }
        print(0);
    }
    else {
        bt(0);
        print(rchk());
    }

    return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    for (int i = 0; i < n; ++i) {
        cin >> grid[i];
    }

    vector<vector<int>> dp(n, vector<int>(m, int(0)));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (grid[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            }

            if (i + 1 < n) {
                dp[i + 1][j] += dp[i][j];
                if (dp[i + 1][j] >= MOD)
                    dp[i + 1][j] -= MOD;
            }

            if (j + 1 < m) {
                dp[i][j + 1] += dp[i][j];
                if (dp[i][j + 1] >= MOD)
                    dp[i][j + 1] -= MOD;
            }

        }
    }
    
    cout << dp[n - 1][m - 1] << '\n';
    return 0;
}


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

int main() {
  int a[5];
  rep(i,5) cin >> a[i];

  rep(i,5){
      if(a[i]==0){
          cout << i+1 << endl;
          return 0;
      }
  }
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		long sum = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}


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

signed main(){
	char a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	if(a[6]<='4'&&a[5]=='0'){
		cout<<"Heisei"<<endl;
	}
	else{
		cout<<"TBD"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ld a, b, x;
	cin >> a >> b >> x;
	ld ans;
	if(2.0*x<=a*a*b) {
		ans = acos(-1)/2-atan((2*x)/(a*b*b));
	} else {
		ans = atan((2*a*a*b-2*x)/(a*a*a));
	}
	cout << fixed << setprecision(15) << ans*180/acos(-1) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = 200001;


	void doIt() {
		int N = sc.nextInt();
		Set<String> set = new HashSet<>();
		for(int i = 0; i < N; i++) {
			set.add(sc.next());
		}
		System.out.println(set.size());
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 78220
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//https://drken1215.hatenablog.com/entry/2018/01/16/222843
//////////////////////////////////////
map< int, int > prime_factor(int64_t n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
ll fact[MAX]={1},inv[MAX]={1};

ll modpow(ll a,ll b){
  ll r=1;
  while(b>0){
    if(b%2==1)(r*=a)%=mod;
    (a*=a)%=mod;
    b/=2;
  }
  return r;
}
ll chose(ll a,ll b){
  return fact[a]*inv[b]%mod*inv[a-b]%mod;
}
void cmbinit(){
  rep(i,MAX){
      fact[i+1]=fact[i]*(i+1)%mod;
      inv[i+1]=modpow(fact[i+1],mod-2);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    map<int,int>pf;
    pf=prime_factor(m);
    cmbinit();
    ll ans=1;
    for(auto x:pf){
        (ans*=chose(x.sc+n-1,n-1))%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  int dp[31];
  
  while(cin>>n, n) {
    fill(dp, dp+31, 0);
    dp[0]=dp[1]=1; dp[2]=2; dp[3]=4;
    for(int i=4; i<=n; i++) {
      dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
    }

    cout << dp[n]/3650+1 << endl;
  }

  return 0;
}

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

int main()
{
    std::string S;
    std::cin >> S;
    int len = 0;


    while(true)
    {
        if(S[len]=='\0')
            break;
        else
        {
            len++;
        }
        
    }
  
    char lst = S[len-1];

    if(lst == 's')
        std::cout << S << "es" << std::endl;
    else
    {
        std::cout << S << 's' <<std::endl;
    }
}

Measured memory_bytes: 3608
//To all well wishers,I own this code
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vector<double> a(n);
    f(i,n)
    {
        double x;
        cin>>x;
        a[i]=(double)1.0/x;
    }
    double s=0;
    for(int i=0;i<n;i++)
    {
        s+=a[i];
    }
    cout<<1/s<<endl;
    
    
    
    return 0;
}




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

int main(){
int K,A,B;
cin >> K >> A >> B;
  for(int i=0;K*(i-1)<=B;i++){
    if(A<=K*(i-1)){
      cout << "OK" <<endl;
      break;
    }
    else if (K*i>B){
      cout <<"NG" <<endl;
    }
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll ans = 0;
vector<string> ss;

void dfs(string &s, char c) {
  if (c == 'a') {
    ss.push_back(s);
    return;
  }
  int ci = -1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == c) {
      ci = i;
      break;
    }
  }
  if (ci < 0) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == c - 1) {
        s[i] += 1;
        dfs(s, c - 1);
        s[i] -= 1;
      }
    }
    dfs(s, c - 1);
  } else {
    for (int i = 0; i < ci; i++) {
      if (s[i] == c - 1) {
        s[i] += 1;
        dfs(s, c - 1);
        s[i] -= 1;
      }
    }
  }
}

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#")
      break;
    ans = 0;

    dfs(s, 'z');

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

    sort(ss.begin(), ss.end());
    if (ss.size() < 10) {
      for (auto &v : ss) {
        cout << v << endl;
      }
    } else {
      for (int i = 0; i < 5; i++)
        cout << ss[i] << endl;
      for (int i = ss.size() - 5; i < ss.size(); i++)
        cout << ss[i] << endl;
    }
    ss.clear();
  }
  return 0;
}



Measured memory_bytes: 4248
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {
    
    double a,b; cin >> a >> b;
    
    if (a > b + EPS) {
        cout << "GREATER" << endl;
    } else if (b > a + EPS)  {
        cout << "LESS" << endl; 
    } else {
        cout << "EQUAL" << endl;
    } 
    
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 998244353;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int x[205], y[205], pw[205];

bool check( int i, int j, int k ) {
	if( y[i] > y[j] ) swap(i, j);
	if( y[k] < y[i] || y[k] > y[j] ) return false;
	if( x[i] > x[j] ) swap(i, j);
	if( x[k] < x[i] || x[k] > x[j] ) return false;
	int vx = x[k] - x[i], vy = y[k] - y[i];
	int wx = x[k] - x[j], wy = y[k] - y[j];
	return vx*wy - vy*wx == 0;
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> x[i] >> y[i];

  pw[0] = 1;
  FOR(i, 1, n+1) pw[i] = pw[i-1] * 2 % MOD;
  int ret = (pw[n] - n + MOD) % MOD;
  REP(i, n) FOR(j, i+1, n) {
    int cnt = 0;
    REP(k, n) if(k!=i && k!=j && check(i,j,k)) ++cnt;
    ret = (ret - pw[cnt] + MOD) % MOD;
  }
  cout << (ret - 1 + MOD) % MOD << endl;

  return 0;
}


Measured memory_bytes: 256
S = input()
A = ''.join([str(i % 2) for i in range(len(S))])
B = ''.join([str((i + 1) % 2)  for i in range(len(S))])

ans1 = ans2 = 0

for s, a, b, in zip(S, A, B):
    if s != a:
        ans1 += 1
    if s != b:
        ans2 += 1

print(min(ans1, ans2))


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

int main() {
	int a,b;cin>>a>>b;
  if(a%2==1&&b%2==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	}

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

typedef unsigned int uint;

const uint M = 6000011u;
const uint P = M/10u+1u;

uint Five[13];
uint C[128];
uint X[M];

uint convert(const char s[]) {
  uint j = 0;
  for(uint i = 0u; s[i] != '\0'; ++i) {
    j += C[s[i]]*Five[i];
  }
  return j;
}

void insert(const char s[]) {
  uint x = convert(s);
  uint p = x%M;
  while(X[p] != UINT_MAX) p = (p+P)%M;
  X[p] = x;
}

bool find(const char s[]) {
  uint x = convert(s);
  uint p = x%M;
  while(X[p] != UINT_MAX) {
    if(X[p] == x) return true;
    p = (p+P)%M;
  }
  return false;
}

int main() {
  int n;
  char s[100];

  C['A'] = 1u;
  C['C'] = 2u;
  C['G'] = 3u;
  C['T'] = 4u;
  Five[0] = 1u;
  for(int i = 1; i < 13; ++i) Five[i] = Five[i-1]*5u;

  fill(X,X+M, UINT_MAX);
  scanf("%d", &n);
  while(n--) {
    scanf("%s", s);
    if(s[0] == 'f') {
      scanf("%s", s);
      if(find(s))
        printf("yes\n");
      else
        printf("no\n");
    } else {
      scanf("%s", s);
      insert(s);
    }
  }
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	set<pii> inds;

	vi arr (N);
	F0R(i, N) {
		cin >> arr[i];
		inds.insert({arr[i], i});
	}

	set<int> bounds;
	bounds.insert(-1);
	bounds.insert(N);

	ll ans = 0;
	for (pii x : inds) {
		auto it = bounds.lower_bound(x.second);
		int lo = *(prev(it));
		int hi = *it;
		ans += 1LL * x.first * (x.second - lo) * (hi - x.second);
		bounds.insert(x.second);
	}
	print(ans);
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int n,k,s;
    cin >> n >> k >> s;

    REP(i,k){
        cout << s << " ";
    }
    if(k != n){
            if(s == 1e9){
            FOR(i,k,(n-1)){
                cout << 1 << " ";
            }
            cout << 1 << endl;
        }else{
            FOR(i,k,(n-1)){
                cout << s+1 << " ";
            }
            cout << s+1 << endl;
        }
    }
    
}


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


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

    int n;
    cin >> n;

    if(n == 0)
    {
        cout << 0 << endl;
        return 0;
    }


    string result = "";
    while(n != 0)
    {
        int rem = n % -2;
        n /= -2;

        if(rem < 0)
        {
            rem += (2);
            n++;
        }

        result = to_string(rem) + result;
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}
	else if(a*b==15){
		cout<<"*"<<endl;
	}
	else{
		cout<<"x"<<endl;
	}
} 
	

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  int cnt = 1;
  
  vector<char> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  sort(all(p));
  
  repo(i,n){
    if(p[i-1]!=p[i])cnt++;
  }
  
  
  cout << (cnt==3?"Three":"Four") << endl;
  
}

Measured memory_bytes: 256