akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
#define PI 3.1415926535
using namespace std;
vector<long long> vertexs[200000];
long long dp[2][200000] = {};
long long solve(long long now, long long back) {
	long long na = 0;
	long long mew = 0;
	long long tere = 0;
	for (int i = 0;i < vertexs[now].size();++i) {
		if (vertexs[now][i] != back) {
			solve(vertexs[now][i], now);
			na += dp[1][vertexs[now][i]];
			tere++;
			mew = max(mew, dp[1][vertexs[now][i]] - dp[0][vertexs[now][i]]);
		}
	}
	dp[0][now] = na - mew;
	if (tere >= 2) {
		dp[1][now] = dp[0][now];
	}
	else if(tere == 0){
		dp[1][now] = 1;
	}
	else {
		dp[1][now] = na;
	}
return 0;
}
int main() {
#define int long long
	int n;
	cin >> n;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	for (int i = 0;i < 200000;++i) {
		dp[0][i] = LONG_INF;
		dp[1][i] = LONG_INF;
	}
	int now_itr = 0;
	int maximum = 0;
	for (int i = 0;i < n;++i) {
		if (maximum < vertexs[i].size()) {
			maximum = vertexs[i].size();
			now_itr = i;
		}
	}
	solve(now_itr, -1);
	cout << max(1LL, dp[0][now_itr]) << endl;
	return 0;
}


Measured memory_bytes: 18944
#include <cstdio>

int main() {
    int a,b;
    char op;
    while(1) {
        scanf("%d %c %d", &a,&op,&b);
        int res;
        if(op=='+') {
            res=a+b;
            printf("%d\n",res);
        }
        else if(op=='-') {
            res=a-b;
            printf("%d\n",res);
        }
        else if(op=='*') {
            res=a*b;
            printf("%d\n",res);
        }
        else if(op=='/') {
            res=a/b;
            printf("%d\n",res);
        } else break;
    }
}


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

int main(){

    int N,K;
    cin>>N>>K;
    string S;
    cin>>S;
    if(S.at(K-1)=='A'){S.at(K-1)='a';}
    else if(S.at(K-1)=='B'){S.at(K-1)='b';}
    else if(S.at(K-1)=='C'){S.at(K-1)='c';}
    cout << S << endl;

}

Measured memory_bytes: 256
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
    if i !=minj:
        c+=1
    A[i],A[minj] = A[minj],A[i]
print(*A)
print(c)

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
    int k,a,b,f=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0){
            f=1;
            break;
        }
        else
            f=0;
    }
    if(f==1) cout<<"OK";
    else cout<<"NG";
   return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int dp[81][81][162*81];


int main(){
    int h,w;cin >> h >> w;
    vector<vector<int>> a(h,vector<int> (w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> b(h,vector<int> (w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> b[i][j];
        }
    }
    queue<pair<P,int>> q;
    q.push(mp(mp(0,0),abs(a[0][0]-b[0][0])));
    while(!q.empty()){
        auto qq = q.front();q.pop();
        int x = qq.first.second, y = qq.first.first;
        int c = qq.second;
        //cout << x << " " << y << " " << c << endl;
        if(dp[y][x][c]) continue;
        dp[y][x][c] = true;
        for (int i = 0; i < 2; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h){
                int nc = abs(c+abs(a[ny][nx] - b[ny][nx]));
                q.push(mp(mp(ny,nx),nc));
                nc = abs(c-abs(a[ny][nx] - b[ny][nx]));
                q.push(mp(mp(ny,nx),nc));
            }
        }
    }

    for (int i = 0; i < 162*81; i++) {
        if(dp[h-1][w-1][i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 357548
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());
            double area = r * r * Math.PI;
            double circumference = 2.0 * r * Math.PI;
            Console.WriteLine(area.ToString("F6") + " " + circumference.ToString("F6"));
        }
    }
}

Measured memory_bytes: 9276
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N, M, C = I()
que = []
B = l()
A = []
for i in range(N):
    a = l()
    A.append(a)

count = 0
for i in range(N):
    ans = 0
    for j in range(M):
        ans += A[i][j]*B[j]
    ans += C
    if ans > 0:
        count += 1

print(count)


Measured memory_bytes: 9984
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 110;

char s[N];

int main() {
  int n, k;
  scanf("%s%d", s + 1, &k);
  n = strlen(s + 1);
  if (count(s + 1, s + n + 1, s[1]) == n)
    printf("%lld\n", n * (ll)k / 2);
  else {
    ll ans = 0;
    if (s[1] != s[n]) {
      char c = s[1];
      int cnt = 1;
      for (int i = 2; i <= n + 1; ++i)
        if (c == s[i])
          ++cnt;
        else {
          ans += cnt / 2LL * k;
          cnt = 1;
          c = s[i];
        }
    } else {
      int l = 1, r = n;
      while (s[l] == s[1]) ++l;
      while (s[r] == s[n]) --r;
      char c = s[l];
      int cnt = 1;
      for (int i = l + 1; i <= r + 1; ++i)
        if (c == s[i])
          ++cnt;
        else {
          ans += cnt / 2LL * k;
          cnt = 1;
          c = s[i];
        }
      ans += (l - 1 + n - r) / 2LL * (k - 1);
      ans += (l - 1) / 2;
      ans += (n - r) / 2;
    }
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k; cin >> n >> k;
	
	ll ans = 0;	
	rep(i, k, n+1){
		ans += (2*n-i+1)*i/2-(i-1)*i/2+1;
		ans %= MOD;
	}
	print(ans)
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int dp[11][200001];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int d, g;
  cin >> d >> g;
  g /= 100;
  vint p(d), c(d);
  rep(i, d) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }
  fill(dp[0], dp[11], inf);
  dp[0][0] = 0;
  int sum = 0;
  rep(i, d) {
    rep(j, p[i]+1) {
      rep(k, sum+1) {
	chmin(dp[i+1][k+(i+1)*j+(j==p[i]?c[i]:0)], dp[i][k]+j);
      }
    }
    sum += p[i]*(i+1)+c[i];
  }
  int ans = inf;
  reps(i, g, sum+1) chmin(ans, dp[d][i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17536
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

signed main(){
    int N; ll A, B;
    cin >> N >> A >> B;
    vector<ll> hs;
    rep(N){
        ll h;
        cin >> h;
        hs.push_back(h);
    }

    ll max_h = *max_element(all(hs));
    //ll min_ans = (max_h+A-1) / A, max_ans = (max_h+B-1) / B;
    ll min_ans = 1, max_ans = (max_h+B-1) / B;
    ll ans;
    while(min_ans < max_ans){
        ans = (max_ans + min_ans) / 2;
        ll check = 0;
        rep(N){
            if(hs[i] <= B*ans) continue;
            ll diff = A - B;
            check += (hs[i] - B*ans + diff - 1) / diff;
        }
        if(check <= ans){
            max_ans = ans;
        }else{
            min_ans = ans + 1;
        }
    }
    cout << min_ans;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.size()-1; i++) {
		if (S[i] != S[i + 1]) {
			ans++;
		}
	}

	cout << ans;

}	




Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int a,b,c,d,e,f;
    while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
        double y=(double)(c*d-a*f)/(double)(b*d-a*e);
        if(a!=0)
        printf("%.3f %.3f\n",(c-b*y)/a,y);
        else
        printf("%.3f %.3f\n",(f-e*y)/d,y);
    }
}


Measured memory_bytes: 2572
#include<bits/stdc++.h>
#define add(i,j) (i+j>=1000000007)?(i+=j-1000000007):(i+=j)
using namespace std;
int f[3010][3010][2];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for (int i=0;i<=n;i++) f[0][i][0]=1;
	for (int i=0;i<m;i++)
	for (int j=0;j<=n;j++)
	for (int k=0;k<=1;k++)
	{
		if (j==0)
		{
			add(f[i+1][j+1][1],f[i][j][k]);
			add(f[i+1][j][1],f[i][j][k]);
		}
		else if (j==1)
		{
			add(f[i+1][j][1],f[i][j][k]);
			add(f[i+1][j-1][1],f[i][j][k]);
			if (j!=n)
			{
				add(f[i+1][j][k],f[i][j][k]);
				add(f[i+1][j+1][k],f[i][j][k]);
			}
		}
		else if (j==n)
		{
			add(f[i+1][j][k],f[i][j][k]);
			add(f[i+1][j-1][k],f[i][j][k]);
		}
		else
		{
			add(f[i+1][j][k],f[i][j][k]);
			add(f[i+1][j-1][k],f[i][j][k]);
			add(f[i+1][j][k],f[i][j][k]);
			add(f[i+1][j+1][k],f[i][j][k]);
		}
	}
	int sum=0;
	for (int i=0;i<=n;i++) add(sum,f[m][i][1]);
	cout<<sum<<endl;
}

Measured memory_bytes: 70784
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
int arr[int(1e5+10)];
int cnt[int(1e5+10)];
int dp(int n,int k)
{
  if(n<=0)return int(1e9);
  if(cnt[n]!=-1)return cnt[n];
  int ans=INF;
  for(int i=1;i<=k;++i)
  {
    if(n>i)
    ans=min(ans,abs(arr[n-i]-arr[n])+dp(n-i,k));
  } 
  return cnt[n]=ans;
}
int main()
{  
  fast
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;++i)cin>>arr[i];
  memset(cnt,-1,sizeof(cnt));
  cnt[1]=0;
  cout<<dp(n,k);
  
  

}

Measured memory_bytes: 7296
#include<stdio.h>

int main(){
  int count[30], result[30];
  char s[100]="\0";
  scanf("%s", &s);

  for(int j=0; j<30; j++)
    count[j]=0;

  for(int i=0; i<100; i++){
    for(int j=0; j<26; j++){
      if(s[i]=='a'+j){
        count[j]++;
        break;
      }
    }
  }

  for(int j=0; j<26; j++){
    if((count[j]%2)!=0){
      printf("No\n");
      return 0;
      break;
    }
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 1660
N = int(input())
A =list(map(int,input().split()))

tmp=0
sum_list = [0]
for i in range(N):
    tmp +=A[i]
    sum_list.append(tmp)

#print(sum_list)

diff =9999999999999
for i in range(1,N):
    diff = min(diff , abs( sum_list[-1]-2*sum_list[i]  ))

print(diff)

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

int main(){
	int x, y;
	for(int i=0; i >= 0; i++){
	cin >> x >> y;
	if(x==0 && y==0)break;
	if(x<y) cout << x << " " << y << "\n";
	else cout << y << " " << x << "\n";
	
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000

LL arr[MAX];


int main() {


	LL n, ans, i;
	cin>>n;

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

	ans = arr[0];
	for(i = 1 ; i < n ; i++) ans = ans ^ arr[i];

	for(i = 0 ; i < n ; i++) cout<<(ans ^ arr[i]) << " ";

	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 5132
#include<iostream>
main(){
	for (int n,x,i,j,k,c;c=0,std::cin>>n>>x,n||x;){
		for(i=1;i<n;++i)
		for(j=i;j<n;++j)
		if(j-i)
		for(k=j;k<n;++k,(k-j&&k-i)?(i+j+k==x?++c:0):0);
		std::cout<<c<<"\n";
	}
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  char x, y;
  cin >> x >> y;

  if (x == y) cout << '=' << "\n";
  else if (x < y) cout << '<' << "\n";
  else cout << '>' << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int diff = A - 2*B;
    
    if(diff > 0){
      System.out.println(diff);
    } else {
      System.out.println(0);
    }
  }

}

Measured memory_bytes: 25300
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np


def main():
	n,t=map(int,input().split())
	T=list(map(int,input().split()))
	T=np.array(T)
	diff=T[1:]-T[:-1]
	time1=diff[diff<=t]
	time2=len(diff[diff>t])*t
	print(time1.sum()+time2+t)



if __name__ == "__main__":
	main()


Measured memory_bytes: 30928
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int n,tw;
vector<pair<int,int> > c(0);
vector<int> val(10001,-1);

int search(int i){
  //if(i<0) return -1;
  if(i==0) return 0;
  if(val[i]>=0) return val[i];
  int max=0;
  for(int k=0;k<c.size();k++){
    if(i-c[k].second<0 || c[k].second > i) continue;
    int can=search(i-c[k].second)+c[k].first;
    if( max < can ){
      max=can;
    }
  }
  val[i]=max;
  return max;
}

int main(void){
  int x,y;
  cin>>n>>tw;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    c.push_back(make_pair(x,y));
  }

  val[0]=0;
  for(int i=1;i<val.size();i++){
    search(i);

  }
  int max=0;
  for(int i=0;i<tw+1;i++){
    //cout << val[i] << " " ;
    if(max < val[i]) max=val[i];
  }
  //cout << endl;
  cout << max << endl;
  //cout << val[tw] << endl;


  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

vector<string> vec;
int n,m;

// n<23
int sol1(string s="", int x = 0){
  if(x==n){
    rep(i,m) if(s[i]=='1') return -INF;
    return 0;
  }
  if(x==0){
    s = string(m,'0');
  }
  int ret = sol1(s, x+1);

  // use
  rep(i,m){
    if(s[i]==vec[x][i]) s[i]='0';
    else s[i]='1';
  }
  ret = max(ret, sol1(s, x+1) + 1);

  return ret;
}

// m<23
int sol2(){
  using B = bitset<500>;
  vector<B> v(n);
  rep(i,n){
    rep(j,m) v[i][j] = vec[i][j]-'0';
  }

  unordered_map<B,int> ma;
  ma[B(0)] = 0;
  rep(i,n){
    auto nm = ma;
    for(auto x : ma){
      nm[x.fi^v[i]] = max(nm[x.fi^v[i]], x.se+1);
    }
    swap(nm, ma);
  }
  return ma[B(0)];
}

int main(){
  while(cin>>n>>m, n|m){
    vec.clear();
    vec.resize(n);
    rep(i,n) cin>>vec[i];

    // if(n<=10 && m<=10){
    //   int r1 = sol1();
    //   int r2 = sol2();
    //   assert(r1==r2);
    //   cout << r1 << endl;
    // }
    // else if(n<23){
    //   cout << sol1() << endl;
    // }
    // else if(m<23){
      cout << sol2() << endl;
    // }
    // else assert(n*m<=500);
  }

  return 0;
}

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

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	sort(A.rbegin(), A.rend());
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		if(int m = (ok + ng) / 2; [&](){
			int64_t c = 0;
			rep(i, N){
				int d = (A[i] - 1) / m;
				if(d == 0) break;
				c += d;
			}
			return c <= K;
		}()) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, Q;
//---------------------------------------------------------------------------------------------------
int op(int a, int b) {
	return max(a, b);
}
int e() {
	return -1;
}
int tmp;
bool f(int x) {
	return x < tmp;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q;
	vector<int> v(N);
	rep(i, 0, N) cin >> v[i];
	segtree<int, op, e> st(v);
	rep(q, 0, Q) {
		int t, a, b; cin >> t >> a >> b;
		if (t == 1) st.set(a - 1, b);
		else if (t == 2) {
			int ans = st.prod(a - 1, b);
			printf("%d\n", ans);
		}
		else {
			tmp = b;
			int ans = st.max_right<f>(a - 1) + 1;
			printf("%d\n", ans);
		}
	}
}







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

int 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)){
        printf("%d\n", a - b);
    } else 
        printf("%d\n", a * b);

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

count = 0
A.step(B) do |x|
  count += 1 if x.to_s == x.to_s.reverse
end

puts count


Measured memory_bytes: 14372
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double x = sc.nextInt();
		double max = a * a * b;
		if (x == max / 2) {
		    System.out.println(45.0);
		} else if (x > max / 2) {
		    double target = max - x;
		    double c = target * 2 / a / a;
		    System.out.println(Math.atan2(c, a) * 180d / Math.PI);
		} else {
		    double c = x * 2 / a / b;
		    System.out.println(90 - Math.atan2(c, b) * 180d / Math.PI);
		}
	}
}


Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
N, K, S = map(int,input().split())
ans = []
for i in range(K):
    ans.append(S)
if S < 10**9:
    for i in range(N-K):
        ans.append(10**9)
else:
    for i in range(N - K):
        ans.append(1)
for i in range(N):
    ans[i] = str(ans[i])
print(" ".join(ans))

Measured memory_bytes: 66864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  char str[222];
  scanf("%s", str);
  int n = strlen(str);
  for (int i = n - 2; i; i -= 2)
  {
    if (strncmp(str, str + i / 2, i / 2) == 0)
    {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int pre,l=0,ans=0;
    rep(i,n){
        int h;
        cin>>h;
        if(i==0){
            pre=h;
            l=0;
            continue;
        }
        if(h>pre){
            chmax(ans,int(i-l));
            l=i;
        }
        pre=h;
    }
    chmax(ans,n-l);
    cout<<ans-1<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        mut n: usize,
    }
    let alphabet: Vec<char> = (97..97+26).map(|x| std::char::from_u32(x).unwrap()).collect();;

    let mut ans = String::new();

    while n != 0 {
        n -= 1;
        ans.push(alphabet[n % 26]);
        n /= 26;
    }

    println!("{}", ans.chars().rev().collect::<String>())
}


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

int a[100010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	long ans = -1;
	bool flag = false;
	int now, pre = a[n-1];
	for(int i = n - 2; i >= 0; i--) {
		now = a[i];
		if(pre == now) {
			ans *= now;
			if(flag) break;
			flag = true;
			i--;
			pre = a[i];
		}else{
			pre = now;
		}
	}
	printf("%ld\n", (ans == -1) ? 0 : -ans);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

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

    int a[210000];
    for (int i = 1; i < n; i++)
    {
        cin >> a[i];
    }
    
    vector<int> cnt(n);
    for (int i = 1; i < n; i++)
    {
        cnt[a[i]-1]++;
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << cnt[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4840
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
#define lson (x << 1)
#define rson ((x << 1) | 1)
#define mid ((l + r) >> 1)
using namespace std;
typedef long long LL;

LL n,m,k;
LL a[500005],b[500005];
LL vis[500005] = {0};
LL cnt[500005] = {0};

LL cnn[800005],cid[800005],tot[800005],mii[800005];

void pushup(LL x){
	cnn[x] = max(cnn[lson],cnn[rson]);
	if(cnn[lson] > cnn[rson]) cid[x] = cid[lson];
	else cid[x] = cid[rson];
	
	tot[x] = tot[lson] + tot[rson];
	if(tot[lson]) mii[x] = mii[lson];
	else mii[x] = mii[rson];
}

void build(LL x,LL l,LL r){
	if(l == r){
		cnn[x] = cnt[l];
		cid[x] = l;
		tot[x] = 1;
		mii[x] = l;
		return;
	}
	build(lson,l,mid);
	build(rson,mid + 1,r);
	pushup(x);
}

LL getmin(LL x,LL l,LL r,LL L,LL R){
	if(L > R) return n + 1;
	if(L <= l && r <= R) return mii[x];
	LL ret = n + 1;
	if(L <= mid) ret = min(ret,getmin(lson,l,mid,L,R));
	if(R > mid) ret = min(ret,getmin(rson,mid + 1,r,L,R));
	return ret;
}

LL getmax(){
	return cid[1];
}

void modify(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L <= l && r <= R){
		cnn[x] --;
		return;
	}
	if(L <= mid) modify(lson,l,mid,L,R,v);
	if(R > mid) modify(rson,mid + 1,r,L,R,v);
	pushup(x);
}

void modify2(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L <= l && r <= R){
		tot[x] --;
		mii[x] = n + 1;
		cnn[x] = -1;
		cid[x] = n + 1;
		return;
	}
	if(L <= mid) modify2(lson,l,mid,L,R,v);
	if(R > mid) modify2(rson,mid + 1,r,L,R,v);
	pushup(x);
}

LL judge(){
	memset(cnt,0,sizeof(cnt));
	for(LL i = 1;i <= n;i ++) cnt[b[i]] ++;
	for(LL i = 1;i <= n;i ++){
		if(cnt[i] != 1) return 0;
		if(b[i + 1] == a[b[i]]) return 0;
	}
}

LL u[3],dfv[3] = {0};

void dfs2(LL x){
	if(x > n){
		if(judge()){
			for(LL i = 1;i <= n;i ++) cout << b[i] << (i == n ? '\n' : ' ');
			exit(0);
		}
		else return;
	}
	for(LL i = 0;i < 3;i ++){
		if(dfv[i]) continue;
		dfv[i] = 1;
		b[x] = u[i];
		dfs2(x + 1);
		dfv[i] = 0;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++) cnt[a[i]] ++;
	build(1,1,n);
	
	if(n <= 2){
		cout << -1 << endl;
		return 0;
	}
	
	LL nxt = -1,id;
	for(LL i = 1;i <= n - 3;i ++){
//		cout << getmax() << ' ' << cnt[getmax()] << ' ' << n - i << endl;
		if(cnt[getmax()] == n - i){
			id = getmax();
			nxt = a[id]; b[i] = id; cnt[a[b[i]]] --;
			modify(1,1,n,a[b[i]],a[b[i]],-1);
			modify2(1,1,n,id,id,-1);
		}
		else{
			id = getmin(1,1,n,1,n);
			if(id == nxt) id = getmin(1,1,n,id + 1,n);
			nxt = a[id];
			b[i] = id; cnt[a[b[i]]] --;
			modify(1,1,n,a[b[i]],a[b[i]],-1);
			modify2(1,1,n,id,id,-1);
		}
	}
	
	u[0] = u[1] = u[2] = -1;
	for(LL i = 1;i <= n - 3;i ++) vis[b[i]] = 1;
	for(LL i = 1;i <= n;i ++){
		if(!vis[i]){
			if(u[0] == -1) u[0] = i;
			else if(u[1] == -1) u[1] = i;
			else u[2] = i;
		}
	}
	
	dfs2(n - 2);
	
	return 0;
}

Measured memory_bytes: 29568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A < 10 && B < 10){
			System.out.println(A * B);
		}else{
			System.out.println(-1);			
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>

using namespace std;

int main () {

    string a, b;

    cin >> a >> b;

    // this could be a big integer question, i'm not prepared for that so just do whatever. 

    int aL = a.size();
    int bL = b.size();


    if (aL > bL) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (bL > aL){
        cout << "LESS" << endl;
        return 0;
    }
    else {
        for (int i = 0; i < a.size(); i++){
            int bi = b[i] - '0';
            int ai = a[i] - '0';

            if (ai > bi) {
                cout << "GREATER" << endl;
                return 0;

            } 
            else if (bi > ai) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }

    cout << "EQUAL" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input())
    a_l = [int(i) for i in input().split()]
    if 1 not in a_l:
        print(-1)
        sys.exit()
    counter = 1
    b = 0
    for i in a_l:
        if i == counter:
            counter += 1
        else:
            b += 1
    print(b)
    sys.exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 72012
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>

#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



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

  ll N,M; cin>>N>>M;
  dsu uf(N);
  rep(i,M){
    ll x,y,z; cin>>x>>y>>z; x--; y--;
    uf.merge(x,y);
  }
  
  cout<<uf.groups().size()<<'\n';
  
  return 0;
}


Measured memory_bytes: 9736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int G[205][205];
int in[205]={0};
int out[205]={0};
int vis[205]={0};
int v[205]={0};
int n;
int flag=1;
void dfs(int u,int value){
    //cout << u << endl;
    for(int i=1;i<=n;i++){
        //.//cout << u << i << endl;
        if(G[u][i]==1){
            if(!vis[i]){
              //  cout << i <<endl;
                v[i]=value^1;
                vis[i]=1;
                dfs(i,value^1);
            }
            else{
              //  cout << u << i << endl;
                if(v[u]^v[i]==0){
                    flag=0;
                }
            }
        }
    }
}
char s[205];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%s",s);
        for(int j=1;j<=n;j++){
            G[i][j]=s[j-1]-'0';
        }
    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++){
//            cout << G[i][j] << " \n"[j==n];
//        }
//    }
    v[1]=0;
    vis[1]=1;
    dfs(1,0);
    if(flag==0){
        printf("-1\n");
        return 0;
    }
    for(int i=1;i<=n;i++) {
            for(int j=1;j<=n;j++) {
                if(i==j) {    //顶点本身
                    G[i][j]=0;
                }
                else {    //无穷
                    if(G[i][j]==0)
                    G[i][j]=99999;
                }
            }
        }
    for(int k=1;k<=n;k++) {    //只允许经过顶点k
            for(int i=1;i<=n;i++) {
                for(int j=1;j<=n;j++) {
                    if(G[i][k]+G[k][j]<G[i][j]) {
                        G[i][j]=G[i][k]+G[k][j];
                    }
                }
            }
        }
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(G[i][j]<1000){
                ans=max(ans,G[i][j]);
            }
        }
    }
    printf("%d\n",ans+1);
    //cout << flag << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#include<utility>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

pair<int, int> a[100000];


int main() {
  int m,n;
  cin >> n >> m;
  REP(i,m) {
    cin >> a[i].second >> a[i].first;
    if(a[i].second > a[i].first) {
      int tmp = a[i].second;
      a[i].second = a[i].first;
      a[i].first = tmp;
    }
  }

  sort(a, a+m);

  int ans = 1;
  int tmp = a[0].first;
  REP(i,m) {
    if(tmp <= a[i].second) {
      tmp = a[i].first;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int suma[]=new int[N+1];
		int sumz[]=new int[N+1];
		int z=0,y=0,x=0,v=0;int i=0;int j=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<N-1){
			y=A[z]-A[z+1];
			x=A[N-1-z]-A[N-2-z];
			if(y<0)
				y*=-1;
			if(x<0)
				x*=-1;
			i+=y;j+=x;
			suma[z+2]=i;
			sumz[N-2-z]=j;
			z++;
		}z=0;
		while(z<N){
			if(z!=0&&z!=N-1){
				v=A[z-1]-A[z+1];
				if(v<0)
					v*=-1;
			}
			int go=A[0];int back=A[N-1];
			if(z==0)
				go=A[1];
			if(z==N-1)
				back=A[N-2];
			if(go<0)
				go*=-1;
			if(back<0)
				back*=-1;
			System.out.println(suma[z+2-2]+v+sumz[z+1]+go+back);
			z++;v=0;
		}
	}
}

Measured memory_bytes: 63712
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long gcd(long a,long b){
  long v0=a,v1=b,v2=a%b;
  while(v2!=0){
    v0=v1;
    v1=v2;
    v2=v0%v1;
  }
  return v1;
}

int main(){
  int N;
  cin>>N;
  vector<long>A;
  long tmp;
  for(int i=0;i<N;++i){
    cin>>tmp;
    A.push_back(tmp);
  }
  vector<long>L,R;
  for(int i=0;i<N;++i){
    if(i==0){
      L.push_back(A[i]);
      R.push_back(A[N-i-1]);
    }
    else{
      L.push_back(gcd(L[i-1],A[i]));
      R.push_back(gcd(R[i-1],A[N-i-1]));
    }
  }
  int ans=1;
  for(int i=0;i<N;++i){
    if(i==0){
      ans=R[N-(i+1)-1];
    }
    else if(i<N-1){
      if(ans<gcd(L[i-1],R[N-i-2]))ans=gcd(L[i-1],R[N-i-2]);
    }
    else{
      if(ans<L[N-2])ans=L[N-2];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int k;
    string s;
    cin >> k >> s;
    int n = s.length();
    if(n <= k){
        cout << s << endl;
    }else{
        s = s.substr(0, k);
        cout << s << "...\n";
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;
class Main {
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int a = scanner.nextInt();
  int b = scanner.nextInt();
  int c = scanner.nextInt();
  int[] numbers = {a, b, c};
  int temp;
  for (int i = 0; i < numbers.length - 1; i++) {
      for(int j = numbers.length - 1; j > i; j--){
          if(numbers[j -1] > numbers[j]){
              temp = numbers[j -1];
              numbers[j-1] = numbers[j];
              numbers[j] = temp;
          }
      }
  }
  System.out.println(numbers[0] + " " + numbers[1] + " " + numbers[2]);
  }
}

Measured memory_bytes: 25972
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int D, T, S;

  cin >> D >> T >> S;
  if( T*S >= D){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

int main(){
ll N;cin >> N;

rep(i, 0, N){

  cout << "ACL";

}


}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <(n); i++)
#define rep2(i,l,r) for (int i=(l); i<(r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

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;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
    //~ if (!bit) break;
//~ }
int next_combination(int sub){
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
//~ bool isPrime(int a){
  //~ if(a==2) return true;
  //~ if(a<=1 || a%2==0) return false;
  
  //~ for(int i=3; i*i<=a; i+=2){
    //~ if(a%i==0) return false;
  //~ }
  //~ return true;
//~ }
vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (a[index] >= key) return true;
    else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];

ll MOD = 1e9 + 7;

ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n>0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    
    ll ans = 0;
    
    ans = modpow(10, N, MOD) - modpow(9, N, MOD) - modpow(9, N, MOD) + modpow(8, N, MOD);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
string s;
set<int> idx[26];

int main() {
    fastio();

    int q;
    cin >> n >> s >> q;

    forn(i, s.size()) {
        idx[s[i] - 'a'].insert(i);
    }

    while (q--) {
        int x;
        cin >> x;
        if (x == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;

            idx[s[i] - 'a'].erase(i);
            idx[c - 'a'].insert(i);
            s[i] = c;
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;

            int cnt = 0;
            forn(c, 26) {
                auto it = idx[c].lower_bound(l);
                if (it != idx[c].end()) {
                    if (*it <= r) cnt++;
                }
            }

            cout << cnt << "\n";
        }
    }

    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++) if (n%i == 0) return false;
    return true;
}
signed main()
{   
    gearup;
    int num = 100010;
    vector<int> a(num,0);
    for(int i=3;i<num;i+=2){
        if(is_prime(i) && is_prime((i+1)/2)){
            a[i] = 1;
        }
    }
    //累積わ
    vector<ll> s(num,0);
    rep(i,num) s[i+1] = a[i] + s[i];

    int q; cin >> q;
    rep(i,q){
        int l,r; cin >> l >> r; //l <= x <= rの範囲
        cout << s[r+1]-s[l] << endl;
    }
}

Measured memory_bytes: 1792