akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#define LiangJiaJun main
using namespace std;
char s[2004];
int l;
bool pd(int zq){
     if(zq%2!=0)return 0;
     int w=zq/2;
     for(int i=1;i<=w;i++)
        if(s[i]!=s[i+w])return 0;
     return 1;
}
int LiangJiaJun(){
    scanf("%s",s+1);
    l=strlen(s+1);
    for(int len=l-1;len>=1;len--){
        if(pd(len)){
            return printf("%d\n",len),0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int lmax,rmin=INT_MAX,n;
int main() {
    int x,y;
    scanf("%*d%d",&n);
    for(register int i=1; i<=n; i++) {
        scanf("%d%d",&x,&y);
        lmax=max(lmax,x);
        rmin=min(rmin,y);
    }
    printf("%d\n",max(rmin-lmax+1,0));
    return 0;
}


Measured memory_bytes: 3784
program sum_of_product
    implicit none
    integer(16) n, i, y,ans,x,z,j,t
    integer(16),allocatable :: a(:)

    read *, n
    allocate(a(n))
    read *, a
    y=0
    x=0
    z=0
    j=0
    t=sum(a)
    do i=1,n
        x=x+a(i)
        y=t-x
        z=y*a(i)
        j=j+z
    end do
    ans=modulo(j,1000000007)
    print *,ans
end program sum_of_product

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> A(n+1);
    rep(i,n){
        int a; cin >> a;
        A[a] = i+1; 
    }
    rep1(i,n+1){
        cout << A[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
	int n;
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		int a=0,b;
		for(int i=4;i<=n;i++){
			b=5;
			while(b<=i){
				a+=(!(i%b) && i!=0)? 1 : 0;
				b*=5;
			}
		}
		printf("%d\n",a);
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = n - (k - 1);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	int X, Y;

	scanf("%d%d", &X, &Y);

	if (X / Y == (double)X / Y) {
		printf("-1\n");
		return 0;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 ll n;
 cin >> n;
 vector <ll> l(n),copy(n);
 rep (i,n){
   cin >> l[i];
   copy[i]=l[i];
 }
 if (n <= 2) {
   cout << 0 << endl;
   return 0;
 }
 
 long long res = 0;
    
    // a と b を固定
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
          if (l[i]==l[j]) continue;
            for (int k = j+1;k < n;++k){
              if (abs(l[i]-l[j])<l[k] && l[i]+l[j]>l[k]) {
                if (l[k]==l[i] || l[k]==l[j]) continue;
                //cout << l[i] <<" " << l[j] << " " << l[k] << endl;
               res++;
              }
            }
        }
    }
    cout << res << endl;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=l[n-1-i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
// ALPCA.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <atcoder/dsu.hpp>
using namespace std;
using namespace atcoder;
int main()
{
    int n, q;
    cin >> n >> q;
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }
        else {
            cout << d.same(u, v) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3444
import itertools
n,m,r=map(int,input().split())
rx=[int(i) for i in input().split()]
inf=100000000
wf=[[inf]*n for i in range(n)]
for i in range(n):
    wf[i][i]=0

for i in range(m):
    a,b,c=map(int,input().split())
    wf[a-1][b-1]=c
    wf[b-1][a-1]=c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if wf[i][j]>wf[i][k]+wf[k][j]:
                wf[i][j]=wf[i][k]+wf[k][j]
cnt=0
l=list(itertools.permutations([i for i in range(r)]))
cnt=inf
for i in l:
    cnt_sub=0
    for j in range(r-1):
        cnt_sub+=wf[rx[i[j]]-1][rx[i[j+1]]-1]
    cnt=min(cnt,cnt_sub)
print(cnt)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vs vs(n);
    cin>>vs;
    Vec v(26);
    rep(i,26){
        v[i] = INF;
    }
    rep(i,n){
        string s = vs[i];
        Vec x(26);
        rep(j,s.length()){
            x[s[j]-'a']++;
        }
        rep(j,26){
            chmin(v[j],x[j]);
        }
    }
    rep(i,26){
        rep(j,v[i]){
            char x = 'a'+i;
            cout<<x;
        }
    }
    cout<<endl;
    return  0;
}


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

int main() {
    int64_t N, S;
    cin >> N >> S;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    constexpr int64_t MOD = 998244353;

    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(S + 1, 0));
    dp[0][0] = 1;

    for (int64_t i = 0; i < N; i++) {
        for (int64_t j = 0; j <= S; j++) {
            //遷移
            //選ぶ
            if (j + A[i] <= S) {
                (dp[i + 1][j + A[i]] += dp[i][j]) %= MOD;
            }

            //選ばない
            (dp[i + 1][j] += dp[i][j] * 2) %= MOD;
        }
    }

    cout << dp[N][S] << endl;
}

Measured memory_bytes: 73748
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	if (N == M)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
fn rec(i: u64, n: u64) -> u64 {
    if i > n {
        return 0;
    }

    let s = i.to_string();
    let mut ret: u64 = 0;
    if ["3", "5", "7"].iter().all(|x| s.contains(x)) {
        ret += 1;
    }
    ret + [3, 5, 7]
        .iter()
        .map(|&x| rec(i * 10 + x, n))
        .fold(0, |sum, x| sum + x)
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let n: u64 = buf.trim().parse().unwrap();
    println!("{}", rec(0, n));
}


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

int main() {
    int i, x;
    i = 1;
    while (1) {
        cin >> x;
        if (x == 0) break;
        cout << "Case " << i << ": " << x << "\n";
        i++;
    }
    //cout << endl;

    return 0;
}

Measured memory_bytes: 3092
import sys
from numpy import cumsum
from bisect import bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N, M, K = inpl()
    A = inpl()
    B = inpl()
    cumA = cumsum(A)
    cumB = cumsum(B)
    ans = bisect_right(cumB, K)
    for i, ca in enumerate(cumA):
        k = K - ca
        if k < 0:
            break
        tb = bisect_right(cumB, k)
        # print(k, i, tb, cumB)
        if ans < i + tb + 1:
            ans = i + tb + 1
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 59080
N,K,Q=map(int,input().split())
B=[0]*N
def minu(n):
  return n-1
for i in range(Q):
  A=int(input())
  B[A-1]+=1
for i in range(N):
  if B[i]>Q-K:
    print("Yes")
  else:
    print("No")

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

int main() {
  int N, K;
  cin >> N >> K ;
  int S=1, A ,B ;
  
  for(int i=0; i<N; i++) {
   A = S*2;
   B = S+K;
   if(A<=B){
 S=A;
   }else{
     S=B;
   }
  }
cout << S << endl;
}
    
    


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
const double PI=3.14159265359;
int main()
{
	int a,b,c;
	double S,L,h;
	scanf("%d%d%d",&a,&b,&c);
	S=a*b*sin((double)c/180*PI)/2;
	L=a+b+sqrt(a*a+b*b-2*a*b*cos((double)c/180*PI));
	h=S*2/a;
	printf("%lf %lf %lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

ll dp[110][1000];
char chara[]={'A','C','G','T'};
int N;
regex re("AGC");

int conv(string s){
    int ret=0;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]=='A') ret+=1*(int)pow(10,i);
        else if(s[i]=='C') ret+=2*(int)pow(10,i);
        else if(s[i]=='G') ret+=3*(int)pow(10,i);

    }
    return ret;
}

bool check(string s){
    if(regex_search(s,re)) return false;
    for(int i=0;i<3;++i){
            string t=s;
            swap(t[i],t[i+1]);
            if(regex_search(t,re)) return false;
    }
    return true;
}


ll dfs(int n,string last){
    if(dp[n][conv(last)]>=0)  return dp[n][conv(last)];
    if(n==N) return 1;
    ll ret=0ll;
    for(auto c:chara){
        if(check(last+c)) (ret+=dfs(n+1,last.substr(1)+c))%=MOD;

    }
    return dp[n][conv(last)]=ret;
}

int main(){

    cin>>N;
    memset(dp,-1, sizeof(dp));

    cout<<dfs(0,"TTT")<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pi 3.14159265358979323846
using namespace std;
int main(){
   int n,m;
   cin>>n>>m;
  // vector<int>v;
   int sum=0;
   for(int i=0;i<m;i++){
       int x;cin>>x;
       sum+=x;
   }
    if(sum>n)cout<<"-1"<<endl;
    else cout<<n-sum<<endl;
    return 0;
    
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int a[100000];

int main() { int n, k, q;
    cin >> n >> k >> q;
    rep(i, q) { int tmp;
        cin >> tmp;
        a[tmp - 1] += 1;
    }
    rep(i, n) {
        if(q- a[i] >= k)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache
setrecursionlimit(10**6)
input=stdin.readline

h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
d=[[False]*w for _ in range(h)]
dx=[1,-1,0,0]
dy=[0,0,1,-1]
q=deque()
nowi=[]
ans=0

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            nowi.append((i,j))
            d[i][j]=True
q.append(nowi)
#print(nowi)
while len(q):
    nowq=q.popleft()
    nextq=[]
    #print(nowq)
    for i in nowq:
        ny,nx=i
        for yx in range(4):
            if ny+dy[yx]<0 or ny+dy[yx]>=h:
                continue
            if nx+dx[yx]<0 or nx+dx[yx]>=w:
                continue
            if d[ny+dy[yx]][nx+dx[yx]]:
                continue
            nextq.append((ny+dy[yx],nx+dx[yx]))
            d[ny+dy[yx]][nx+dx[yx]]=True
    if len(nextq):
        q.append(nextq)
        ans+=1
    #print(nextq)
print(ans)

Measured memory_bytes: 137700
#define _USE_MATH_DEFINES
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
    
int main() {
	int A, B, H, M;
    cin >> A >> B >> H >> M;
    double i = abs(M*6 - (H*60 + M)*0.5);
    if(i > 180){
        i = 360 - i;
    }
    double C = A*A + B*B - 2*A*B*cos(i*M_PI/180);
    printf("%.10f\n",pow(C, 0.5));
    return 0;
} 

Measured memory_bytes: 4244
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }

    Scanner kbd = new Scanner(System.in);

    void run(){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n);
	}
    }

    void solve(int n){
	int ans = -1;
	for(int i=1; i<=12; i++){
	    int a = (kbd.nextInt() - kbd.nextInt());
	    //System.out.println(a);
	    if(n>0 && n<=a) ans = i;
	    n -= a;
	}
	if(ans!=-1)
	    System.out.println(ans);
	else
	    System.out.println("NA");
    }
}

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

using namespace std;

int main(){
  long long n, m;
  vector<long long> x, y;
  cin >> n >> m;
  long long prev;
  long long xx, yy;
  long long ans_x = 0;
  long long ans_y = 0;
  cin >> prev;
  for (long long i=1;i<n;i++) {
    long long tmp;
    cin >> tmp;
    //    x.push_back(prev - tmp);
    xx = prev - tmp;
    ans_x += ((n - i) * i * xx) % 1000000007;
    ans_x = ans_x % 1000000007;
    prev = tmp;
  }
  cin >> prev;
  for (long long i=1;i<m;i++) {
    long long tmp;
    cin >> tmp;
    //    y.push_back(prev - tmp);
    yy = prev - tmp;
    ans_y += ((m - i) * i * yy) % 1000000007;
    ans_y = ans_y % 1000000007;
    prev = tmp;
  }

  cout << (ans_x * ans_y)%1000000007 << endl;

  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    e=a*b;
    f=c*d;
    if(e>=f) printf("%d\n",e);
    else printf("%d\n",f);


}


Measured memory_bytes: 3132
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new char[n, n];
        for (int i = 0; i < n; i++)
        {
            var s =Console.ReadLine().Trim();
            for (int j = 0; j < n; j++) a[i, j] = s[j];
        }
        var count = 0;
        if (checkArray(a)) count++;
        for (int i = 0; i < n-1; i++)
        {
            getNew(a);
            if (checkArray(a)) count++;
        }
        Console.WriteLine(count * n);
    }
    public static void getNew (char[,] a)
    {
        var n = a.GetLength(0);
        var w = new char[n];
        for (int i = 0; i < n; i++)
            w[i] = a[i, n - 1];
        for (int i = 0; i < n; i++)
            for (int j = n - 2; j >= 0; j--) a[i, j+1] = a[i, j];
        for (int i = 0; i < n; i++)
            a[i, 0] = w[i];
    }
    public static bool checkArray (char[,] a)
    {
        var n = a.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++)
                if (a[i, j] != a[j, i]) return false;
        return true;
    }
}

Measured memory_bytes: 13212
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=1;i<n;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0&&v<A[j]){
            swap(A[j],A[j+1]);
            j--;
        }
        A[j+1]=v;
    }
    int ans=abs(A[0]-A[n-1]);
    cout<<ans<<endl;
    



return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(false);
    long long int h,w,a1=LLONG_MAX,a2=LLONG_MAX,a3=LLONG_MAX,a4=LLONG_MAX,x,y,z;
    cin>>h>>w;
    if(h>=3){
        if(h%3==0){
            cout << 0;
            return 0;
        }else{
            a1=w;
        }
    }
    if(w>=3){
        if(w%3==0){
            cout << 0;
            return 0;
        }else{
            a2=h;
        }
    }
    if(h>=2&&w>=2){
        for(long long int i=1;i<h;i++){
            if(w%2==0||w%2==1){
                x=i*w;
                y=(h-i)*(w/2);
                z=(h-i)*((w+1)/2);
                a3=min(a3,abs( max(max(x,y),z) - min(min(x,y),z)));
            }
        }
    }
    if(h>=2&&w>=2){
        for(long long int i=1;i<w;i++){
            if(w%2==0||w%2==1){
                x=i*h;
                y=(w-i)*(h/2);
                z=(w-i)*((h+1)/2);
                a3=min(a3,abs( max(max(x,y),z) - min(min(x,y),z)));
            }
        }
    }
    cout<<min(min(min(a1,a2),a3),a4);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    int n;  cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    int num=0;
    bool b=true;
    for(int i=0;b;++i){
        b=false;
        for(int j=n-1;j>=i+1;--j){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                b=true;
                ++num;
            }
        }
    }
    for(int i=0;i<n-1;++i){
        cout<<A[i]<<" ";
    }
    cout<<A[n-1]<<endl;
    cout<<num<<endl;
}


Measured memory_bytes: 3108
import collections
N = int(input())
A = list(map(int,input().split()))

temp = range(1,N+1)
temp2=[]
counter_m = 0
temp_ans = 10**20
ans = 0
# counter_p = 0
for i in range(N):
    temp2.append(A[i]-temp[i])
    if A[i] -temp[i] <= 0:
        counter_m+=1
temp2 = sorted(temp2)
if len(temp2)%2 == 0:
    b = (temp2[int(len(temp2)/2)]+temp2[int(len(temp2)/2 - 1)])/2
else:
    b = temp2[int(len(temp2)/2)]
# print(b)

for i in range(1,N+1):
    ans += abs(A[i-1]-(b+i))
print(int(ans))

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

map<string,int>memo;

int main() {
	int n;
 	cin>>n;
	
  
  string s;
  for(int i=0;i<n;i++){cin>>s;
  	memo[s]+=1;
}
  
  int mx=0;
	for(const auto&x:memo){
    	int v=x.second;
      if(v>mx)mx=v;
    }
  
  for(auto it=memo.begin();it !=memo.end();it++){
  	if(it->second==mx){
    	cout<<it->first<<endl;
    }
  }
  
  
  
}

Measured memory_bytes: 19244
#include <stdio.h>

int main(){
	int i,j;

	for(i = 0;i < 9;i++){
		for(j = 0;j < 9;j++){
			printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
		}
	}

	return 0;
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> arr_A;
  vector<int> arr_B;
  rep1(i, 1, A + 1) if (A % i == 0) arr_A.push_back(i);
  rep1(i, 1, B + 1) if (B % i == 0) arr_B.push_back(i);
  int cnt = 0;
  rep2(i, 0, arr_A.size() - 1) {
    rep2(j, 0, arr_B.size() - 1) {
      if (arr_A[i] == arr_B[j]) cnt++;
      if (cnt == K) {
        cout << arr_A[i] << endl;
        return 0;
      }
    }
  }
  return 1;
}

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

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

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
x=1
cnt=0
y=[1]
while True:
    x=a[x-1]
    cnt+=1
    y.append(x)
    if x==2:
        print(cnt)
        break
    elif x==1:
        print('-1')
        break
    elif cnt==100000:
        print(-1)
        break
    else:
        continue


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

int main() {
	
	int N,L;
	cin >>N >>L;
	
	int taste_ori=0;
	
	for(int i=0; i<N; i++){
		
		taste_ori+=L+i;
		
	}
	
	vector<int> tastes(N);
	
	
	for(int i=0; i<N; i++){
		
		tastes.at(i)=L+i;
		
	}
	
	vector<int> abstastes(N);
	
	for(int i=0; i<N; i++){
		
		abstastes.at(i)=abs(tastes.at(i));
		
	}
	
	vector<int>::iterator t = min_element(abstastes.begin(),abstastes.end());
	size_t index =distance(abstastes.begin(),t);
	
	cout <<taste_ori-tastes.at(index) <<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> a(n+1),b(n+1);
  REP(i,n) cin >> a[i+1];

  vector<int> ans;
  for (int i=n; i>0; i--) {
    int sum = 0;
    for(int j=i*2; j<=n; j+=i) sum+=b[j];
    if (sum%2 != a[i]) { b[i]++; ans.push_back(i); }
  }

  reverse(ALL(ans));
  COUT(ans.size());
  for (int x: ans) cout << x << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 5328
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

template <class Type>
Type dist(Type x, Type y)
{
	return sqrt(pow(x, 2) + pow(y, 2));
}

int main()
{
	const int DATASETS = 1000;

	double V[DATASETS];

	int X, H, K = 0;

	double A, B;

	while (true)
	{
		cin >> X >> H;

		if (X == 0 && H == 0) { goto Exit; }

		A = X;
		B = dist<double>(static_cast<double>(X) / 2, static_cast<double>(H));

		V[K] = static_cast<double>(X * X) + A * B * 2;

		K++;
	}

Exit:;

	for (int i = 0; i < K; i++)
	{
		cout << fixed << setprecision(15) << V[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  Int N,P;
  cin>>N>>P;
  Int ans = 1;
  for(Int i=2;i*i<=P;i++){
    Int cnt = 0;
    while(P%i==0) P/=i, cnt++;
    Int p = 1;
    while(cnt/N) p *= i, cnt -= N;
    ans *= p;
  }

  if(P != 1 && N == 1) ans *= P;

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


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

const long long mod = 1000000007;

int main(){
    using namespace std;
    long long N; cin >> N;
    vector<long long> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    long long ans = 0;
    for (int i = 0; i < 60; i++)
    {
        long long n1 = 0, n0 =0;
        for (int j = 0; j < N; j++)
        {
            long long a = (v[j] >> i & 1);
            if(a==0) n0++;
            else n1++;
        }
        long long t = (1ll << i) % mod;
        long long s = (n1 * n0) % mod;
        ans += t * s % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

int n, k, m = 0;
int p[10000], r[10000];

struct edge {
	int s, t, w;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.w < e2.w;
}

edge e[100000];

int find(int x) {
	if (p[x] == x)
		return x;
	else
		return p[x] = find(p[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);

	if (x == y)
		return;

	if (r[x] < r[y])
		p[x] = y;
	else {
		p[y] = x;
		if (r[x] == r[y])
			r[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

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

	for (int i = 0; i < k; i++)
		cin >> e[i].s >> e[i].t >> e[i].w;

	sort(e, e + k, comp);

	for (int i = 0; i < n; i++) {
		p[i] = i;
		r[i] = 0;
	}

	for (int i = 0; i < k; i++) {
		edge ea = e[i];

		if (!same(ea.s, ea.t)) {
			unite(ea.s, ea.t);
			m += ea.w;
		}
	}

	cout << m << endl;
}



Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){

  string s;
  bool a=1;
  cin >> s;
  FOR(i,s.size()-1){
    if(s[i]==s[i+1]){
      a=0;
    }
  }
  if(a){
    cout << "Good" << endl;
    
  }else{
    cout << "Bad" << endl;
  }
}


Measured memory_bytes: 256
s = input()

length = len(s) - 1
max = 2 ** length

ans = 0
for i in range(max):
    b = bin(i)[2:].zfill(length) + '1'
    index_s = 0
    l = []
    for j, flag in enumerate(b):
        if flag == '1':
            l.append(int(s[index_s:j+1]))
            index_s = j + 1
    
    ans += sum(l)

print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll s[101];
    std::cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
        sum += s[i];
    }
    sort(s,s+n);
    if(sum%10 == 0){
        for (int i = 0; i < n; i++) {
            if(s[i]%10 != 0){
                std::cout << sum-s[i] << std::endl;
                return 0;
            }
        }
        std::cout << 0 << std::endl;
    }else{
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,s,d,f,w=0,x;
	scanf("%d%d%d%d",&a,&s,&d,&f);
	w=a+s+d+f;
	x=0;
	while(1){
		if(w<60) break;
		w=w-60;
		x++;
	}
	printf("%d\n",x);
	printf("%d\n",w);
}

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


void solve(long long Q, long long H, long long S, long long D, long long N){
    // コスパ最強なものを買う
    // 2Lで奇数だったら、1Lコスパ最強なものを買う
    Q = 4 * Q;
    H = 2 * H;
    // 1Lコスパ最強
    long long cost_1l;
    if( Q <= H && Q <= S) cost_1l = Q;
    if( H <= Q && H <= S) cost_1l = H;
    if( S <= Q && S <= H) cost_1l = S;

    // 2Lコスパ最強
    long long cost_2l = (cost_1l * 2 >= D) ? D : cost_1l*2;

    if(N % 2 == 0){
        cout << (N/2) * cost_2l << endl;
    } else { 
        cout << (N/2) * cost_2l + cost_1l << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long Q;
    scanf("%lld",&Q);
    long long H;
    scanf("%lld",&H);
    long long S;
    scanf("%lld",&S);
    long long D;
    scanf("%lld",&D);
    long long N;
    scanf("%lld",&N);
    solve(Q, H, S, D, N);
    return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int calc(ll x)
{
	int res=0;
	for(char c:to_string(x))
		res+=c-'0';
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		int res=calc(stoll(s));
		per(i,s.size()){
			repi(j,i+1,s.size())
				s[j]='0';
			chmax(res,calc(stoll(s)-1));
		}
		cout<<res<<endl;
	}
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int x = n / k;
	int y = n % k;
	vector<int>mod(k);
	for (int i = 0; i < k; i++) {
		mod.at(i) = x;
		if (i >= 1 && i <= y)mod.at(i)++;
	}
	ll ans = pow(mod.at(0), 3);
	if (k % 2 == 0)ans += pow(mod.at(k / 2), 3);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N=2e6+5;
ll n,c,c2;
bool pow(ll x){
    ll tmp=n;
    while(tmp>=x){
        if(!(tmp%x))
            tmp/=x;
        else
            tmp%=x;
    }
    return (tmp==1);
}
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    n--;
    for(ll i=1; i*i <= n ;i++){
        if((n%i))
            continue;
        c+=2;
        if( i*i == n || i==2 ) c--;
    }
    n++;
    c++;
    for(ll i=3; i*i <= n ; i++){
        if((n%i))
            continue;
        if(pow(i)) c++;
    }
    if(n<4) c--;

    cout<<c<<'\n';
    return 0;
}


Measured memory_bytes: 256
S = input()
l = len(S)

if l == 1:
    print(S)
else:
    patterns = []
    for i in range(2 ** (l-1)):
        b = format(i, 'b').zfill(l-1)
        patterns.append(b)

    ans = 0
    for pi in patterns:
        s = S[0]
        for i, bi in enumerate(pi):
            if bi == '1':
                s += '+'
            s += S[i+1]
        v = eval(s)
        ans += v
    print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int L[110];
    for (int i=0;i<n;++i) {
        cin >> L[i];
    }
    sort(L,L+n,greater<int>());
    int res=0;
    for (int i=0;i<k;++i){
        res += L[i];
    }
    cout << res << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
using namespace std;
typedef long long LL;
int main(){
    int n;
    scanf("%d",&n);
    int a[200005];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    if(a[0]!=0){
        printf("-1\n");
        return 0;
    }
    for(int i=1;i<n;i++){
        if(a[i]-1>a[i-1]){
            printf("-1\n");
            return 0;
        }
    }
    LL ans=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]+1)
        ans++;
        else{
            ans+=a[i];
        }
    }
    printf("%lld\n",ans);
}




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

struct edge {
    int to;
    int num;
};

vector<vector<edge> > g;
vector<int> ans;

void bfs(int x, int c=-1, int b=-1){
    int k = 1;
    rep(i, g[x].size()){
        int t = g[x][i].to;
        if(t == b)continue;
        int n = g[x][i].num;
        if(k == c)k++;
        ans[n] = k; k++;
        bfs(t, ans[n], x);
    }
    return;
}

int main() {
    int N; cin >> N;
    g.resize(N);
    ans.resize(N-1);
    rep(i, N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back((edge){b, i});
        g[b].push_back((edge){a, i});
    }
    bfs(0);

    int Max = 0;
    rep(i, N-1){
        Max = max(Max, ans[i]);
    }
    cout << Max << endl;

    rep(i, N-1){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 8320
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

ans[0]= 0
for i in range(N-1):
    ans[0] = ans[0]^A[i+1]

All = ans[0]^A[0]

for i in range(N):
    ans[i] = All^A[i]

for i in range(N):
    print(ans[i])

Measured memory_bytes: 31444
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define pr pair<int,int>
#define N 100005
#define mod 1000000007
#define INF 2147483647
using namespace std;
int a[N];
bool vis[N];
vector<int>v;
int main() {
	IOS;
    int m,n,cnt=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    v.push_back(a[1]);
    for(int i=2;i<=n;i++){
        if(v.back()>=a[i])v.push_back(a[i]);
        else{
            int l=-1,r=v.size();
            while(l+1<r){
                int mid=l+r>>1;
                if(v[mid]<a[i])r=mid;
                else l=mid;
            }
            v[l+1]=a[i];
        }
        //for(auto i:v)cout<<i<<' ';
        //cout<<'\n';
    }
    cout<<v.size();
	return 0;
}

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

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector <int> snuke(n+1, 0);

    for (int i = 1; i <= k; i++)
    {
        int d;

        cin >> d;

        for (int j = 1; j <= d; j++)
        {
            int a;

            cin >> a;

            snuke[a]++;
        }
    }

    int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        if (!snuke[i])
            ans++;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
main(){
  int a,b,c;
  a=1;
  b=1;
  while(a<10){
    while(b<10){
      c=a*b;
      printf("%dx%d=%d\n",a,b,c);
      b++;
    }
    b=1;
    a++;
  }
return 0; 
}

Measured memory_bytes: 0
#include <stdio.h>
int main() {
	double a1[2], a2[2], b1[2], b2[2];

	while(scanf(" %lf %lf %lf %lf %lf %lf %lf %lf ",
				a1, a1+1, a2, a2+1, b1, b1+1, b2, b2+1) != EOF) {
		if (a1[0] > b2[0] || a2[0] < b1[0]) {
			puts("NO");
		}
		else if (a1[1] > b2[1] || a2[1] < b1[1]) {
			puts("NO");
		}
		else {
			puts("YES");
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
     
using namespace std;
     
int main(){
     
    int a, b, c, sum;
    cin >> a >> b >> c;
    sum = a+b+c;
    if (sum == 17) cout << "YES" << "\n";
    else cout << "NO" << "\n";

    return 0;

    }


Measured memory_bytes: 256
string = list(input())
string.pop()
string.pop()
while "".join(string[:len(string) // 2]) != "".join(string[len(string) // 2:]):
	#print("".join(string[:len(string) // 2]), "".join(string[len(string) // 2:]))
	string.pop()
	string.pop()
# print("".join(string[:len(string) // 2]), "".join(string[len(string) // 2:]))
print(len(string))

Measured memory_bytes: 2940
import sys
v=[0]*101
for e in sys.stdin:
 a,b=map(int,e.split())
 v[a]+=1;v[b]+=1
 if a==0:
  print(['NG','OK'][1&v[1]and 1&v[2]and sum(x&1 for x in v)==2])
  v=[0]*101


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

int paper[50][50];


void dropSmall(int y,int x){
  int dx[] ={0,0,1,-1};
  int dy[] ={1,-1,0,0};
  paper[y][x]++;
  for(int i=0;i<4;i++) paper[y+dy[i]][x+dx[i]]++;
}


void dropMidium(int y,int x){
  for(int dy=-1;dy<=1;dy++)
    for(int dx=-1;dx<=1;dx++)paper[y+dy][x+dx]++;
}

void dropLarge(int y,int x){
  dropMidium(y,x);
  int dx[] = {0,0,2,-2};
  int dy[] = {2,-2,0,0};
  for(int i=0;i<4;i++) paper[y+dy[i]][x+dx[i]]++;
}


int main(){
  int x,y,s;
  while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
    x+=10;
    y+=10;
    if(s == 1)dropSmall(y,x);
    if(s == 2)dropMidium(y,x);
    if(s == 3)dropLarge(y,x);
  }

  int cnt = 0;
  int mx = 0;
  for(int i=10;i<20;i++)
    for(int j=10;j<20;j++){
      if(paper[i][j] == 0) cnt++;
      if(paper[i][j] > mx) mx = paper[i][j];
    }
  
  cout<<cnt<<endl;
  cout<<mx<<endl;
  
  return 0;
}

Measured memory_bytes: 3132
import Data.List

parse :: String -> [Int]
parse xs = case read ("(" ++ xs ++ ")") of
    (c1,c2,c3,c4,c5) -> [c1,c2,c3,c4,c5]

(<|>) :: Maybe a -> Maybe a -> Maybe a
Nothing <|> x = x
x       <|> _ = x

conditional :: a -> a -> Bool -> a
conditional x y b = if b then x else y

onePair :: [Int] -> Maybe String
onePair = conditional (Just "one pair") Nothing . any ((== 2) . length) . group

twoPair :: [Int] -> Maybe String
twoPair [c1,c2,c3,c4,c5] = conditional (Just "two pair") Nothing $ (c1 == c2 && c3 == c4) || (c1 == c2 && c4 == c5) || (c2 == c3 && c4 == c5)
twoPair _ = undefined

threeCard :: [Int] -> Maybe String
threeCard = conditional (Just "three card") Nothing . any ((== 3) . length) . group

straight :: [Int] -> Maybe String
straight (x:xs) = conditional (Just "straight") Nothing $ impl x xs
    where
        impl :: Int -> [Int] -> Bool
        impl _ [] = True
        impl 1 [10,11,12,13] = True
        impl y (z:zs)
            | succ y == z = impl z zs
            | otherwise   = False
straight _ = undefined

fullHouse :: [Int] -> Maybe String
fullHouse = conditional (Just "full house") Nothing . all ((\ x -> x == 2 || x == 3) . length) . group

fourCard :: [Int] -> Maybe String
fourCard = conditional (Just "four card") Nothing . any ((== 4) . length) . group

apply :: [(a -> b)] -> a -> [b]
apply fs x = map (\ f -> f x) fs

score :: [Int] -> Maybe String
score = foldr (<|>) Nothing . apply [fourCard , fullHouse , straight , threeCard , twoPair , onePair] . sort

solve :: [Int] -> IO ()
solve = putStrLn . maybe "null" id . score
    
main :: IO ()
main = getContents
    >>= mapM_ solve . map parse . lines

Measured memory_bytes: 3980
N,K = list(map(int, input().split()))
S = input()
# 0の塊をK回返して、1の連結をつくる
# K = 2 のとき
# ... 0:3,1:3,0:2,1:2,0:3,1:4,0:2,... のとき
# 1:2の両端をを返す→1始まりの5個の部分和
# 1の塊をK-1回返して、0の連結をつくり、最後にひっくり返す（端の1ともくっつく…）
# K = 2 のとき
# ... 0:3,1:3,0:2,1:2,0:3,1:4,0:2,... のとき
# 1:2を裏返す、0:2-1:2-0:3を返す　→　あれ一緒…？


# 0が端のときだけ気を付ければよさそう…
# 0が端にあったらひっくり返したA作って、Kを減らしておなじことやりゃよいのか？
# あとKが極端に小さいか、Arrayの数（0/1のパターン数より大きいとき）の考慮
# あとlen(A) = 1

# sequence数を格納するArrayを作る
A = []
pre = S[0]
cnt = 1
for i in range(1,N):
  now = S[i]
  if pre == now:
    cnt += 1
  else:
    A.append(cnt)
    cnt = 1
  pre = now
A.append(cnt)

#print(A)

if len(A) == 1:
  print(sum(A))
  exit(0)

# 貪欲でとってから前2個足して後ろ引く、見たいにやればO(N)でいけるはず…
# 部分和でも仕留められそうではあるけど…
def solve(Ar,Kr):
  l,r = 0, 2*Kr+1
  if len(Ar) < 2*Kr+1:
    #全部でよい
    return sum(Ar)
  wk = sum(Ar[l:r])
  ans = wk
  while r < len(Ar):
    wk = wk - Ar[l] - Ar[l+1] + Ar[r] + (Ar[r+1] if r+1 < len(Ar) else 0)
    ans = max(ans, wk)
    #print(wk,l,r,Ar[l],Ar[r])
    l,r = l+2, r+2
  return ans

if S[0] == '1':
  print(solve(A,K))
else:
  B = A[1:]
  B[0] += A[0] # 1始まりに無理やりする
  print(max(solve(A[1:],K), solve(B,K-1)))

Measured memory_bytes: 6132
/***
 @ Author       : RobsonChen
 @ Date         : 2020-09-20 19:35:23
 @ LastEditTime : 2020-09-20 22:31:44
 @ Got AC       : Σ(っ °Д °;)っ
*/
#include <bits/stdc++.h>

using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 998244353;
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define FW freopen("data2.txt", "w", stdout);

//快速读入输出，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

void slove(int qnum)
{
    int n;
    cin >> n;
    LL ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += (n - 1) / i;
    }
    cout << ans << endl;
}

int main()
{
    int qnum = 1;
    // cin >> num;
    for (int i = 1; i <= qnum; ++i) {
        slove(i);
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3640