akhauriyash/Code-Regression huggingface dataset:
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]
A = []
for x, l in XL:
    A.append([x + l, x - l])
A.sort()
B = []
i = 0
while True:
    B.append(A[i])
    if i == N - 1:
        break
    j = 1
    while True:
        if A[i][0] > A[i + j][1]:
            j += 1
            if i + j == N:
                break
            continue
        else:
            break
    if i + j == N:
        break
    i = i + j
print(len(B))

Measured memory_bytes: 41652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    string s, temp;
    cin >> s;


    bool YESflag = false;
    bool continueflag = true;
    while(continueflag){
      continueflag = false;

      if(s.empty()){
        YESflag = true;
        break;
      }

      temp = s.substr(0,7);
      if (temp == "dreamer"){
        if (s.size() == 7){
          YESflag = true;
          break;
        } else if (s.substr(7,1) == "e" || s.substr(7,1) == "d"){
          s.erase(s.begin(), s.begin() + 7);
          continueflag = true;
          continue;
        }
      }

      temp = s.substr(0,6);
      if (temp == "eraser"){
        s.erase(s.begin(), s.begin() + 6);
        continueflag = true;
        continue;
      }

      temp = s.substr(0,5);
      if (temp == "dream"){
        s.erase(s.begin(), s.begin() + 5);
        continueflag = true;
        continue;
      }

      if (temp == "erase"){
        s.erase(s.begin(), s.begin() + 5);
        continueflag = true;
        continue;
      }

    }
    if (YESflag){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int a, b, q; cin>>a>>b>>q;
    vector<ll> s(a+2), t(b+2);
    s[0] = t[0] = -INF;
    for(int i=0; i<a; i++) cin>>s[i+1];
    for(int i=0; i<b; i++) cin>>t[i+1];
    s[a+1] = t[b+1] = INF;

    while(q--){
        ll x; cin>>x;

        int sidx = lower_bound(all(s), x) - s.begin();
        int tidx = lower_bound(all(t), x) - t.begin();

        ll ans = INF;
        for(int i=sidx-1; i<=sidx; i++){
            for(int j=tidx-1; j<=tidx; j++){
                chmin(ans, min(abs(x - s[i]) + abs(s[i] - t[j]), abs(x - t[j]) + abs(t[j] - s[i])));
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
package main

import (
	"fmt"
)

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

	var s []byte
	fmt.Scan(&s)

	var cnt int
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{ int b,c=0;cin>>b;int a[b];for(int i=0;i<b;i++)cin>>a[i];
  for(int i=0;i<b;i++){
      while(a[i]%2==0){
          c++;
          a[i]/=2;
      }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    string s;
    cin>>s;
    if(s[0]=='S'){
        cout<<"Cloudy"<<endl;
    }else if(s[0]=='C'){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
}


Measured memory_bytes: 3600
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
  // static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 int n = sc.nextInt();
	 char[] s = sc.next().toCharArray();
	 long[] map = new long[26];
	 Arrays.fill(map,1);
	 for(int i=0;i<n;++i) {
		 map[s[i]-'a']++;
	 }
	 long ans = 1;
	 for(long x : map) ans = (ans*x)%mod;
	 out.print(ans-1);
	 out.close();
		
	}

}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  char b,c;
  cin >> b;
  if(b == 'A') c = 'T';
  else if(b == 'T') c = 'A';
  else if(b == 'C') c = 'G';
  else c ='C';
  
  cout << c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 200


//問題文のとおり

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int e=max(a,c);
	int f=min(b,d);
	cout<<(f>e ? f-e : 0)<<endl;

	cin>>a;
	return 0;
}

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


int main()
{
	int a, b, k;
	int m;
	std::cin >> a >> b >> k;
	int small = std::min(a, b);
	int large = std::max(a, b);
	std::vector<int> divs;
	for (int d = 1; d <= small; d++)
	{
		if (small % d == 0 && large % d == 0)
			divs.push_back(d);
	}
	std::cout << divs.at(divs.size() - k) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
typedef vector<bool> vb;
const ll INF=1LL << 60;
const ll MOD=1e9+7;

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

  int x;
  cin >> x;
  int cnt=0;
  int y=x;
  while(y>1){
    y/=2;
    cnt++;
  }
  int ans=0, a=sqrt(x);
  rep1(i, a+1){
    int n=1;
    rep1(j, cnt){
      n*=i;
      if(n>x){
        n/=i;
        j=cnt;
      }
    }
    ans=max(ans, n);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3580
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s;
  cin>>s;
  int n=s.size();
  string st1=s.substr(0,(n-1)/2);
  string st2=s.substr((n+3)/2-1,n);
  //cout<<st1<<" "<<st2<<endl;
  bool flag=true;
  if(st1!=st2) flag=false;

  reverse(all(st1));
  if(st1!=st2) flag=false;

  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
pii XY[200200];

//2N個のボールのうち最大のものを赤、最小のものを青で塗った場合
int RMBm() {
    int RMax = -INF, Rmin = INF;
    int BMax = -INF, Bmin = INF;
    rep(i, N) {
        int r = max(XY[i].first, XY[i].second);
        int b = min(XY[i].first, XY[i].second);
        RMax = max(RMax, r);
        Rmin = min(Rmin, r);
        BMax = max(BMax, b);
        Bmin = min(Bmin, b);
    }
    return (RMax - Rmin) * (BMax - Bmin);
}

//2N個のボールのうち最大、最小のものを赤でぬる
pii blue[200200];

int RMrm1() {
    int maxv = -INF, minv = INF;
    rep(i, N) {
        int M = max(XY[i].first, XY[i].second);
        int m = min(XY[i].first, XY[i].second);
        blue[i] = pii(m, M);
        if (M > maxv) {
            maxv = M;
        }
        if (m < minv) {
            minv = m;
        }
    }
    sort(blue, blue + N);
    int bluemin = blue[0].first;
    int bluemax = blue[N - 1].first;
    blue[N].first = INF;
    int bluemin2 = INF;
    int res = (maxv - minv) * (bluemax - min(bluemin, bluemin2));
    rep(i, N) {
        bluemin2 = min(bluemin2, blue[i].second);
        bluemin = blue[i + 1].first;
        bluemax = max(bluemax, blue[i].second);
        res = min(res, (maxv - minv) * (bluemax - min(bluemin, bluemin2)));
    }
    return res;
}

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> XY[i].first >> XY[i].second;
    }
    cout << min(RMBm(), RMrm1()) << endl;
    return 0;
}


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

int main(int argc, char const *argv[]) {
    int r, c;
    int mat[101][101] = {};

    cin >> r >> c;
    int rsum = 0;
    int csum = 0;
    int sum = 0;

    for (int i = 0; i < r; i++) {
        rsum = 0;
        for (int j = 0; j < c; j++) {
            cin >> mat[i][j];
            rsum += mat[i][j];
            sum += mat[i][j];
        }
        mat[i][c] = rsum;
    }
    
    mat[r][c] = sum;
    
    for (int j = 0; j < c; j++) {
        csum = 0;
        for (int i = 0; i < r; i++){
            csum += mat[i][j];
        }
        mat[r][j] = csum;
    }

    for (int i = 0; i < r+1; i++) {
        for (int j = 0; j < c+1; j++) {
            if (j != 0) {
                cout << ' ' << mat[i][j];    
            } else {
                cout << mat[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

map<int,int> dp[11][1024];

int main() {
    int n, s;
    while (cin >> n >> s) {
        for (int i=0; i<11; ++i) {
            for (int j=0; j<1024; ++j) {
                dp[i][j].clear();
            }
        }
        dp[0][0][0] = 1;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<1024; ++j) {
                if (dp[i][j].empty()) continue;
                for (auto it = dp[i][j].begin(); it != dp[i][j].end(); ++it) {
                    for (int k=0; k<=9; ++k) {
                        if ((j & (1<<k)) == 0) {
                            dp[i+1][j|(1<<k)][it->first + (i+1)*k] += it->second;
                        }
                    }
                }
            }
        }
        int res = 0;
        for (int i=0; i<1024; ++i) {
            res += dp[n][i][s];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3688
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N,M;
	cin >> N >> M;
	vector<int> data(M);
	int HW = 0;
	for (auto& i : data)
	{
		cin >> i;
		HW += i;
	}
	int ans = N - HW;
	if (ans < 0)ans = -1;
	
		cout << ans << endl;

	

	return 0;

}


Measured memory_bytes: 3672
#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();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n; cin>>n;
    long long ans[10100];
    memset(ans,0,sizeof(ans));
    for(int x=1; x<=110; x++){
        for(int y=1; y<=110; y++){
            for(int z=1; z<=110; z++){
                long long cnt=x*x+y*y+z*z+x*y+y*z+z*x;
                if(cnt<10100){
                    ans[cnt]++;
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a+b >= a-b && a+b >= a*b)
        printf("%d\n", a+b);

    else if (a-b >= a+b && a-b >= a*b)
        printf("%d\n", a-b);

    else if (a*b >= a+b && a*b>= a-b)
        printf("%d\n", a*b);
}



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

int main(){
    string w,ans="Yes";
    vector<int> num(26,0);
    cin >> w;
    for(auto& c : w) num[c-'a']++;
    for(auto& n : num){
        if(n%2){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
#define sz(x) (int)(x.size())
#define all(x) (x).begin(),(x).end()
template<typename tp> void read(tp &x) {cin >> x;}
template<typename tp, typename... Args> void read(tp& x, Args&... args) {read(x);read(args...);}
const int mxN = (int)1e5,INF = (int)1e9,MOD = (int)1e9+7;

void solve()
{
		string s;
		cin >> s;
		if(s.back()!='s')
		{
			cout <<s << "s";
		}
		else cout << s << "es";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int test = 1;
	//read(test);
	while(test--)
		solve();
	return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<vector>
#define pb push_back

using namespace std;

const int N=55,M=205,P=1e9+7;
typedef long long ll;

vector<int>e[N];
int dfn[N],low[N],dfc,st[N],tp,fac[M],ifac[M];
int n,m,k,ans=1;
set<int>dat;

int fpow(int a,int t){static int r;for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;return r;}
int C(int n,int m){return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int polya(int n){int r=0;for(int i=1;i<=n;i++)r=(r+fpow(k,gcd(n,i)))%P;return (ll)r*fpow(n,P-2)%P;}
int permu(int m){return C(m+k-1,k-1);}

void tarjan(int x,int fa){
	dfn[x]=low[x]=++dfc,st[++tp]=x;
	for(int v:e[x])if(v!=fa){
		if(!dfn[v]){
			tarjan(v,x),low[x]=min(low[x],low[v]);
			if(low[v]>=dfn[x]){
				dat.clear();
				int n=0,m=0,las;
				do dat.insert(st[tp]),las=st[tp],st[tp--]=0,n++;while(las!=v);
				dat.insert(x),n++;
				for(int u:dat)for(int v:e[u])if(dat.count(v))m++;m>>=1;
				if(n==1)ans=(ll)ans*k%P;
				else if(m==n)ans=(ll)ans*polya(n)%P;
				else ans=(ll)ans*permu(m)%P;
			}
		}else low[x]=min(low[x],dfn[v]);
	}
	if(fa==0)st[tp--]=0;
}

int main(){
	scanf("%d%d%d",&n,&m,&k);
	fac[0]=1;
	for(int i=1;i<=m+k;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[m+k]=fpow(fac[m+k],P-2);
	for(int i=m+k;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i,0);
	printf("%d\n",ans);
	return 0;
}


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

#define ucin ios::sync_with_stdio(0), cin.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}
ldb L;
int main() {
	cin >> L;
	printf("%.8Lf", (L / 3) * (L / 3) * (L / 3));
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    n = II()
    S = list(input())

    cnt = 0
    pre = ''
    for s in S:
        if pre == s:
            continue
        else:
            cnt += 1
            pre = s
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4084
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N,a;

int main(){
    cin>>N;
    int order[N];
    rep(i,N){
        cin>>a;
        a--;
        order[a]=i;
    }
    rep(i,N){
        cout<<order[i]+1<<" ";
    }
    out("");
    
    
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
}

Measured memory_bytes: 3612
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define lint long long int

#include "bits/stdc++.h"
using namespace std;

int main() {
	lint A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K % 2 == 0) {
		cout << A - B << endl;
	}
	else {
		cout << B - A << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long sum = 0;
		long squareSum = 0;
		int MOD = 1000000007;
		for(int i = 0; i < n; i++){
		    long a = sc.nextLong();
		    sum += a;
		    sum %= MOD;
		    squareSum += a*a%MOD;
		    squareSum %= MOD;
		}
		
		// 計算
		long result = 0;
		result = (sum*sum - squareSum + MOD)%MOD*inv(2, MOD)%MOD;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

    public static long inv(long a, long MOD) {
        long b = MOD;
        long u = 1;
        long v = 0;
        while(b > 0){
            long t = a/b;
            
            a -= t*b;
            long tmp = a;
            a = b;
            b = tmp;
            
            u -= t*v;
            tmp = u;
            u = v;
            v = tmp;
        }
        u %= MOD;
        if(u < 0) u += MOD;
		return u;
	}

}


Measured memory_bytes: 52372
#include <bits/stdc++.h>
int main(){
int n,k,t, tt = 0;
scanf("%d%d", &n, &k);
int res = k * 2;
for (int i = 0; i < n; i ++ ){
for (; (t = getchar()) < 33; );
if (t == tt) res ++ ;
tt = t;
}
if (res >= n) res = n - 1;
printf("%d", res);
}

Measured memory_bytes: 256
n=int(input())
ans_max=0
ans_num=0
for i in range(n):
    num=i+1
    num_now=i+1
    #print(num)
    ans = 0
    while(num%2==0):
        num=num/2
        ans = ans+1
    if(ans>=ans_max):
        ans_max=ans
        ans_num=num_now
        #print('ansmax',ans_max)
        #print('ansmax',ans_num)

print(ans_num)



Measured memory_bytes: 2940
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

    int n = sc.nextInt();
    int MAX_TIME = sc.nextInt();
    int min = Integer.MAX_VALUE;

    for (int i = 0; i < n; i++) {
      int cost = sc.nextInt();
      int time = sc.nextInt();
      if (time<=MAX_TIME && cost<min){
        min = cost;
      }
    }

    if (min==Integer.MAX_VALUE){
      out.println("TLE");
      out.close();
      return;
    }

    out.println(min);
    out.close();
  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 21332
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;

Node treeMinimum(Node a);
Node treeMaximum(Node a);
Node treeSearch(Node u, int k);
Node treeSuccessor(Node a);
void treeDelete(Node a);
void insert(int k);
void inorder(Node u);
void preorder(Node u);
void postorder(Node u);
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node a){
  while(a->left!=NIL){
    a = a->left;
  }
  return a;
}

Node treeMaximum(Node a){
  while(a->right!=NIL){
    a = a->right;
  }
  return a;
}


Node treeSearch(Node u, int k){
  while(u!=NIL && k != u->key){
    if(k < u->key)u= u->left;
    else{
      u=u->right;
    }
  }
    return u;
  }





Node treeSuccessor(Node a){
  if(a->right != NIL) return treeMinimum(a->right);
  Node y;
  y = a->p;
  while(y != NIL && a == y->right){
    a = y;
    y = y->p;
  }
  return y;
}



void treeDelete(Node a){
  Node y;
  Node x;
  if(a->left ==NIL || a->right==NIL)y=a;
  else{
    y = treeSuccessor(a);
  }
  if(y->left!=NIL)x = y->left;
  else {
    x = y->right;
  }
  if(x != NIL)x->p = y->p;
  if(y->p == NIL)root = x;
  else if(y==y->p->left) y->p->left = x;
  else{
    y->p->right = x;
  }
  if(y!=a)a->key = y->key;
}


void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;

   z = malloc(sizeof(struct node));
   z ->key = k;
   z ->left = NIL;
   z ->right = NIL;

   while(x!= NIL){
     y= x;
     if(z->key < x->key) x= x->left;
   else{
     x = x->right;
 }
   }
     z->p = y;

     if(y == NIL) root =z;
     else if(z->key < y->key) y->left = z;
     else {
       y ->right =z;
     }
 }


//中間順列
 void inorder(Node u){
   if(u != NIL){
     inorder(u->left);
     printf(" %d", u->key);
     inorder(u->right);
   }
   else{
     return;
   }
 }

//先行順列
   void preorder(Node u){
     if(u!=NIL){
       printf(" %d",u->key);
       preorder(u->left);
       preorder(u->right);
     }
     else{
       return;
     }
   }

//後攻巡回順
void postorder(Node u){
  if(u!=NIL){
    postorder(u->left);
    postorder(u->right);
    printf(" %d",u->key);
  }
  else{
    return;
  }
}

     int main(){
       int n,i,x;
       char com[20];
       scanf("%d",&n);
       
       for(i = 0 ; i<n; i++){
	 scanf("%s",com);
	 
	 if(com[0] == 'f'){
	 scanf("%d",&x);
	 Node t = treeSearch(root,x);
	 if(t!=NIL)printf("yes\n");
	 else{
	   printf("no\n");
       }
	 
       }
       else if(com[0] == 'i'){
	 scanf("%d",&x);
	 insert(x);
       }
       else if(com[0] == 'p'){
	 inorder(root);
	 printf("\n");
	 preorder(root);
	 printf("\n");
	 
       }
       else if(com[0] == 'd'){
	 scanf("%d",&x);
	 treeDelete(treeSearch(root,x));
       }
     }
     return 0;
   }



Measured memory_bytes: 20416
h, w = list(map(int, input().split()))
s = [list(input()) for i in range(h)]

flag = True
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            neighbors = []
            if i != 0:
                neighbors.append([i-1, j])
            if i != h-1:
                neighbors.append([i+1, j])
            if j != 0:
                neighbors.append([i, j-1])
            if j != w-1:
                neighbors.append([i, j+1])
            neighbors_colors = []
            for n in neighbors:
                neighbors_colors.append(s[n[0]][n[1]])
            if '#' not in neighbors_colors:
                flag = False
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	string s; cin >> s;
	vector<ll>ans(s.size() + 1, 0);
	for (ll i = 0; i < s.size();++i) {
		if (s[i] == '<') {
			ans[i + 1] = max(ans[i + 1], ans[i] + 1);
		}
	}
	for (ll i = s.size() - 1;i >= 0;--i) {
		if (s[i] == '>') {
			ans[i] = max(ans[i], ans[i + 1] + 1);
		}
	}
	ll sum = 0;
	for (ll i = 0; i < s.size() + 1;++i)sum += ans[i];
	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 4740
#include <iostream>
using namespace std;
typedef long long int lli;

int main() {
  lli N, A, B;
  cin >> N >> A >> B;
  lli X[N];
  for (int i=0; i<N; i++) {
    cin >> X[i];
  }
  lli ans=0;
  for (int i=0; i<N-1; i++) {
    ans+=min(B,A*(X[i+1]-X[i]));
  }
  cout << ans << endl;
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int[] dg = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int d = dg[0];
        long g = dg[1];
        long[] p = new long[d];
        long[] c = new long[d];
        for (int i = 0; i < d; i++)
        {
            long[] pc = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            p[i] = pc[0];
            c[i] = pc[1];
        }
        long res = 1 << 18;
        for (int bit = 0; bit < (1 << d); bit++)
        {
            long sum = 0;
            long num = 0;
            for (int i = 0; i < d; i++)
            {
                if ((bit & (1 << i)) > 0)
                {
                    sum += c[i] + p[i] * 100 * (i + 1);
                    num += p[i];
                }
            }

            if (g <= sum) res = Math.Min(res, num);
            else
            {
                for (int i = d - 1; 0 <= i; i--)
                {
                    if ((bit & (1 << i)) > 0) continue;
                    for (int j = 0; j < p[i]; j++)
                    {
                        if (g <= sum) break;
                        sum += 100 * (i + 1);
                        num++;
                    }
                }
                res = Math.Min(res, num);
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13396
N = int(input())
flg = False
w = input()
l = [w]
for i in range(1, N):
  w = input()
  if w not in l and w[0] == l[-1][-1]:
    l.append(w)
    flg = True
  else:
    flg = False
    break
if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
def swap(arr,i,j):
    arr1 = arr[:]
    arr1[i],arr1[j] = arr1[j],arr1[i]

    return arr1

def increasing(arr):
    for i in range(len(arr)-1):
        if arr[i+1] <= arr[i]:
            return False

    return True

def main():
    n = int(input())
    arr = list(map(int,input().split()))
    if increasing(arr):
        print('YES')
        return

    for i in range(n):
        for j in range(n):
            arr1 = swap(arr,i,j)
            if increasing(arr1):
                print('YES')
                return

    print('NO')

main()


Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let mut odd: i64 = 0;


    for i in 1..(n+1){
        if i % 2 == 1{
            odd += 1;
        }
    }

    println!("{}", odd as f64 / n as f64);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long K = long.Parse(str[1]);
		long ans = 1;
		if(N%K==0)
			ans = 0;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11220
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;

int s2i(string s){
	stringstream ss(s);
	int d;
	ss >> d;
	return d;
}

int main(){
	string s;
	double a, b, x;
	while (getline(cin, s)){
		stack<double>X;
		stringstream ss(s);
		while(ss>>s){
			if (s=="+"||s=="-"||s=="*"||s=="/"){
				b = X.top(); X.pop();
				a = X.top(); X.pop();
				if (s == "+") x = a + b;
				else if (s == "-") x = a - b;
				else if (s == "*") x = a * b;
				else if (s == "/") x = a / b;
				X.push(x);
			}
			else{
				X.push(s2i(s));
			}
		}
		printf("%.6f\n", X.top());
	}
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	ll a[105], b[105];
	ll ans = 0LL;
	for(int i=0;i<n-1;i++){
		cin >> b[i];
	}
	a[0] = b[0];
	a[n-1] = b[n-2];
	ans += a[0]+a[n-1];
	for(int i=1;i<n-1;i++){
		a[i] = min(b[i-1],b[i]);
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

//#include "D:\Code\C++\Headers\zle_STL.h"
//#include "D:\Code\C++\Headers\zle_OLD.h"

#define ll long long

using namespace std;

int main() {
	int N;
	cin >> N;
	int ans;
	for (int c = 0; ; c++) {
		if (1000 * c >= N) {
			cout << 1000 * c - N;
			return 0;
		}
	}
	
}


Measured memory_bytes: 3160
def func(x):
    if x == 0: return 0
    return func(x // 10) + (x % 10)


if __name__ == '__main__':
    n, a, b = map(int, input().split())

    i = 1
    ans = 0
    while i <= n:
        if a <= func(i) <= b:
            ans += i
        i += 1

    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,sx,sy,ex,ey;
    cin>>n>>m>>sx>>sy>>ex>>ey;
    sx--;sy--;ex--;ey--;
    deque<int> dx,dy;
    dx.push_front(sx);
    dy.push_front(sy);
    char ** a = new char * [n];
    int ** dist = new int * [n];
    for(int i=0;i<n;i++){
        a[i] = new char [m];
        dist[i] = new int [m];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            dist[i][j] = 10e8;
        }
    }
    int pos[][2] =  {{-1,0},{1,0},{0,-1},{0,1}};
    dist[sx][sy] = 0;
    while(!dx.empty()){
        int curx = dx.front();
        int cury = dy.front();
        
        dx.pop_front();dy.pop_front();
        int nx,ny;
        for(int i=0;i<4;i++){
            nx = curx + pos[i][0];
            ny = cury + pos[i][1];
            if(nx <0 || ny <0 || nx>=n || ny>=m || a[nx][ny] == '#'){
                continue;
            }
            if(dist[nx][ny] > dist[curx][cury]){
                dist[nx][ny] = dist[curx][cury];
                dx.push_front(nx);
                dy.push_front(ny);
            }
        }
        for(int i=curx-2;i<=curx+2;i++){
            for(int j= cury-2;j<=cury+2;j++){
                if(i <0 || j <0 || i>=n || j>=m || a[i][j] == '#'){
                    continue;
                }
                if(dist[i][j] > dist[curx][cury] + 1){
                    dist[i][j] = dist[curx][cury]+1;
                    dx.push_back(i);
                    dy.push_back(j);
                }
            }
        }
    }
    (dist[ex][ey] > 10e5)? cout<<"-1" : cout<<dist[ex][ey]; 
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  vector<ll> cards(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &cards[i]);
    sum += cards[i];
  }
  ll best = 1LL << 60;
  ll sum1 = cards[0];
  for (int i = 1; i < n; i++) {
    ll others = sum - sum1;
    best = min(best, abs(sum1 - others));
    sum1 += cards[i];
  }
  printf("%lld\n", best);
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  int cnt = 0;
  char s[5];
  while ((s[cnt++] = fgetc(stdin)) != '\n')
    ;
  cnt--;
  if (cnt == 2) {
    printf("%c%c\n", s[0], s[1]);
  } else {
    printf("%c%c%c\n", s[2], s[1], s[0]);
  }
  
  return 0;
}


Measured memory_bytes: 128
#N = int(input())
#A = [int(x) for x in input().split()]
#a, b, c = map(int, input().split())
#name1 = str(input())
#alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
a, b, c = map(str, input().split())
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-03 20:18:22
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

template<class _Tp>
std::map<_Tp, int> prime_fact(_Tp n){
  std::map<_Tp, int> result;
  for (_Tp i = 2; i * i <= n; ++i){
    if (n % i != 0) continue;
    int cnt = 0;
    while (n % i == 0){
      n /= i; ++cnt;
    }
    result[i] = cnt;
  }
  if (n != 1) result[n] = 1;
  return result;
}

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


  int64 x; cin >> x;

  map<int64, int> mp = prime_fact(x);

  for (int64 i = 0; i <= 5000; ++i) {
    for (int64 j = -5000; j <= 5000; ++j) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j << endl; return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	int i,j,sam;
	
	i=0;
	j=0;
	sam=0;
	
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			sam=i*j;
			printf("%dx%d=%d\n",i,j,sam);
		}
	}
	return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <cstdio>
#define N 505
using namespace std;

int n, g, num, c[N], s[N], f[N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i < n; i++) {
		scanf ("%d %d %d", &c[i], &s[i], &f[i]);
	}
	g = 0;
	for (i = 1; i < n; i++) {
		g = 0;
		for (j = i; j < n; j++) {
			if (g < s[j]) {
				g = s[j];
//				num = (s[] - g) / f[j];
//				if ((s[j] - g) % f[j]) num++;
//				g += num * f[j];
			} else if ((g - s[j]) % f[j] > 0){
				g += f[j] - ((g - s[j]) % f[j]);
			}
			g += c[j];
		}
		printf("%d\n", g);
	}
	cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2e5 + 5, INF = 1e9 + 5;
int a[N], b[N], ans[N];
vector<int> g[N];

void dfs(int node, int anc) {
    int x = lower_bound(b, b + N, a[node]) - b,
        y = b[x];

    b[x] = min(b[x], a[node]);

    ans[node] = lower_bound(b, b + N, INF) - b - 1;

    for (int to : g[node]) {
        if (to != anc) {
            dfs(to, node);
        }
    }

    b[x] = y;
}

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

    int n;
    cin >> n;

    fill(b, b + N, INF);
    b[0] = 0;

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

    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0, -1);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 31276
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto S = new string[](N);
    foreach (i; 0 .. N)
        S[i] = sread();

    long ans;
    outer: foreach (i; 0 .. N)
    {
        foreach (j; 0 .. N)
            foreach (k; 0 .. N)
            {
                if (S[(j + i) % N][k] != S[(k + i) % N][j])
                {
                    // writefln("%s %s %s %s %s", i, j, k, S[(j + i) % N][k], S[k][(j + i) % N]);
                    continue outer;
                }
            }
        ans += N;
    }
    writeln(ans);
}


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

signed main(){
	
	int n,W;
	cin>>n>>W;
	int wt[n];
	int val[n];
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	
	int dp[n+1][W+1] = {0}; // value at this condition.
	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			if(i == 0 || j== 0){
				dp[i][j] = 0;
			}
			else{
				if(j >= wt[i-1]){
					dp[i][j] = max(dp[i-1][j],val[i-1] + dp[i-1][j-wt[i-1]]);
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}
			
		}
	}

	cout<<dp[n][W]<<"\n";
}

Measured memory_bytes: 82548
#include "math.h"
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli memo[1000][1000] = {};
lli comb(lli n, lli r)
{
    if (memo[n][r] != -1)
        return memo[n][r];
    if (r == 0 || n == r)
        return 1;
    else
        return memo[n][r] = comb(n - 1, r) + comb(n - 1, r - 1);
}
lli po(int n)
{
    lli ans = 1;
    rep(i, n) ans *= 2;
    return ans;
}
int main()
{
    lli n, p;
    cin >> n >> p;
    rep(i, 1000) rep(j, 1000) memo[i][j] = -1;
    int a, e = 0, o = 0;
    rep(i, n)
    {
        cin >> a;
        if (a & 1)
            o++;
        else
            e++;
    }
    lli ans = 0;
    lli s1 = 0, s2 = 0;
    if (p & 1) {
        for (int i = 1; i <= o; i += 2) {
            s1 += comb(o, i);
        }
    } else {
        for (int i = 0; i <= o; i += 2) {
            s2 += comb(o, i);
        }
    }
    cout << po(e) * (s1 + s2) << endl;
}


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

const int N=100100;
int n,ans;
vector<int>g[N];

int dfs(int x,int fa=-1){
	int ret=0,res=0;
	for(int i:g[x])if(i!=fa){
		int u=dfs(i,x);
		res|=ret&u;ret|=u;
	}
	int now=(res?32-__builtin_clz(res):0);
	now+=__builtin_ctz((ret>>now)+1);
	ans=max(ans,now);ret&=~((1<<now)-1);
	ret|=1<<now;return ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	dfs(1);
	cout<<ans<<'\n';
	return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long lint;

lint dp[20][2][2];

lint calc(lint N) {
	memset(dp, 0, sizeof(dp));
	
	lint div = 1;
	for_(i,0,18) div *= 10;
	
	dp[19][0][0] = 1;
	
	for_rev(i,19,1) {
		lint d = (N / div) % 10;
		
		for_(j,0,2) for_(k,0,2) {
			if (dp[i][j][k] == 0) continue;
			
			for_(a,0,10) {
				if (j == 0 && d < a) continue;
				int nj = (j == 1 || d > a) ? 1 : 0;
				int nk = (k == 1 || a == 4 || a == 6) ? 1 : 0;
				dp[i - 1][nj][nk] += dp[i][j][k];
			}
		}
		
		div /= 10;
	}
	
	return dp[0][1][1];
}

void solve(lint n) {
	lint lb = 1, ub = (lint)1e15;
	
	while (ub - lb > 1) {
		lint med = (ub + lb) / 2;
		lint c = calc(med);
		
		if (med - c > n) ub = med;
		else lb = med;
	}
	
	cout << lb << endl;
}

int main() {
	int n;
	while (cin >> n, n) solve(n);
}

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

int main() {
  string s,t;
  cin>>s>>t;

  int ans = 1000;
  int n = s.size();
  int m = t.size();
  int l = n-m;

  for(int i=0; i<=l; i++) {
    int count = 0;
    for(int j=0; j<m; j++) {
      if(s[i+j]!=t[j]) count++;
    }
    ans = min(ans, count);
  }

  cout<<ans<<endl;

  return 0;
}

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

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

    for(int i=1; i<=n; i++){
        if(i%3 == 0){
            cout << " " << i;
        }
        else{
            int num=i;
            while(num>1){
                if(num%10 == 3){
                    cout << " " << i;
                    break;
                }
                num/=10;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
    char S[4];
    int count = 0;

    scanf("%s", S);

    if(S[0] == 'R') {
        count++;
        if(S[1] == 'R') {
            count++;
            if(S[2] == 'R') {
                count++;
            }
        }
    } else if(S[1] == 'R') {
        count++;
        if(S[2] == 'R') {
            count++;
        }
    } else if(S[2] == 'R') {
        count++;
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int n;cin >> n;
    string s;
    cin >> s;

    int ct = 0;
    rep(i,sz(s)-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ct++;
    }

    cout << ct << endl;

}

Measured memory_bytes: 256