akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

//リスト用構造体定義
struct Node {
  struct Node *prev;
  struct Node *next;
  int key;
};

//リストの先頭を定義
struct Node *nil;

//命令を行う関数の宣言
struct Node* listSearch(int);
void init();
void insert(int);
void deleteNode(struct Node*);
void deleteFirst();
void deleteLast();
void deleteKey(int);
void printList();

int main()
{
  int i,n,key;
  char str[20]; //命令判定用
  scanf("%d",&n);
  init();

  for(i = 0; i < n; i++) {
    scanf("%s %d",str,&key);
    if(strcmp(str,"insert") == 0) {
      insert(key);
    }
    else if(strcmp(str,"delete") == 0) {
      deleteKey(key);
    }
    else if(strcmp(str,"deleteFirst") == 0) {
      deleteFirst();
    }
    else if(strcmp(str,"deleteLast") == 0) {
      deleteLast();
    }
    else printf("error\n");
  }//命令

  printList();
  return 0;
}

struct Node* listSearch(int key) {
  struct Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  struct Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void insert(int key) {
  struct Node *x=(struct Node*)malloc(sizeof(struct Node));
  
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
  
}

void deleteNode(struct Node *t) {
  if (t == nil) return; //t=nilの時処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 1e6 + 10, mod = 1e9 + 7;

int fac[maxn], ifac[maxn];

int pow_mod(int x, int n) {
	int y = 1;
	while(n) {
		if(n & 1) {
			y = (long long) y * x % mod;
		}
		x = (long long) x * x % mod;
		n >>= 1;
	}
	return y;
}

int C(int n, int m) {
	return n < m || m < 0 ? 0 : (long long) fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int F(int n, int m) {
	return C(n - 2 * m + 2 + m - 1, m);
}

int main(int argc, char *argv[]) {
#ifdef DEBUG
	freopen(argv[1], "r", stdin);
	freopen(argv[2], "w", stdout);
#endif
	int N = maxn - 1;
	fac[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fac[i] = (long long) fac[i - 1] * i % mod;
	}
	ifac[N] = pow_mod(fac[N], mod - 2);
	for (int i = N; i; --i) {
		ifac[i - 1] = (long long) ifac[i] * i % mod;
	}
	int n;
	scanf("%d", &n);
	int ans = fac[n];
	if(n == 2) {
		puts("1");
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		ans = ((long long) ans - (long long) fac[i] * fac[n - 1 - i] % mod * F(n - 3, n - 1 - i)) % mod;
	}
	printf("%d\n", (ans + mod) % mod);
	return 0;
}



Measured memory_bytes: 8064
//
//AtCoder Beginner Contest 128
//B - Guidebook
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<tuple<string, int, int>> t(n);
    REP(i,n){
        string s;
        int p;
        cin >> s >> p;
        t[i] = make_tuple(s,100-p,i+1);
    }
    sort(ALL(t));
    REP(i,n) cout << get<2>(t[i]) << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int l = s.size();
	
	for (int i = l-1; i >= 0 ; --i) {
		if(i%2==0 && i!=0) continue;
		int length = (i+1)/2;
		if(i == l - 1) continue;
		if(i == 0){
			cout << 1 << endl;
			return 0;
		}
		if(s.substr(0,length) == s.substr(i-length+1, length)){
			cout << 2*length << endl;
			return 0;
		}
	}
    return 0;
}



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

using namespace std;

typedef long long ll;

int N;
ll A[200000 + 10], B[200000 + 10];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i] >> B[i];

	sort(A, A + N), sort(B, B + N);
	if (N % 2 == 1) {
		cout << B[N / 2] - A[N / 2] + 1 << endl;
	}else {
		ll tmpa = A[N / 2 - 1] + A[N / 2];
		ll tmpb = B[N / 2 - 1] + B[N / 2];
		cout << tmpb - tmpa + 1 << endl;
	}
 	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N,F[101][15],P[101][15];
    cin>>N;

    rep(i,N){
        rep(j,10){
            cin>>F[i][j];
        }
    }
    rep(i,N){
        rep(j,11){
            cin>>P[i][j];
        }
    }

    //bit全探索？
    int res=-INF;
    for(int b=1;b<(1<<10);b++){//営業するしないが10回選択できるため、10**2通りある
        int cc=0;
        for(int i=0;i<N;i++){
            int c=0;
            //b>>jが日にち指定 &1でその日営業するか否か
            for(int j=0;j<10;j++)if((b>>j&1)&&F[i][j])c++;//bitの各桁が営業日を表す？
            cc+=P[i][c];
        }
        if(res<cc)res=cc;
    }
    cout<<res<<endl;


    return 0;
}

//a=97,z=122

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

int main() {
    set<int> s;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int h, w, prev_l = 0, prev_r = 0;
    cin >> h >> w;
    string line;
    bool flag = true;
    rep(i, h){
        int l = w, r = -1;
        cin >> line;
        rep(j, w){
            if(line[j] == '#'){
                l = min(l, j);
                r = max(r, j);
            }
        }
        if(prev_r != l){
            flag = false;
        }
        prev_l = l, prev_r = r;
    }
    printf(flag ? "Possible\n" : "Impossible\n");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,k;
int dp[2010][2010];
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n+1) dp[1][i]=1;
	rep(i,2,n+1) {
		dp[i][i-1]=dp[i-1][i-1];
		rep(j,i,n+1) {
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			if (dp[i][j]>=mod) dp[i][j]-=mod;
		}
	}
	int v=dp[k][n]-dp[k-1][n];
	if (v<0) v+=mod;
	v=v*powmod(2,max(0,n-k-1))%mod;
	printf("%d\n",v);
}


Measured memory_bytes: 13952
#include <iostream>

using namespace std;

int main(){
  
  int a,b,c,d;
  while(1){

    cin>>a>>b;
    if(a==0 && b==0)break;
    for(c=1;c<=a;c++){
      
      for(d=1;d<=b;d++){
	if(c!=1 && c!=a && d!=1 && d!=b){
	  cout<<".";
	}
	  else cout<<"#";
	
      }
      
      cout<<"\n";
      
    }
    cout<<"\n";
  }
  
  
  
  
  return 0;
}

Measured memory_bytes: 1120
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double x = sc.nextInt();
		if(2*(b-x/(a*a))>=b) {
			double m = 2*x/(a*b);
			double tan = b/m;
			System.out.println(Math.toDegrees(Math.atan(tan)));
		}
		else {
			double m = 2*(b-x/(a*a));
			double x_2 = a*a*m/2;
			double tan = a/m;
			System.out.println(90-Math.toDegrees(Math.atan(tan)));
		}
	}	
}

Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  int ren = 0;
  for(char t : s){
    if(t == 'T' || t == 'A' || t == 'G' || t == 'C'){
      ren++;
    }else{
      ans = max(ren, ans);
      ren = 0;
    }
  }
  ans = max(ren, ans);
  cout << ans << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;
	string S;
	cin >> S;

	if (C<D) {
		bool flag = true;
		for (int b = B; b < D;b++) {
			if (S[b]=='#'&&S[b+1]=='#') {
				flag = false;
				break;
			}
		}
		for (int a = A; a < C && flag; a++) {
			if (S[a] == '#' && S[a + 1] == '#') {
				flag = false;
				break;
			}
		}
		if (flag) {
			ce("Yes")
		}
		else {
			ce("No")
		}
	}
	else {
		bool flag = false;
		for (int b = B-1; b < D; b++) {
			if (S[b] == '.' && S[b + 1] == '.' && S[b + 2] == '.') {
				flag = true;
				break;
			}
		}
		if (flag) {
			for (int a = A; a < C; a++) {
				if (S[a] == '#' && S[a + 1] == '#') {
					flag = false;
					break;
				}
			}
			if (flag) {
				ce("Yes")
			}
			else {
				ce("No")
			}
		}
		else {
			ce("No")
		}
	}
    return 0;
}



Measured memory_bytes: 640
import collections
n = int(input())
v = list(map(int,input().split()))

a = []
b = []
for i in range(n):
    if i%2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])
    
ac = collections.Counter(a)
bc = collections.Counter(b)

atemp = []
for i in ac:
    atemp.append(ac[i])
btemp = []
for i in bc:
    btemp.append(bc[i])

mxma = max(atemp)
mxmb = max(btemp)
for i in ac:
    if ac[i] == mxma:
        mxma = i
        break
for i in bc:
    if bc[i] == mxmb:
        mxmb = i
        break

atemp.sort()
btemp.sort()

if mxma != mxmb:
    print(n-max(atemp)-max(btemp))
else:
    if len(atemp) == 1 and len(btemp) == 1:
        print(n-max(atemp))
    else:
        temp = [atemp[-2]+btemp[-1],atemp[-1]+btemp[-2]]
        print(n-max(temp))

Measured memory_bytes: 19168
n = int(input())
A = list(map(int, input().split()))
xsum = A[0]
asum = A[0]
ans = 0
left, right = 0, 0

while True:
  if xsum == asum:
    ans += right - left + 1
    right += 1
    if right == n:
      break
    asum += A[right]
    xsum ^= A[right]
  else:
    asum -= A[left]
    xsum ^= A[left]
    left += 1
print(ans)


Measured memory_bytes: 32208
import math
from functools import lru_cache
from operator import mul
from functools import reduce


def cmb(n, r, mod):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod


x, y = map(int, input().split())
mod = 1000000007
cnt = (x + y) // 3
if (x + y) % 3 != 0:
    print(0)
    exit()
m = min(x, y)
num_2 = m - cnt
num_1 = cnt - num_2
ans = cmb(cnt, num_1, mod)
print(ans)



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

int top, S[1000];
void push(int);
int pop(void);

int main(){
  int x, y;
  char s[100];
  top = 0;
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(s[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else push(atoi(s));
  }

  printf("%d\n",pop());
  return 0;
}

void push(int m){
  S[++top] = m;
}

int pop(){
  top--;
  return S[top + 1];
}



Measured memory_bytes: 2104
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int h=stdIn.nextInt();
			int w=stdIn.nextInt();
			if(h==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 35284
N,M = map(int, input().split())
A=[-1 for i in range(N)]

ans=True
for i in range(M):
    s, c = map(int, input().split())
    if A[s-1]==-1:
        A[s-1]=c
    elif A[s-1]!=c:
        ans=False
        
if A[0]==0:
    ans=False        

head=True
for i in range(N):       
    if A[i]==-1:
        if head:
            A[i]=1
            head=False
        else:
            A[i]=0 
    elif A[i]==0:
        pass
    else:
        head=False

if N==1 and M==0:
    print(0)
elif ans and not head:
    A=[str(a) for a in A]
    print("".join(A))
elif head and N==1:
    print(0)
else:     
    print(-1)


Measured memory_bytes: 3064
class Dice:
    def __init__(self,u,s,e,w,n,d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d
    def rot(self,way):
        if way == 0:
            c = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = c
        if way == 1:
            c = self.e
            self.e = self.n
            self.n = self.w
            self.w = self.s
            self.s = c
        if way == 2:
            c = self.w
            self.w = self.d
            self.d = self.e
            self.e = self.u
            self.u = c
u,s,e,w,n,d = map(int,input().split())
dice = Dice(u,s,e,w,n,d)
questions = int(input())
for q in range(questions):
    top, south = map(int,input().split())
    flag = 0
    count = 0
    while True:
        for v in range(5):
            if dice.u == top and dice.s == south:
                print(dice.e)
                flag = 1
                break
            else:
                dice.rot(0)
        if flag:
            break
        elif count == 5:
            dice.rot(2)
            count = 0
        else:
            dice.rot(1)
            count += 1
    
    
    


Measured memory_bytes: 5608
#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 MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  cout << N*N*N << endl;
}



Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll cnt[10000005];

int main(){
	fastio;
	ll n; read(n);
	FER(i, 3, n+1){
		for(ll j = i; j<= n; j+=i) {
			cnt[j]++;
		}
	}
	long long ans = 0LL;
	FER(i, 1, n+1){
		ans += 1LL*i*(cnt[i] + 1 + (!(i&1)? 1: 0));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 42704
/* ***********************************************
Author        :axp
Created Time  :2017/1/22 20:03:37
TASK		  :A.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
ll ans;
int n,m;
int T;
ll now;
int a[N],b[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
	for(int i=n;i>=1;i--)
	{
		if((a[i]+now)%b[i]==0)continue;
		ll t=b[i]-(a[i]+now)%b[i];
		now+=t;
		ans+=t;
	}
	printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(string S, string T){
    int len = S.length();
    for(int i=0; i<len; ++i){
        S = S.substr(len - 1, 1) + S.substr(0, len - 1);
        if(S == T){
            cout<<Yes<<endl;
            return;
        }
    }
    cout<<No<<endl;
    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    string S, T;
    cin>>S>>T;
    answer(S, T);

    return 0;
}


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

#define fori( tt,aa)      for(int i= tt; i<aa; i++)
#define forj( yy,bb)      for(int j=yy; j<bb; j++)
#define fork( uu,cc)      for(int k=uu; k<cc; k++)
#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define EPS 1e-7
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define sc scanf
#define print printf
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string String;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

ll numOfDigits(ll n);
bool compare(int &a, int &b){
    return a>b;
}

ll pow (ll a, ll b);

dd BN (vector<pii> &v, ll n, ll m);



dd sum(dd mid){
    return ((dd)mid/2)*(mid+1);
}
int  N, M, NUM, mn = IMAX;
#define MAX 1000000
bool visited[15][102];
bool arr[15][102];

bool valid(int r, int c){//if not out of the bounds
    if(r>=N || r<0) return 0;
    if(c>=M || c<0) return 0;
    return 1;
}
void countReachable(int r, int c, int cnt, int i){
    //if out of bounds || visited before
    if(!valid(r, c) || visited[r][c])
        return;

    visited[r][c] = 1; //mark as visited

    if(i==NUM) {mn = min(mn, cnt); return;}
    //try 4 moves
    countReachable(r,c+1, cnt+1, i+arr[r][c]);//right

    countReachable(r,c-1, cnt+1, i+arr[r][c]);//left

    countReachable(r+1,c, cnt+1, i+arr[r][c]);//up
    visited[r][c] = 0;
    countReachable(r-1,c, cnt+1, i+arr[r][c]);//down
    visited[r][c] = 0;

}

int main()
{
    JULEE_DO_THE_THING;
    //freopen("test cases\\.txt", "r", stdin) ;
    int h, n; cin>>h>>n;
    int arr[n];
    fori(0, n) cin>>arr[i];
    sort(arr, arr+n);
    for(int i=n-1; i>=0; i--){
        h -= arr[i];
        if(h<=0) return cout<<"Yes", 0;
    }
    cout<<"No";
    return 0;
}


dd BN (vector<pii> &v, ll n, ll m){
dd low = 0;
dd up = 1e21;
dd ans = 0;
while(low<=up){
    dd mid = trunc((low+ up)/2);
    dd fx = 0;
    fori(0, n){
        fx += max(0.0, mid-v[i].F)*v[i].S;
    }
    if(fx<=m) {
        ans = mid;
        low = mid+1;
    }else up = mid-1;
}
return ans;
}

ll pow (ll a, ll b){
    ll pow = 1;
    fori(0,b)
        pow *=a;
    return pow;
}
ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n)+1);
}


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

int main(){
  int N,K,x;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int a,b,c;
    cin >> a;
    b = a*2;
    c = (K-a)*2;
    if(b>c)
      x += c;
    else
      x += b;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int A, B; cin >> A >> B;

    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3636
using System;

class Program
{
    static long n;
    static long s;

    static void Main()
    {
        n = long.Parse(Console.ReadLine());
        s = long.Parse(Console.ReadLine());

        long s_n = (long)Math.Pow(n, 0.5);
        for (long b = 2; b <= s_n; b++)
        {
            long n_ = n;
            long sum = 0;
            while (n_ > 0)
            {
                sum += n_ % b;
                n_ /= b;
            }
            if (s == sum)
            {
                Console.WriteLine(b);
                return;
            }
        }

        long u = (long)((n - s) / (Math.Pow(n, 0.5) - 1));
        for (long k = Math.Min(u, s); k > 0; k--)
        {
            if ((n - s) % k != 0) continue;
            long p = (n + k - s) / k;
            if (k >= p || (s - k) >= p) continue;
            Console.WriteLine(p);
            return;
        }

        if (s == n)
        {
            Console.WriteLine(n + 1);
            return;
        }

        Console.WriteLine(-1);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,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;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<string,ll> ma;
    string S;ll N;cin >> S >> N;
    ll s = S.size();
    rep(i,s){
        if(s - i < 5){
            for(ll j = 1;j <= s - i;j++){
                ma[S.substr(i,j)]++;
            }
        }
        else{
            rep(j,5){
                ma[S.substr(i,j + 1)]++;
            }
        }
    }
    ll cnt = 1;
    for(auto x : ma){
        if(cnt == N){
            cout << x.first << "\n";
            return 0;
        }
        cnt++;
    }
}

Measured memory_bytes: 4668
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

string solve(){
    int d,t,s;
    cin>>d>>t>>s;
    return (s*t >= d)?"Yes":"No";
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a  < b){
			System.out.println("a < b");
		}else if(a > b){
				System.out.println("a > b");
		} else {
				System.out.println("a == b");
			
		}
	}
}

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

int main(){

  ll N,M=0;
  
  cin>>N>>M;
  
  ll A[N];
  
  ll sum=0;
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }
  double thres=sum;
  thres=thres/(4*M);
  sort(A, A + sizeof(A)/sizeof(A[0]), greater<int>() );  
  //rep(i,N)cout<<A[i]<<" ";
  if(A[M-1]<thres)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;

}


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

typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    if (m == 1) {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    vector<int> d(m - 1);
    for (int i = 0; i < m - 1; i++) {
        d[i] = x[i + 1] - x[i];
    }
    sort(d.begin(), d.end());
    ll ans = 0;
    for (int i = 0; i < (int)d.size() - (n - 1); i++) {
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,K = list(map(int,input().split()))
PRR = list(map(int,input().split()))

# N = 10
# K = 4
# PRR = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
#
# N = 5
# K = 3
# PRR = [1, 2, 2, 4, 5]

def calculate(n, k, prr):

    sumarr = []
    for i in range(n):
        if len(sumarr) == 0:
            sumarr.append(prr[0])
        else:
            sumarr.append(sumarr[-1] + prr[i])

    maxSum = []

    for i in range(k-1,n):

        if i - k < 0:
            sss = sumarr[i] - 0
        else:
            sss = sumarr[i] - sumarr[i - k]
        maxSum.append(sss)

    print((k+max(maxSum))/2)


calculate(N, K, PRR)


Measured memory_bytes: 25320
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[i + i], self.seg[i + i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 16084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] as = br.readLine().split(" ");
		int a = Integer.parseInt(as[0]);
		int b = Integer.parseInt(as[1]);
		int c = Integer.parseInt(as[2]);
		if(a== b && c == b) {
			System.out.println("No");
		}else if(a ==b || c == a || b == c){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
int main(void){
	bool b=false;
	while(1){
		int a,n;
		string s;
		multimap<int, string, greater<int> > P;
		int w,d,l;
		cin >> n;
		if(n==0)break;
		if(b==true)cout << endl;
		b=true;
		for(a=0;a<n;a++){
			 cin >> s >> w >> l >> d; 
			P.insert( pair<int, string>(w*3+d,s));
		}
		multimap<int, string, greater<int> >::iterator it = P.begin();
		while( it != P.end() )	{
			cout << (*it).second << "," << (*it).first << endl;
			++it;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
p = [int(input()) for _ in range(n)]

indeces = [0] * n

for i in range(n):
	indeces[p[i] - 1] = i

ans = 0
pre_ans = 0

for i in range(n - 1):
	if indeces[i] < indeces[i + 1]:
		pre_ans += 1
	else:
		if pre_ans > ans:
			ans = pre_ans
		pre_ans = 0

if pre_ans > ans:
	ans = pre_ans

print(n - ans - 1)

Measured memory_bytes: 18996
N=input()
a,b,c,d=int(N[0]),int(N[1]),int(N[2]),int(N[3])

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
elif a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
elif a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
elif a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
elif a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
elif a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
elif a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
elif a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))



Measured memory_bytes: 38256
def solve(N, A):
    c = int(N / 2)
    left = sorted(A)[c - 1]
    right = sorted(A)[c]
    if left == right:
        for x in range(N):
            print(left)
        return;
    for x in range(N):
        if A[x] <= left:
            print(right)
        if A[x] >= right:
            print(left)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)


Measured memory_bytes: 26772
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main(){
  
  int q, com, x;
  set<int> S;
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> com;
    
    if(com == 0){
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
    }else if(com == 1){
      cin >> x;
      cout << S.count(x) << endl;
    }else if(com == 2){
      cin >> x;
      S.erase(x);
    }
  }
  
  return 0;
}


Measured memory_bytes: 12500
a, b, c, x, y=map(int, input().split())
ans = float("inf")
for i in range(max(x,y)+1):
  pa=max(0,x-i)
  pb=max(0,y-i)
  temp = c*2*i+a*pa+b*pb
  ans=min(ans,temp)
print(ans)

Measured memory_bytes: 65784
#include<bits/stdc++.h>
using namespace std;
const int N=55;
long long dp[N][N*N];
int main()
{
	int n,a;
	cin>>n>>a;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		for(int j=i-1;j>=0;j--)
			for(int k=0;k<=N*j;k++)
				dp[j+1][k+x]+=dp[j][k];
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
			ans+=dp[i][i*a];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define ANS_MAX 1000000000
#define M_MAX 1000
#define N_MAX 12
using namespace std ;

long dp[M_MAX][1<<N_MAX];
long price[M_MAX];
vector< vector<int> > keys(M_MAX);
int n, m;

long caldp(int k, int close){
    if(k==m) return close==0?0:ANS_MAX;
    if(close==0) return dp[k][close]=0;
    if(dp[k][close]>0) return dp[k][close];
    long ret=caldp(k+1, close);
    int nextClose=close;
    for(int key:keys[k]){
        if((close&(1<<key))!=0) nextClose-=(1<<key);
    }
    return dp[k][close]=min(ret, caldp(k+1, nextClose)+price[k]);
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int b;
        int key;
        cin>>price[i]>>b;
        for(int j=0;j<b;j++){
            cin>>key;
            keys[i].push_back(key-1);
        }
    }
    long ans=caldp(0, (1<<n)-1);
    ans=ans<ANS_MAX?ans:-1;
    cout<<ans<<endl;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  bool ok=true;
  ll pt=0,px=0,py=0;
  rep(i,n){
    ll t,x,y; cin>>t>>x>>y;
    if(t-pt<abs(px-x)+abs(py-y)) ok=false;
    else if((t-pt)%2!=(abs(px-x)+abs(py-y))%2) ok=false;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;

int main() {
	cin >> N;
	cout << (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

bool contain(int array[11], int a)
{
    for (int i = 1; i <= 10; i++)
    {
        if (array[i] == a)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int N, M;
    int k[11];
    int s[11][11];
    bool p[11];
    int count[11];
    rep(i, 11)
    {
        count[i] = 0;
        p[i] = 0;
        k[i] = 0;
        rep(j, 11)
        {
            s[i][j] = 0;
        }
    }
    cin >> N >> M;
    for (int i = 1; i <= M; i++)
    {
        cin >> k[i];
        for (int j = 1; j <= k[i]; j++)
        {
            cin >> s[i][j];
        }
    }
    for (int i = 1; i <= M; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        rep(i,11)
        {
            count[i] = 0;
        }
        int c = 0;
        for (int i = 1; i <= N; i++)
        {
            if (bit & (1 << (i - 1))) //i番目のスイッチがオンなら
            {
                for (int j = 1; j <= M; j++)
                {
                    if (contain(s[j], i))
                    {
                        count[j]++;
                    }
                }
            }
        }
        for (int i = 1; i <= M; i++)
        {
            if (count[i] % 2 == p[i])
            {
                c++;
            }
        }
        if (c == M)
        {
            ans++;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // https://atcoder.jp/contests/abc147/submissions/8921445
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        N : i32,
        arr : [[(i32,i32)];N]
    );

    let mut ans = 0;
    for mask in 0..1 << N {
        let mut ok = true;
        for i in 0..N {
            if mask >> i & 1 == 1 {
                for j in 0..arr[i as usize].len() {
                    let p = arr[i as usize][j as usize];
                    // check contradiction
                    if mask >> (p.0 - 1) & 1 ^ p.1 == 1 {
                        ok = false;
                    }
                }
            }
        }
        if ok && (ans as u32).count_ones() < (mask as u32).count_ones() {
            ans = mask;
        }
    }
    println!("{}", ans.count_ones());
}

Measured memory_bytes: 4352
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e5+10;
vi g[mxn];
bool vis[mxn];
int n,m;
int d[mxn];

void dfs(int v){
	d[v]=0;
	vis[v] =1 ;
	for(int u : g[v]){
		if(!vis[u]){
			dfs(u);

		}
		d[v] = max(d[v],d[u]+1);
	}
}

int32_t main(){
	NINJA;

	cin >> n >> m;
	fo(i,m){
		int u,v; cin >> u >> v;
		g[u].pb(v);
	}

	for1(i,n){
		if(!vis[i]){
			dfs(i);
		}
	}
	int mx = 0;
	for1(i,n) mx = max(mx,d[i]);
	cout << mx << endl;

	
	return 0;
}

Measured memory_bytes: 12608
N,M=map(int,input().split())

Pre=[[] for _ in range(N)]
for i in range(M):
    p,y=map(int,input().split())
    Pre[p-1].append([y,i+1])

ID=[0 for _ in range(M)]
for j in range(N):
    Pre[j].sort()
    for k in range(len(Pre[j])):
        ID[Pre[j][k][1]-1]=str(j+1).zfill(6)+str(k+1).zfill(6)

for d in ID:
    print(d)

Measured memory_bytes: 39108
#include<iostream>
#include<set>
#include<vector>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int>a(N),index(N+1);
    for(int i=0;i<N;i++)
    {
        cin>>a[i];
        index[a[i]]=i;
    }
    
    set<int>left={-1,N},right={-1,N};
    
    long long int anser=0;
    
    for(int i=1;i<=N;i++)
    {
        int ind=N-1-index[i];
        anser+=(long long int)i*(*right.upper_bound(index[i])-index[i])*(*left.upper_bound(ind)-ind);
        right.insert(index[i]);
        left.insert(ind);;
    }
    
    cout<<anser<<"\n";
    
    return 0;
}

Measured memory_bytes: 20608