akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
	int a, b; cin >> a >> b;
	vector<vector<long long>>che(b, vector<long long>(2));
	vector<vector<long long>>stu(a, vector<long long>(2));
	for (int i = 0; i < a; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			cin >> stu[i][j];
		}
	}
	for (int i = 0; i < b; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			cin >> che[i][j];
		}
	}
	int c = 0;
	for (int i = 0; i < a; ++i)
	{
		int mn = 100000000000;
		for (int j = 0; j< b; ++j)
		{
			int sum = 0;
			for (int k = 0; k < 2; ++k)
			{
				sum += abs(stu[i][k] - che[j][k]);
			}
			if (mn > sum){
				mn = sum;
				c = j + 1;
	         	}
		}
		cout << c << endl;
	}
	
}

Measured memory_bytes: 3172
N = int(input())
grid = [list(map(int, input().split())) for _ in range(N-1)]
C = [c[0] for c in grid]
S = [s[1] for s in grid]
F = [f[2] for f in grid]

T = []
for n in range(N):
    t = 0
    for i in range(n, N-1):
        if S[i] >= t:
            d = S[i] - t + C[i]
        else:
            temp = (t - S[i])%F[i]
            if temp == 0:
                d = C[i]
            else:
                d = F[i] - temp + C[i]
        t += d
    T.append(t)

for t in T:
    print(t)

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

int main() {
    int n;
    int max_num = 0;
    int max_at = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        if(max_num < a.at(i)){
            max_num = a.at(i);
            max_at = i;
        }
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < n; i++){
        if(i != max_at){
            cout << max_num << endl;
        }else{
            cout << a.at(n-2) << endl;
        }
    }
}


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,ans=0;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        ans+=a-1;
    }
    cout << ans << endl;
    return 0;
}


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

#define int int64_t

const int64_t inf = 1e18;

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, m, l, q;
	cin >> n >> m >> l;
	vector < vector < int64_t > > g(n + 1, vector < int64_t > (n + 1, inf));
	vector < vector < int > > p(n + 1, vector < int >(n + 1, -1));
	for (int i = 0; i < m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		if (w <= l) {
			g[u][v] = w;
			p[u][v] = u;
			g[v][u] = w;
			p[v][u] = v;
		}
	}
	for (int i = 0; i <= n; ++i)
		g[i][i] = 0;
	for (int k = 0; k <= n; ++k) {
		for (int i = 0; i <= n; ++i) {
			for (int j = 0; j <= n; ++j) {
				if (g[i][j] > g[i][k] + g[k][j]) {
					g[i][j] = g[i][k] + g[k][j];
					p[i][j] = p[k][j];
				}
			}
		}
	}
	vector < vector < int > > d(n + 1, vector < int > (n + 1, inf));
	for (int i = 0; i <= n; ++i)
		d[i][i] = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (g[i][j] <= l)
				d[i][j] = 1;
		}
	}
	for (int k = 0; k <= n; ++k) {
		for (int i = 0; i <= n; ++i) {
			for (int j = 0; j <= n; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		}
	}
	cin >> q;
	for (int j = 0; j < q; ++j) {
		int s, t;
		cin >> s >> t;
		if (d[s][t] == inf)
			cout << "-1\n";
		else
			cout << d[s][t] - 1 << '\n';
	}
}


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

int main(void){
  int N,M;
  cin >> N >> M;

  //高い金額から順に取り出す
  priority_queue<long long> prices;

  //pricesに値段を記録していく．
  for(int i = 0; i < N; ++i){
    long long A;
    cin >> A;
    prices.push(A);
  }

  //割引券の使用(高いものから順に適応していく)
  while(M--){
    long long price = prices.top(); prices.pop();
    //割引券の利用
    price /= 2;

    //割引した後も割引券は使えるので割引後の値段を挿入
    prices.push(price);
  }

  //値段の合計
  long long sum = 0ll;
  while(!prices.empty()){
    sum += prices.top(); prices.pop();
  }

  //出力
  cout << sum << endl;
}


Measured memory_bytes: 1400
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    counter = defaultdict(int)
    for a in A:
        counter[a] += 1
    counter = sorted(counter.items(), key=lambda x: x[1])
    ans = 0
    for i in range(len(counter)-K):
        ans += counter[i][1]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 39532
#include<bits/stdc++.h>
using namespace std;
int n;
int dp[100005],num[100005];
int main() {
	cin.tie(),cout.tie();
	memset(dp,23333,sizeof(dp));
	cin>>n;
	for (int i=1;i<=n;i++) cin>>num[i];
	dp[0]=0;
	dp[1]=0;
	dp[2]=fabs(num[2]-num[1]);
	for (int i=3;i<=n;i++) {
		for (int j=i-2;j<=i-1;j++) {
			int add=fabs(num[i]-num[j]);
			dp[i]=min(dp[i],dp[j]+add);
		}
//		cout<<i<<':'<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
	return 0;
} 

Measured memory_bytes: 1024
import Data.List

f::String->String
f [] ="Yes"
f (x:xs)=if not (x `elem` ['0'..'9']) then "No" else f xs

main = do
       e1<-getLine
       e2<-getLine
       let (a:b:[])=map read (words e1)::[Int]
       putStrLn $ if e2!!a=='-' then f (delete '-' e2) else "No"

Measured memory_bytes: 508
from itertools import combinations
from collections import defaultdict
n = int(input())


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for p in range(2, int(n**.5)+1):
        if res[p] < p:
            continue
        for q in range(p**2, n, p):
            if res[q] == q:
                res[q] = p
    return res


U = 100
min_factor = sieve(U)


def prime_factor(n):
    res = defaultdict(int)
    while 1 < n:
        res[min_factor[n]] += 1
        n //= min_factor[n]
    return res


cnt = defaultdict(int)
for i in range(1, n+1):
    for k, v in prime_factor(i).items():
        cnt[k] += v

facts = cnt.keys()
ans = 0
# 3,5,5
for subset in combinations(facts, 3):
    for i in range(3):
        can_be = 1
        for j, prim in enumerate(subset):
            if i == j:
                if cnt[prim] < 2:
                    can_be = 0
                    break
            else:
                if cnt[prim] < 4:
                    can_be = 0
                    break
        if can_be:
            ans += 1

# 15,5 3,25
for subset in combinations(facts, 2):
    for i in range(2):
        can_be = 1
        for j, prim in enumerate(subset):
            if i == j:
                if cnt[prim] < 4:
                    can_be = 0
                    break
            else:
                if cnt[prim] < 14:
                    can_be = 0
                    break
        if can_be:
            ans += 1

        can_be2 = 1
        for j, prim in enumerate(subset):
            if i == j:
                if cnt[prim] < 2:
                    can_be2 = 0
                    break
            else:
                if cnt[prim] < 24:
                    can_be2 = 0
                    break
        if can_be2:
            ans += 1

# 74個の場合
if 74 <= cnt[2]:
    ans += 1

print(ans)


Measured memory_bytes: 9644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    bool G[N][N];
    if(N % 2 == 1) {
        rep(i, N) {
            rep(j, N) {
                G[i][j] = false;
                if(i != j && j != N - i - 2)
                    G[i][j] = true;
            }
        }
    }else {
        rep(i, N) {
            rep(j, N) {
                G[i][j] = false;
                if(j != i && j != N - i - 1)
                    G[i][j] = true;
            }
        }
    }
    int cnt = 0;
    rep(i, N) {
        rng(j, i + 1, N) {
            if(G[i][j]) ++cnt;
        }
    }
    cout << cnt << endl;
    rep(i, N) {
        rng(j, i + 1, N) {
            if(G[i][j]) cout << i + 1 << ' ' << j + 1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define MAX_N 100001
typedef long long ll;
using namespace std;

const int DAT_SIZE = (1<<18)-1;

int n,q;
int A[MAX_N];

ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r){
    if(a<=l&&r<=b){
        data[k]+=x;
    }
    else if(l<b&&a<r){
        datb[k]+=(min(b,r)-max(a,l))*x;
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
    }
}

ll sum(int a,int b,int k,int l,int r){
    if(b<=l||r<=a){
        return 0;
    }
    else if(a<=l&&r<=b){
        return data[k]*(r-l)+datb[k];
    }
    else{
        ll res=(min(b,r)-max(a,l))*data[k];
        res+=sum(a,b,k*2+1,l,(l+r)/2);
        res+=sum(a,b,k*2+2,(l+r)/2,r);
        return res;
    }
}
int main(){
    int m,l,r,ans,sumv[MAX_N]={};
    vector<int> v[MAX_N];
    scanf("%d %d",&m,&n);
    for(int i=0;i<m;i++){
        scanf("%d %d",&l,&r);
        v[r-l+1].push_back(l);
    }
    for(int i=n;i>=1;i--){
        sumv[i]=sumv[i+1]+v[i].size();
    }
    for(int i=1;i<=n;i++){
        ans=sumv[i];
        for(int j=i;j<=n;j+=i){
            ans+=sum(j,j+1,0,0,n+1);
        }
        for(int j=0;j<v[i].size();j++){
            add(v[i][j],v[i][j]+i,1,0,0,n+1);
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000000000;

int main() {
  ll N, M, R;
  cin >> N >> M >> R;
  ll r[R];
  for (ll i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  
  ll d[N][N];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (i == j) {d[i][j] = 0;}
      else {d[i][j] = INF;}
    }
  }
  
  
  for (ll i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c; d[b][a] = c;
  }
  
  for (ll k = 0; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  
  ll D[R][R];
  
  for (ll i = 0; i < R; i++) {
    for (ll j = 0; j < R; j++) {
    D[i][j]= d[r[i]][r[j]];
    }
  }
  
  vector<int> v;
  for (ll i = 0; i < R; i++) {v.push_back(i);}
  
  ll ans = INF;
  do {
    ll p = 0;
    for (ll i = 0; i < R-1; i++) {
      p += D[v[i]][v[i+1]];
    }
    ans = min(p, ans);
  } while (next_permutation(v.begin(), v.end())); 
  
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

int A,B,K;
using namespace std;


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

    cin >> A >> B >> K;
    for(int i = 0; i < K; i++){
        if(i%2 == 0){
            if(A%2 == 1){
                A -= 1;
            }
            A /= 2;
            B += A;

        }else{
            if(B%2 == 1){
                B -= 1;
            }
            B /= 2;
            A += B;
        }
    }
    cout << A <<endl;
    cout << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    ll n, s, mod = 998244353;
    cin >> n >> s;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll dp[n + 1][s + 1][3] = {};
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j][0] = dp[i][j][0];
            dp[i + 1][j][1] = dp[i][j][0] + dp[i][j][1];
            dp[i + 1][j][2] = dp[i][j][0] + dp[i][j][1] + dp[i][j][2];
            dp[i + 1][j][1] %= mod;
            dp[i + 1][j][2] %= mod;
            if (j >= a[i]) {
                dp[i + 1][j][1] += dp[i][j - a[i]][0] + dp[i][j - a[i]][1];
                dp[i + 1][j][2] += dp[i][j - a[i]][0] + dp[i][j - a[i]][1];
                dp[i + 1][j][1] %= mod;
                dp[i + 1][j][2] %= mod;
            }
        }
    }

    cout << dp[n][s][2] << endl;
}


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

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

        final Map<String, Integer> cnt = new HashMap<>();
        {
            cnt.put("SUN", 7);
            cnt.put("MON", 6);
            cnt.put("TUE", 5);
            cnt.put("WED", 4);
            cnt.put("THU", 3);
            cnt.put("FRI", 2);
            cnt.put("SAT", 1);
        };


        String s = in.next();
        out.println(cnt.get(s));

        in.close();
        out.close();
    }
    static class Pair {
	  		public long first;
	  		public long second;

	  		public Pair() {
	  			this(0, 0);
	  		}

	  		public Pair(final long first, final long second) {
	  			this.first = first;
	  			this.second = second;
	  		}
	  	}
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  if(a%c==0){
    cout<<(b/c-a/c)+1;

  }
  else{
   cout<<(b/c-a/c)<<endl;
  }


}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: i64,
        y: i64,
    };
    for a in 0..=100 {
        for b in 0..=100 {
            if (a + b == x) && (a * 2 + b * 4 == y) {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <random>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a[7];
  rep(i,7)cin >> a[i];
  ll ans=a[1];
  
  ans+=2*(a[0]/2)+2*(a[3]/2)+2*(a[4]/2);
  if(a[0]%2==1 && a[3]%2==1 && a[4]%2==1){
    ans+=3;
  }
  else if(a[0]>0 && a[0]%2==0 && a[3]%2==1 && a[4]%2==1){
    ans++;
  }
  else if(a[0]%2==1 && a[3]>0 && a[3]%2==0 && a[4]%2==1){
    ans++;
  }
  else if(a[0]%2==1 && a[4]>0 && a[4]%2==0 && a[3]%2==1){
    ans++;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int S; cin >> S;
  int X1=0,Y1=0;
  int X2=1000000000;
  int Y2=1;
  int Y3=(S+1000000000-1)/1000000000;
  int X3=1000000000*Y3-S;
  cout << X1 << " "<< Y1 << " "<< X2 << " "<< Y2 << " "<< X3 << " "<< Y3 << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from math import sin
from math import cos
from math import sqrt
pi=math.pi

a,b,h,m=map(int,input().split())
angh=pi*(60*h+m)/360
angm=pi*m/30

hx=a*cos(angh)
hy=a*sin(angh)
mx=b*cos(angm)
my=b*sin(angm)

d=sqrt((hx-mx)**2+(hy-my)**2)
print(d)

Measured memory_bytes: 9552
N = int(input())
S = input()
ans = 0
for a in range(1, N):
    cnt = 0
    for i in range(N - a):
        if S[i + a] == S[i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, a))
print(ans)


Measured memory_bytes: 73624
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

L, R, d = map(int, input().split())
ans = 0
for i in range(L, R+1):
	if i%d ==0:
		ans+=1
print(ans)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9160
#include <stdio.h>
#include <math.h>
struct XX{
  double x;
  double y;
};
  void kock(int n,struct XX p1,struct XX p2){
    struct XX s,t,u;
    if(n==0) return;

    s.x=(2*p1.x+p2.x)/3;
    s.y=(2*p1.y+p2.y)/3;

    t.x=(p1.x+2*p2.x)/3;
    t.y=(p1.y+2*p2.y)/3;

    u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
    u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

    kock(n-1, p1, s);
    printf("%.8f %.8f\n",s.x,s.y);
    kock(n-1, s, u);
    printf("%.8f %.8f\n",u.x,u.y);
    kock(n-1, u, t);
    printf("%.8f %.8f\n",t.x,t.y);
    kock(n-1, t, p2);



  }
int main(){
  int n;
  struct XX p1,p2;
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char a[11],b[11],c[11];
	scanf("%s %s",a,b);
	int A,B;
	scanf("%d %d",&A,&B);
	scanf("%s",c);
	if(!strcmp(a,c))
	A--;
	else
	B--;
	cout<< A << " " << B <<endl; 
	
	
	
	
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n,m,t[200],base = 0;

	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> t[i];
	    base += t[i];
	}
	
	cin >> m;
	for(int i = 0; i < m;i++){
    	int  p,x;
    	cin >> p >> x;
    	
    	cout << base-t[p-1]+x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
int main()
{
    std::string S;
    long long K;
    std::cin >> S;
    std::cin >> K;

    int ans = 1;
    for (long long i = 0; i < S.length(); i++) {
        if (S[i] != '1') {
            ans = std::stoi(S.substr(i, 1));
            break;
        }

        if (i >= K-1) {
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

ll get_digit(ll m)
{
    ll idx = 0;

    while (m > 0) {
        m /= 10;
        idx++;
    }
    return idx;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = get_digit(n);
    for (ll a = 1ll; a * a <= n; ++a) {
        if (n % a != 0) {
            continue;
        }
        const ll b = n / a;
        const ll cur = max(get_digit(a), get_digit(b));
        ans = min(ans, cur);
    }

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

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


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

  // if(s[k] == 'A') s[k] = 'a';
  // if(s[k] == 'B') s[k] = 'b';
  // if(s[k] == 'C') s[k] = 'c';
  s[k] += 32;

  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3616
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << n * (n - 1) / 2 << '\n';
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int R,W,c,r;
    while(cin >> R >> W >> c >> r,c){
        double now=(double)R/W;
        int res=0;
        if(now>=c){
            res=0;
        }else{
            while(1){
                R+=r;
                res++;
//                cout << R << endl;
                if(R/W>=c)break;
            }
        }
        cout << res << endl;
    }
}



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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

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

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(): x(0) {}
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

vector<ll> v;
ll dp[200005][3];
ll ninf = -0x3f3f3f3f3f3f3f3fll;

int main() {
    // cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; cin >> n;
    v = vector<ll>(n);

    rep(i, 0, n) cin >> v[i];
    
    rep(i, 0, n) rep(j, 0, 3) dp[i][j] = ninf;

    if (n % 2 == 0) {
        dp[0][0] = ninf;
        dp[0][1] = v[0];
        dp[1][0] = v[1];
        dp[1][1] = ninf;

        rep(i, 2, n) {
            dp[i][0] = v[i] + max(dp[i - 2][0], i - 3 >= 0 ? dp[i - 3][1] : ninf);
            dp[i][1] = v[i] + dp[i - 2][1];
        }
    
        cout << max(dp[n - 1][0], dp[n - 2][1]) << endl;
    } else if (n % 2 == 1) {
        dp[0][0] = dp[0][1] = ninf; dp[0][2] = v[0];
        dp[1][0] = dp[1][2] = ninf; dp[1][1] = v[1];
        dp[2][1] = ninf; dp[2][2] = v[0] + v[2]; dp[2][0] = v[2];

        rep(i, 3, n) {
            dp[i][0] = v[i] + max(dp[i - 2][0], max(
                i - 3 >= 0 ? dp[i - 3][1] : ninf, i - 4 >= 0 ? dp[i - 4][2] : ninf));
            dp[i][1] = v[i] + max(dp[i - 2][1], i - 3 >= 0 ? dp[i - 3][2] : ninf);
            dp[i][2] = v[i] + dp[i - 2][2];
        }

        // printf("%4c%23lld%23lld%23lld\n", ' ', 0ll, 1ll, 2ll);

        // rep(i, 0, n) {
        //     printf("%3d:%23lld%23lld%23lld\n", i, dp[i][0], dp[i][1], dp[i][2]);
        // }

        cout << max(dp[n - 1][0], max(dp[n - 2][1], dp[n - 3][2])) << endl;
    }
}

Measured memory_bytes: 9528
import os, sys, re, math

N = int(input())
A = [int(n) for n in input().split()]

A = sorted(A)
for i in range(N - 1):
    if A[i] + A[i + 1] < 0:
        A[i] *= -1
        A[i + 1] *= -1

print(sum(A))


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  rep(i,s.size()){
    t+='x';
  }

  cout << t << endl;
  
  return 0;
}


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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
  int N,X,m=0,ans=1;
  cin >> N >> X;
  REP(i,N){
    int tmp;
    cin >> tmp;
    m+=tmp;
    if(m <= X)
      ans++;
    else break;
  }
  cout << ans << endl;
}



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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
const ll INF = 1e18L + 5;
const ll MOD = 1e9 + 7;
const int nax = 1e5 + 5;


int main(){
	int n;
	cin >> n;
	set<int> possible;
	for(int i = 1; i <= 9; ++i) {
		for(int j = 1; j <= 9; ++j) {
			possible.insert(i*j);
		}
	}
	if(possible.find(n) != possible.end()) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

 


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

const int INF = 100000000;

int main() {
	int N;
	cin >> N;
	int a[N],b[N], c[N];
	
	for(int i=0; i<N;i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	
 	vector<vector<int>> dp(N,vector<int>(3, 0));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for(int i=1; i <N ; i++) {
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
	}
	int aa = dp[N-1][0];
	int bb = dp[N-1][1];
	int cc = dp[N-1][2];
	int ans = max(aa,bb);
	ans = max(ans,cc);
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll k;
  cin>>k;
  while(k){
    if(a<b)break;
    b*=2;
    k--;
  }
  while(k){
    if(b<c)break;
    c*=2;
    k--;
  }
  if(a<b&&b<c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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); }



int n;
vector<ll> a;

const int MAX_COL = 63;
const int MAX_ROW = 100005;



struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }
};

BitMatrix mat(100005, 61);

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // cout << bitset<61>(1008288677408720767) << endl;
    
    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];
    
    
    
    rep(i, n) rep(j, 61) {
        if (a[i] & (1LL << j)) {
            mat[i][60 - j] = 1;
        } else mat[i][60 - j] = 0;
    }
    
    // rep(i, n) { rep(j, 60) cout << mat[i][j] << " "; cout << endl; }
    
    // たてのbit数える
    ll ans = 0;
    rep(j, 61) {
        int cnt = 0;
        rep(i, n) {
            // if (mat[i][j] & (1LL << (59 - j))) cnt++; // mat[i][j]は1, 0 -> 1LL << とかやばい
            if (mat[i][j] == 1) cnt++;
        }
        // cout << j << " " << cnt << endl;
        if (cnt % 2) {
            ans += (1LL << (60 - j));
            rep(i, n) mat[i][j] = 0;
        }
    }
    // cout << "ans " << ans << endl;
    // cout << endl; rep(i, n) { rep(j, 60) cout << mat[i][j] << " "; cout << endl; }
    
    GaussJordan(mat);
    // cout << endl; rep(i, n) { rep(j, 60) cout << mat[i][j] << " "; cout << endl; }
    
    // int r = 0;
    rep(j, 61) {
        int cnt = 0;
        rep(i, n) {
            if (mat[i][j] == 1) cnt++;
            /*
            if (mat[i][j] == 1 && r == i) {
                // cout << i << " " << j << " " << ans << endl;
                ans += (2LL << (59 - j));
                r++;
            }
             */
        }
        if (cnt % 2) ans += (2LL << (60 - j));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  rep(i,0,n)cin >> d[i];
  l = d[0];
  short up = 0;
  ll ans = 1;
  rep(i,1,n){
    if(up == 0){
      if(l < d[i])up = 1;
      else if(l > d[i])up = -1;
    }else if(up == 1){
      if(l > d[i]){
        ans++;
        up = 0;
      }
    }else{
      if(l < d[i]){
        ans++;
        up = 0;
      }
    }
    l = d[i];
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main ( void ){
int K ;
cin >> K ;
 
int a [] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
 
1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << a [ K -1] << endl ;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin>>n;
	V<int>a(n);
	REP(i,0,n)cin>>a[i];
	SO(a);
	cout<<a[a.size()-1]-a[0];
    return 0;
}


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

int main(){
	int n,i,p,q;
  cin>>n;
  int arr[n];
  int sum[n];
  for(i=0;i<n;i++)
    cin>>arr[i];
  sum[0]=0;
  sum[1]=abs(arr[0]-arr[1]);
  
  for(i=2;i<n;i++){
  	p=(sum[i-1]+abs(arr[i-1]-arr[i]));
    q=(sum[i-2]+abs(arr[i-2]-arr[i]));
    sum[i]=min(p,q);
  }
  cout<<sum[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	long long n, v[200000];
	long long ans = 0, ans1 = 0, ans2 = 0;
	cin >> n;
	ans = n * (n + 1) / 2;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		ans1 += v[i];
	}
	ans2 = ans1 - ans;
	cout << ans2 << endl;
	return 0;
}


Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] C = new int[N - 1];
        int [] S = new int[N - 1];
        int [] F = new int[N - 1];
        for (int i = 0 ; i < N - 1 ; i++) {
            C[i] = sc.nextInt();
            S[i] = sc.nextInt();
            F[i] = sc.nextInt();
        }
        for (int i = 0 ; i < N - 1 ; i++) {
            int t = 0;
            for (int j = i ; j < N - 1; j++) {
                if (t < S[j]) {
                    t = S[j];
                    t += C[j];
                } else {
                    while (t % F[j] != 0) {
                        t++;
                    }
                    t += C[j];
                }
            }
            System.out.println(t);
        }
        System.out.println(0);

    }

}

Measured memory_bytes: 26740
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var AB = Enumerable.Range(0, M).Select(i => ReadLine().Split(' ')).Select(s => (A: int.Parse(s[0]) - 1, B: int.Parse(s[1]) - 1)).ToArray();

        var uf = new UnionFind(N);

        foreach (var (A, B) in AB)
            uf.Unite(A, B);

        var ans = Enumerable.Range(0, N).Select(i => uf.Size(i)).Max();

        WriteLine(ans);
    }
}
class UnionFind
{
    private int[] d;
    public UnionFind(int n) => d = Enumerable.Repeat(-1, n).ToArray();
    public int Find(int x) => (d[x] < 0) ? x : d[x] = Find(d[x]);
    public bool Unite(int x, int y)
    {
        (x, y) = (Find(x), Find(y));
        if (x == y)
            return false;
        if (d[x] > d[y])
            (x, y) = (y, x);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    public bool Same(int x, int y) => Find(x) == Find(y);
    public int Size(int x) => -d[Find(x)];
}


Measured memory_bytes: 43876
//#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))

#define fi first
#define sc second 
#define pb push_back


#ifdef DEBUG
    #define dbg(s) {s;}
    #define PRELUDE
#endif

#ifndef DEBUG 
    #define PRELUDE { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define dbg(s)
    #define endl "\n"
#endif

using namespace std;


#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

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

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

inline ld rf() { // from [0, 1]
    return uniform_real_distribution<ld>(0, 1)(rng);
}

ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 998244353;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

int slv[maxn];
vector < int > past;

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);
    
    PRELUDE;
    
    int n; cin >> n;
    int t = 1; while (n % 2 == 0) { n /= 2; t *= 2; }
    // orig = n * t
    string s; cin >> s;
    string z;

    int res = 0;

    for (int x = 1; x <= n; x++) {
        if (n % x) continue;
        int y = x * t; // n * t / y is odd
        int& ans = slv[x];
        ans = 0;
        for (int a : past) {
            if (x % a == 0) ans = (ans - slv[a] * x / a + mod) % mod;
        }
        past.pb(x); 

        int ca = y + y;
        
        if (x < n) {
            z = s;
            for (int j = y; j < n * t; j++) {
                z[j] = (z[j - y] - '0')^1 + '0';
            }
            bool leq = true;
            for (int j = 0; j < n * t; j++) if (z[j] < s[j]) break; else if (z[j] > s[j]) { leq = false; break; }
            
            if (!leq) ans = (ans - ca + mod) % mod;
        }
        int c = 0;
        for (int j = 0; j < y; j++) { c <<= 1; c ^= s[j] - '0'; c %= mod; }
        c++; 
        ans = (ans + c * ca) % mod;
        res = (res + ans) % mod;

    }
    
    cout << res % mod << endl;
}





Measured memory_bytes: 1036
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
using namespace std;

bool isliner(char c1, char c2)
{
  if (c1 == '(' && c2 == ')' || c1 == ')' && c2 == '(' || (c1 != '(' && c1 != ')' && c1 == c2))
    return true;
  return false;
}

int main()
{
  string s;
  while (cin >> s) {
    int ans = 0;

    for (int l = 0, r = s.size()-1; l <= r; ++l, --r) {
      if (!isliner(s[l], s[r]))
	++ans;
    }

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

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

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define SQR(x)              ((x)*(x))
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************

/// Constants
#define MAX                 200005
#define MOD                 1000000007
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f // 4,557,430,888,798,830,399
#define inf                 0x3f3f3f3f // 1,061,109,567
#define PI                  acos(-1.0)  // 3.1415926535897932
#define VT                  int

int n;
pair<int, int> ar[MAX];
map<int, int> mp;

int solve(){
    vector<pii> v;
    FOR(i, 0, n){
        auto pos = lower_bound(all(v), ar[i]);
        if(pos == v.end()) v.pb(ar[i]);
        else v[pos - v.begin()] = ar[i];
    }
    return sz(v);
}

int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    si(n);
    FOR(i, 0, n){
        int x; si(x);
        ar[i] = {x, mp[x]++};
    }
    reverse(ar, ar+n);
    FOR(i, 0, n){
        ar[i] = {ar[i].ff, mp[ar[i].ff] - ar[i].ss};
    }
    printf("%d\n", solve());

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}

Measured memory_bytes: 6780