akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
mat mt;
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1000000007;
ld epi = 0.00000001;
ll cas=0;

void solve(){
    cin>>n;
    vct v(n);
    F(i,n)cin>>v[i];

    vct pre(n),suf(n);
    ll gc=v[0];
    pre[0]=gc;
    for(i=1;i<n;i++){
        gc=__gcd(gc,v[i]);
        pre[i]=gc;
    }

    gc=v[n-1];
    suf[n-1]=gc;
    for(i=n-2;i>=0;i--){
        gc=__gcd(gc,v[i]);
        suf[i]=gc;
    }

    ans=1;
    F(i,n){
        if(i==0)ans=max(ans,suf[i+1]);
        else if(i==(n-1))ans=max(ans,pre[i-1]);
        else ans=max(ans,__gcd(pre[i-1],suf[i+1]));
    }
    prn(ans);    
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout<<fixed<<setprecision(10);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 

Measured memory_bytes: 5580
N=int(input())
A=list(map(int,input().split()))
sA=set(A)
flg=0
if all([x==0 for x in A]):
    flg=1
elif len(sA)==2 and N%3==0:
    a,b=[A.count(x) for x in sA]
    if min(a,b)==N//3 and max(a,b)==N//3*2:
        flg=1
elif len(sA)==3 and N%3==0:
    a,b,c=[x for x in sA]

    if a^b^c==0 and  all([A.count(x)==N//3 for x in sA]):
        flg=1
print("Yes" if flg==1 else "No")


Measured memory_bytes: 61556
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> getContents >>= print . foldl lcm 1 . map ( read :: String -> Integer ) . lines


Measured memory_bytes: 1020
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
  int N, M; scanf("%d%d", &N, &M);
  static long long dp[1001][8];
  for(int pat = 0; pat < 8; ++pat) dp[0][pat] = 0;
  for(int i = 0; i < N; ++i) {
    long long x, y, z; scanf("%lld%lld%lld", &x, &y, &z);
    for(int j = i; j >= 0; --j) {
      // fprintf(stderr, "i=%2d: dp[%2d] = {", i, j+1);
      for(int pat = 0; pat < 8; ++pat) {
        long long score = dp[j][pat] + x + y + z - (pat & 1) * x * 2 - ((pat >> 1) & 1) * y * 2 - ((pat >> 2) & 1) * z * 2;
        dp[j+1][pat] = j == i ? score : max(score, dp[j+1][pat]);
        // fprintf(stderr, "%4lld, ", dp[j+1][pat]);
      }
      // fprintf(stderr, "}\n");
    }
  }
  long long score = dp[M][0];
  for(int pat = 0; pat < 8; ++pat) score = max(score, dp[M][pat]);
  printf("%lld\n", score);
}


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

static const int MAX = 100;
static const int INFTY = (1 << 30);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int color[MAX];
int M[MAX][MAX];
int d[MAX];
int p[MAX];
int n;
int prim()
{
	int u, minv;
	for(int i=0; i<n; i++)
	{
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while(1)
	{
		minv = INFTY;
		u = -1;
		for(int i=0; i<n; i++)
		{
			if(minv > d[i] && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}

		if(u == -1) break;
		color[u] = BLACK;
		for(int v=0; v<n; v++)
		{
			if(color[v] != BLACK && M[u][v] != INFTY)
			{
				if(d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}

	int sum = 0;
	for(int i=0; i<n; i++)
	{
		if(p[i] != -1)
			sum += M[i][p[i]];
	}
	return sum;
}

int main()
{
	scanf("%d", &n);

	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			int e;
			scanf("%d", &e);
			M[i][j] = (e == -1) ? INFTY:e;
		}
	}

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

	return 0;
}




Measured memory_bytes: 2716
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, M = map(int, input().split())
A = [0] * M
dp = [-1] * (N+1)

for i in range(M):
    a = int(input())
    dp[a] = 0

dp[0] = 1
if dp[1] != 0:
    dp[1] = 1

for i in range(2, N+1):
    if dp[i] != 0:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])


Measured memory_bytes: 6900
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    static class Solve
    {
        public static void Answer()
        {
            var K = IO_ShortCut.ReadInt;
            var total = 0;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        total += GCD(GCD(i, j), k);
                    }
                }
            }
            WriteLine(total);
        }

        public static int GCD(int a, int b)
        {
            int gcd;
            while (true)
            {
                if (a == b)
                {
                    gcd = a;
                    break;
                }

                if (b > a)
                {
                    int tmp = b;
                    b = a;
                    a = tmp;
                }
                a -= b;
            }
            return gcd;
        }
    }

    static class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        #endregion
    }
}

Measured memory_bytes: 17636
#include <stdio.h>
  
#define PutChar(c) ; *p = (char)(c); ++p;
  
#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)
  
int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);
  
int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;
  
int main(void) {
    register int i;
    int n;
  
    fread(str, 1, STR_SIZE, stdin);
      
    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }
      
    CountingSort(A, B, MAX_Ai, n);
      
    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');
      
    puts(str);
      
    return 0;
}
  
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
  
void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}
  
void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = { 0 };
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Measured memory_bytes: 26660
//プロ技のテストって裏あったの！？
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<c-(d-b)<<' '<<d+(c-a)<<' '<<a-(d-b)<<' '<<b+(c-a)<<'\n';
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static double[][] dis;
    static double dp[][];
    static int n;
    static int g;
    static final double EPS = 1.0e-10;
    static int rs[];

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String tmp[] = sc.nextLine().split(" ");
            int l = Integer.parseInt(tmp[0]);
            rs = new int[tmp.length - 1];
            for (int i = 1; i < tmp.length; i++) {
                rs[i - 1] = Integer.parseInt(tmp[i]);
            }
            n = rs.length;
            dis = new double[n][n];
            dp = new double[1 << n][n];

            for (int i = 0; i < n; i++) {
                dis[i][i] = 0;
            }
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    dis[i][j] = dis[j][i] = 1.0 * Math.sqrt((rs[i] + rs[j])
                            * (rs[i] + rs[j]) - (rs[i] - rs[j])
                            * (rs[i] - rs[j]));
                }
            }
            boolean flag = false;
            for (int i = 0; i < n; i++) {
                for (int k = 0; k < 1 << n; k++) {
                    Arrays.fill(dp[k], -1);
                }
                double dis = tsp(1 << i, i);
                // System.out.println(dis + rs[i]);
                if (dis + rs[i] < l || Math.abs(l - (dis + rs[i])) < EPS) {
                    flag = true;
                    i = n;
                    break;
                }
            }
            System.out.println(flag ? "OK" : "NA");

        }
    }

    public static double tsp(int S, int v) { // S:既に訪れた頂点、v:現在いる頂点
        if (dp[S][v] >= 0) {
            return dp[S][v];
        }
        if (S == (1 << n) - 1) {
            return dp[S][v] = rs[v];
        }
        double res = Double.POSITIVE_INFINITY;
        for (int u = 0; u < n; u++) {
            if ((S & (1 << u)) == 0) {
                res = Math.min(res, tsp(S | 1 << u, u) + dis[v][u]);
            }
        }
        return dp[S][v] = res;
    }
}

Measured memory_bytes: 17000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int a[maxn];
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
	if(!a)return b;
	return a*b/gcd(a,b);
}
void solve()
{
	int n,m;scdd(n,m);
	int odd=0,even=0;
	rep1(i,n){
		scd(a[i]);
		a[i]/=2;
		if(a[i]&1)odd++;
		else even++;
	}
	if(odd&&even){
		printf("0");
		return ;
	}
	ll g=0;
	rep1(i,n){
		g=lcm(g,1ll*a[i]);
		if(g>m){
			printf("0");
			return ;
		}
	}
	rep1(i,n)if(g/a[i]%2==0){
		printf("0");
		return ;
	}
	int mark=m/g;
	if(mark&1)printf("%d",mark/2+1);
	else printf("%d",mark/2);
}
int main(){
    //IOS;
    solve();
    return 0;
}

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

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A + B >= C ? "Yes" : "No") << endl;

  return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    string s;
    cin >> s;
    int cc=0;

    for(auto c: s){
    	if(c=='2')
    		cc++;
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.exception;

enum letters = "LRUD";

enum dy = [0, 0, -1, 1];
enum dx = [-1, 1, 0, 0];
enum inf = int.max >> 1;

int f (dchar c) {
  foreach (i; 0 .. 4) {
    if (c == letters[i])  return i;
  }
  enforce (false);
  return -1;
}

struct S {
  int u;
  int v;
  int value;
}


bool first (in int[] s, in int[] t, in int[] d, in int u, in int m) {
  immutable x = s.map! (k => d[k]).array.idup;
  immutable y = t.map! (k => d[k]).array.idup;
  debug stderr.writeln ("s = ", s);
  debug stderr.writeln ("t = ", t);
  debug stderr.writeln ("x = ", x);
  debug stderr.writeln ("y = ", y);
  int r1 = 1, r2 = m + 1;
  assert (s.length == t.length);
  foreach_reverse (i; 0 .. s.length) {
    //step 2
    if (i < s.length - 1) {
      if (y[i] < 0) r2++;
      if (y[i] > 0) r1--;
      r1 = max (r1, 1);
      r2 = min (r2, m + 1);
    }
    debug stderr.writefln ("2: i = %d, r1 = %d, r2 = %d", i, r1, r2);
    //step 1
    if (x[i] < 0) r1++;
    if (x[i] > 0) r2--;
    r1 = max (r1, 1);
    r2 = min (r2, m + 1);
    debug stderr.writefln ("1: i = %d, r1 = %d, r2 = %d", i, r1, r2);
    if (r1 >= r2) return true;
  }
  r1 = max (r1, u);
  r2 = min (r2, u + 1);
  return r1 >= r2;
}

void main() {
  auto zz = readln.split.map!(a => a.to!int).array;
  immutable h = zz[0], w = zz[1], n = zz[2];
  zz = readln.split.map!(a => a.to!int).array;
  immutable y = zz[0], x = zz[1];
  auto s = readln.take(n).map!f.array.idup;
  auto t = readln.take(n).map!f.array.idup;
  writeln ((first (s, t, dx, x, w) || first (s, t, dy, y, h)) ? "NO" : "YES");
}



Measured memory_bytes: 11064
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i, N) cin >> S[i];
  sort(all(S));
  string ans = "";
  for (auto s : S) {
    ans += s;
  }

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

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll a1=a*c;
        ll res=max(a1,a*d);
        res=max(res,b*c);
        res=max(res,b*d);
        cout<<res;
    }

    return 0;
}

Measured memory_bytes: 3648
from itertools import accumulate
from bisect import bisect_right, bisect_left
# Kは読める時間。この時間を最大に使ってたくさん本を読みたい
N, M, K = map(int, input().split())

a_books = list(map(int, input().split()))
b_books = list(map(int, input().split()))
a_books = list(accumulate(a_books))
b_books = list(accumulate(b_books))
a_books.insert(0, 0)
b_books.insert(0, 0)
a_index = bisect_right(a_books, K)

# print(a_books)
# print(b_books)


max_nums = 0
for i in range(a_index):
    a_cost = a_books[i]
    remain_cost = K - a_cost
    if remain_cost < 0:
        continue
    j = bisect_right(b_books, remain_cost)
    # print(i, j)
    max_nums = max(max_nums, i + j - 1)
print(max_nums)


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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;




void solve(int z) {
    int a , b , c , k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k > a) ans += a , k -= a;
    else ans += k , k = 0 ;
    if(k > b)  k -= b;
    else k = 0 ;
    if(k > c) ans += -c , k -= c;
    else ans += -k , k = 0 ;
    cout << ans << '\n';
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



Measured memory_bytes: 3640
N, M, Q = map(int, input().split())
X = [[0 for _ in range(N+1)] for __ in range(N+1)]
for i in range(M):
  L, R = map(int, input().split())
  X[L][R] += 1
for i in range(N+1):
  for j in range(N):
    X[i][j+1] += X[i][j]
for i in range(N+1):
  for j in range(N):
    X[j+1][i] += X[j][i]
for i in range(Q):
  p, q = map(int, input().split())
  print(X[q][q] - X[p-1][q])

Measured memory_bytes: 74420
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 1005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#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 in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int a[12][MAX];
int sum[12][MAX];

int get_sum(int x1, int y1, int x2, int y2) {
	int s = sum[x2][y2];
	if(x1 - 1 >= 0) s -=  sum[x1-1][y2];
	if(y1 - 1>=0) s -= sum[x2][y1-1];
	
	if(x1-1>=0 && y1-1>=0) s += sum[x1-1][y1-1];
	return s;
}

void solve() {
	int n, m, x;
	in3(n, m, x);
	string s[n];
	for(int i=0;i<n;i++) {
		cin>>s[i];
		for(int j=0;j<m;j++) a[i][j] = (s[i][j]-'0');
	}
	
	//precompute
	MSV(sum, 0);
	sum[0][0] = a[0][0];
	for(int i=1;i<m;i++) sum[0][i] = sum[0][i-1] + a[0][i];
	for(int i=1;i<n;i++) sum[i][0] = sum[i-1][0] + a[i][0];
	
	for(int i=1;i<n;i++) {
		for(int j=1;j<m;j++) {
			sum[i][j] = a[i][j] + sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1];
		}
	}
		
	vector<int> h;
	for(int i=0;i<n-1;i++) h.PB(i);
	int sz = h.size();
	
	int mini = INT_MAX;
	for(int i=0;i<(1<<sz);i++) {
		vector<int> temp;
		temp.PB(-1);
		int ans = 0;
		for(int j=0;j<sz;j++) {
			if((1<<j) & i) {
				temp.PB(h[j]);
				ans++;
			}
		}
		temp.PB(n-1);
		
		bool f = true;
		int pc = 0;
		for(int j=0;j<m;j++) {
			bool match = true;
			for(int k=1;k<temp.size();k++) {
				int cnt = get_sum(temp[k-1]+1, pc, temp[k], j);
				if(cnt > x) {match = false; break;}
			}
			
			if(!match && pc == j) {f = false;break;}
			if(!match) {
				ans++;
				pc = j;
				j--;
			}
		}
		if(f) mini = min(mini, ans);
	}
	cout<<mini<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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


int main(){
    int x,y,z;
    int a,b,c;
    cin>>x>>y>>z;
    a=x; b=y; c=z;
    x=c; y=a; z=b;
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,ans=0;
 
ll n,k;
string s;

void input(void){
    cin>>s;
    cin>>k;
}
 
void solve(void){
    bool flag=false;
    vl a;
    n=s.length();
    if(s[0]==s[n-1])flag=true;
    c=1;
    rep(i,n-1){
        if(s[i]==s[i+1])c++;
        else{
            a.push_back(c);
            ans+=(c/2)*k;
            c=1;
        }
    }
    a.push_back(c);
    ans+=(c/2)*k;

    if(a.size()==1){
        ans=(k*s.size())/2;
    }
    else{
        if(flag){
            ans-=(a[0]/2+a.back()/2)*(k-1)-(a[0]+a.back())/2*(k-1);
        }
    }

    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

using namespace std;

const int N = 200000 + 7;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;

int main() {
  int m, k;
  scanf("%d %d", &m, &k);
  if(!(0 <= k && k < (1 << m))) {
    printf("-1\n");
    return 0;
  }
  if(m == 1 && k == 1) {
    puts("-1");
    return 0;
  }
  if(k == 0) {
    for(int i = 0; i < (1 << m); ++i) {
      if(i > 0) printf(" ");
      printf("%d %d", i, i);
    }
    puts("");
    return 0;
  }
  //vector<int> v = {0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7};
  //100 101 110
  vector<int> v; v.clear();
  for(int i = 0; i < (1 << m); ++i) {
    if(i != k)
    v.push_back(i);
  }
  v.push_back(k);
  for(int i = (1 << m) - 1; i >= 0; --i) {
    if(i != k)
    v.push_back(i);
  }
  v.push_back(k);
  for(int i = 0; i < v.size(); ++i) {
    if(i > 0) printf(" ");
    printf("%d", v[i]);
  }
  puts("");
  /*
  vector<int> c((1 << m) + 1, 0);
  for(int i = 0; i < v.size(); ++i) {
    for(int j = i + 1; j < v.size(); ++j) {
      if(v[i] == v[j]) {
        int res = 0;
        for(int l = i; l <= j; ++l) {
          res = res ^ v[l];
        }
        //cout << res << " ";
        c[res]++;
      }
    }
  }
  for(int i = 1; i < (1 << m); ++i) {
    if(c[i] == (1 << m)) {
      cout << i << endl;
      //for(int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl;
    }
  }
  */
  /*
  do {
    vector<int> c((1 << m) + 1, 0);
    for(int i = 0; i < v.size(); ++i) {
      for(int j = i + 1; j < v.size(); ++j) {
        if(v[i] == v[j]) {
          int res = 0;
          for(int l = i; l <= j; ++l) {
            res = res ^ v[l];
          }
          //cout << res << " ";
          c[res]++;
        }
      }
    }
    for(int i = 1; i < (1 << m); ++i) {
      if(c[i] == (1 << m) && i == (1 << m) - 2) {
        cout << i << endl;
        for(int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl;
      }
    }
  } while(next_permutation(v.begin(), v.end()));
  */
  return 0;
}


Measured memory_bytes: 2932
main :: IO ()
main = do
    n <- readLn
    putStrLn . show $ getMax n

getMax :: Int -> Int
getMax n =
    let
        m500 = n `div` 500
        m5 = (n - m500 * 500) `div` 5
    in
    m500 * 1000 + m5 * 5


Measured memory_bytes: 508
from bisect import bisect,bisect_left

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

ans = 0

for b in B:
    ca = bisect_left(A,b)
    cc = N - bisect(C,b)
    ans += ca*cc

print(ans)

Measured memory_bytes: 23240
#include <stdio.h>

int main(void)
{
  char s[11] = "";
  char a[11] = "";
  int i, j;
  
  scanf("%s", s);
  for ( i=0, j=0; s[i]!='\0'; i++ ) {
    switch ( s[i] ) {
    case 'B':
      j--;
      if ( j < 0 ) j = 0;
      break;
    default:
      a[j++] = s[i];
      break;
    }
  }
  a[j] = '\0';
  
  puts(a);
  
  return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

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

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	string s=readString();
	vector<string> strs;
	int k=read();
	int n=s.size();
	REP(i,n){
		int len=min(k,n-i);
		string t;
		REP(j,len){
			t.PB(s[i+j]);
			strs.PB(t);
		}
	}
	sort(ALL(strs));
	strs.erase(unique(ALL(strs)),strs.end());
	cerr<<strs<<endl;
	cout<<strs[k-1]<<endl;
}


Measured memory_bytes: 3708
while True:
    H,W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for a in range(H):
        for b in range(W):
            if (a + b) % 2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N, X, A[100000];

int main(){
  int i, k;
  ll res = 0;

  reader(&N,&X);
  rep(i,N) reader(A+i);

  rep(i,N) if(A[i] > X) res += A[i] - X, A[i] = X;
  REP(i,1,N){
    k = A[i-1] + A[i] - X;
    if(k > 0) res += k, A[i] -= k;
  }
  writerLn(res);

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
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; }

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    for (int i = 0; i < 100100; ++i) dp[i] = INF;
    
    dp[0] = 0;
    
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=INT_MAX,e=0;
  cin>>a>>b;
  cout<<min(a%b,(a%b-b)*-1);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

ll solve(vector<ll> vec,ll st){
  if(vec.size()==0) return 0;
  if(vec[0]>st) return -1;
  return vec[0]+vec.size()-1;
}
ll ar[200005]={0};
int main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  ll fst=0,past=-1,ans=0;
  bool f=true;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(a==past+1){
      vec.push_back(a);
    }
    else if(a>past+1) f=false;
    else{
      ll kans=solve(vec,fst);
      if(kans==-1) f=false;
      else ans+=kans;
      vec.clear();
      vec.push_back(a);
      fst=i;
    }
    past=a;
  }
  ll ka2=solve(vec,fst);
  if(ka2==-1) f=false;
  else ans+=ka2;
  cout<<(f?ans:-1)<<endl;
}


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

#define ll long long int
#define ri register int
#define endl "\n"

using namespace std;

ll dp[102][(int)1e5 + 2] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	ll n, w;
	cin >> n >> w;

	vector< pair<ll, ll> > items(n+1);
	for (ri i = 1; i <= n; i++) cin >> items[i].first >> items[i].second;

	for (ri i = 1; i <= n; i++)
	{
		for (ri j = 0; j <= w; j++)
		{
			if (j - items[i].first >= 0)
			{
				dp[i][j] = max(dp[i - 1][j - items[i].first] + items[i].second, dp[i-1][j]);
			}
			else
			{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][w] << endl;
	return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define ll long long

using namespace std;
int mod = 1000000007;

int N, M;
int main() {
  cin >> N >> M;
  if (N > M) {
    int now = M;
    M = N;
    N = now;
  }

  if (M-N > 1) {
    cout << 0 << endl;
    return 0;
  }
  long fact = 1;
  for (int i=1; i<=N; i++) {
    fact *= i;
    fact %= mod;
  }

  fact *= fact;
  fact %= mod;

  if (N == M) {
    fact *= 2;
    fact %= mod;
  } else {
    fact *= M;
    fact %= mod;
  }

  cout << fact << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void swap(int a, int b, int[] li) {
		int tmp = li[a];
		li[a] = li[b];
		li[b] = tmp;
	}
	public static int bubbleSort(int a[], int n) {
		int count = 0;
		boolean flag = true;
		for(int i = 0; flag; i++) {
			flag = false;
			for(int j = n - 1; j > i; j--) {
				if(a[j - 1] > a[j]) {
					swap(j - 1, j, a);
					count++;	flag = true;
				}
			}
		}
		return count;
	}
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int N = scanner.nextInt();
		int[] list = new int[N];
		for(int i = 0; i < N; i++) list[i] = scanner.nextInt();
		int count = bubbleSort(list, N);
		for(int i = 0; i < N; i++) System.out.print(list[i] + (i==N - 1? "\n":" "));
		System.out.println(count);
		scanner.close();
	}
}



Measured memory_bytes: 26488
from math import factorial
from collections import Counter
MOD = 10 ** 9 + 7

def prime_decomposition(n):
 i = 2
 table = []
 while i * i <= n:
   while n % i == 0:
     n //= i
     table.append(i)
   i += 1
 if n > 1:
   table.append(n)
 return table

n = int(input())
nn = factorial(n)
nnn = Counter(prime_decomposition(nn))

ans = 1
for i in nnn.values():
    ans *= i + 1
    ans %= MOD

print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    char S[205];
    ins(S);
    ll ans=strlen(S), N, con;
    while(1){
        ans -= 2;
        N = ans/2;
        con = 0;
        rep(i, N) if(S[i]!=S[N+i]) con++;
        if(con) continue;
        put(ans);
        return 0;
    }
}


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

int main(){
  long long int N,sum=0;
  cin>>N;
  for(long long int i=1;i<=1000030;i++){
    if(i*(i+1)<N){
      if(N%i==0){
        sum=sum+N/i-1;
      }
    }
  }
  cout<<sum<<endl;
  
  
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int n, m, a;
	while (cin >> n >> m >> a, n || m || a) {
		int amida[1000][101];
		rep(i, 1000) rep(j, 101) amida[i][j] = 0;
		rep(i, m) {
			int h, p, q;
			cin >> h >> p >> q;
			amida[1000 - h][p] = q;
			amida[1000 - h][q] = p;
		}
		rep(i, 1000) if (amida[i][a]) a = amida[i][a];
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1552
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////

    int N;
    cin>>N;
    vector<int>a(N+1);
    for(int i=1;i<N+1;i++){
        cin>>a.at(i);
        }
    int i=1;
    for(int j=1;j<N;j++){
        i=a.at(i);
        if(i==2){
            cout<<j<<endl;
            break;
        }
        if(j==N-1){
            cout<<-1<<endl;
        }
    }
    
    
    
    
        return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.Char
import Data.List

winScore :: [[String]] -> (Int,Int)
winScore [] = (0,0)
winScore (x:xs) = (tar + fst k ,han + snd k)
                  where (tar, han) = case (compare (x!!0) (x!!1)) of
                                       GT -> (3,0)
                                       EQ -> (1,1)
                                       LT -> (0,3)
                        k = winScore xs

main = do
    n <- readLn ::IO Int
    c <- replicateM n (words <$> getLine) :: IO [[String]]
    let (tar,han) = winScore c
    putStrLn $ show tar ++" "++ show han
    

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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int mod = 1e9 + 7;
const int N = 3e3 + 10;

int r, c, k;
int val[N][N];
LL dp[4][N][N];

void ckmax(LL& a, LL b) { a = max(a, b); }

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (~scanf("%d%d%d", &r, &c, &k))
    {
        clr(val, 0);
        int rr, cc, vv;
        for (int i = 1; i <= k; i++)
        {
            scanf("%d%d%d", &rr, &cc, &vv);
            val[rr][cc] = vv;
        }

        dp[0][1][1] = 0;
        if (val[1][1] > 0) dp[1][1][1] = val[1][1];

        for (int i = 1; i <= r; ++i)
        {
            for (int j = 1; j <= c; ++j)
            {
                for (int kk = 0; kk <= 3; kk++)
                {
                    ckmax(dp[0][i + 1][j], dp[kk][i][j]);
                    ckmax(dp[kk][i][j + 1], dp[kk][i][j]);

                    if (val[i + 1][j] != 0)
                    {
                        ckmax(dp[1][i + 1][j], dp[kk][i][j] + val[i + 1][j]);
                    }
                    if (val[i][j + 1] != 0 && kk < 3)
                    {
                        ckmax(dp[kk + 1][i][j + 1], dp[kk][i][j] + val[i][j + 1]);
                    }
                }
            }
        }

        LL ans = 0;
        for (int kk = 0; kk <= 3; kk++) ans = max(ans, dp[kk][r][c]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 321228
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;


int main()
{
    int s, w;
    cin >> s >> w;
    if (s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

bool e[52525];

int main(){
  REP(i,52525)e[i]=true;
  e[0]=false;
  e[1]=false;
  int iter = 2;
  set<int> ps;
  while(iter < 52525){
    if(!e[iter]){
      ++iter;
      continue;
    }
    ps.insert(iter);
    int st = iter*2;
    while(st < 52525){
      e[st]=false;
      st+=iter;
    }
    ++iter;
  }
  int n;
  while(~scanf("%d",&n)){
    set<int>::iterator iter;
    iter = ps.lower_bound(n);
    int x,y;
    if(*iter == n){
      --iter; x = *iter;
      ++iter; ++iter; y = *iter;
    }else{
      y = *iter;
      --iter; x = *iter;
    }
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}

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

/* 
 * g++ -std=c++17 A.cpp -o A
 */
int main() {
  ios_base::sync_with_stdio(false);
  int n, x;
  cin>>n>>x;
  vector<int> boxes(n+1, 0);
  for(int i = 1; i <= n; i++) {
    int a;
    cin>>a;
    boxes[i] = a;
  }
  ll res = 0;
  for(int i = 0; i < n; i++) {
    if (boxes[i] + boxes[i+1] > x) {
      res += (ll) (boxes[i] + boxes[i+1] - x);
      boxes[i+1] -= (boxes[i] + boxes[i+1] - x);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.AtCoder_Beginner_Contest_999
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = Console.ReadLine().ToCharArray();

            for (int i = 0; i < num.Length; i++)
            {
                switch (num[i])
                {
                    case '1':
                        num[i] = '9';
                        break;
                    case '9':
                        num[i] = '1';
                        break;
                    default:
                        break;
                }
            }

            Console.Write(new string(num));
        }
    }
}


Measured memory_bytes: 13140