akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll C[80][80];
void init(){
  memset(C, 0, sizeof(C));
  for(int i = 0; i <= 60; i++){
    C[i][0] = 1;
    for(int j = 1; j <= i; j++){
      C[i][j] = (C[i-1][j-1] + C[i-1][j]);
    }
  }
}
string solve(int N, ll M){
  M--;
  if(M == 0) return string(N, '0');
  if(M == (1LL << N) - 1) return string(N, '1');
  ll cur = 1;
  int cnt = -1;
  for(int l = 1; l <= N; l++){
    if(l == N) return "ERROR";
    if(cur + C[N][l] > M){
      M -= cur;
      cnt = l;
      break;
    }
    cur += C[N][l];
  }
  // (0, 1) = (N - cnt, cnt) , M \in [0, C[N][cnt])
  string res(N, '0');
  for(int i = 0; i < N; i++){
    if(C[N - i - 1][cnt] > M){
      res[i] = '0';
    }else{
      // M >= Combination
      M -= C[N - i - 1][cnt];
      cnt--;
      res[i] = '1';
    }
  }
  return res;
}
int main(){
  init();
  int N;
  ll M;
  while(cin >> N >> M && N){
    cout << solve(N, M) << endl;
  }
  return 0;
}

Measured memory_bytes: 1268
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100
x = np.arange(1,U,dtype=np.int64)
div = x[N%x==0]
answer = (div + (N//div)).min() - 2
print(answer)


Measured memory_bytes: 29012
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int min = 32;
	int n;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i){
		int a;
		scanf("%d", &a);
		a = a ^ (a - 1);
		a = (a & 0x55555555) + ((a >> 1) & 0x55555555);
		a = (a & 0x33333333) + ((a >> 2) & 0x33333333);
		a = (a & 0x0f0f0f0f) + ((a >> 4) & 0x0f0f0f0f);
		a = (a & 0x00ff00ff) + ((a >> 8) & 0x00ff00ff);
		a = (a & 0x0000ffff) + ((a >> 16) & 0x0000ffff);
		if (a - 1 < min)min = a - 1;
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int gcd(int a, int b) {

	int c;

	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}

	return b;

}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N);
	
	REP(i, N) {
		cin >> A[i];
	}

	B[1] = A[0];
	C[N - 2] = A[N - 1];

	for (int i = 1; i < N - 1; i++) {
		B[i + 1] = gcd(B[i], A[i]);
	}
	for (int i = N - 2; i > 0; i--) {
		C[i - 1] = gcd(C[i], A[i]);
	}
	/*
	for (int i = 1; i < N; i++) {
		cout << B[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << C[i] << " ";
	}
	cout << endl;
	*/
	int max_gcd = max(B[N - 1], C[0]);

	for (int i = 1; i < N - 1; i++) {
		max_gcd = max(max_gcd, gcd(B[i], C[i]));
	}

	cout << max_gcd << endl;

	return 0;
}

Measured memory_bytes: 1408
import sys

def main():
    input = sys.stdin.readline
    X = list(map(int, input().split()))

    diffx = X[2] - X[0]
    diffy = X[3] - X[1]

    f1 = 'U' * diffy + 'R' * diffx 
    b1 = 'D' * diffy + 'L' * diffx
    f2 = 'L' + 'U' * (diffy + 1) + 'R' * (diffx + 1) + 'D'
    b2 = 'R' + 'D' * (diffy + 1) + 'L' * (diffx + 1) + 'U'

    return f1 + b1 + f2 + b2


if __name__ == '__main__':
    print(main())


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

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

int main(){
  int n;
  cin >> n;
  vector<ll> p2(30);
  p2.at(0)=1;
  int i,j;
  for(i=1;i<30;i++){
    p2.at(i)=p2.at(i-1)*2;
  }
  
  vector<ll> a(n);
  vector<vector<int>> d(n,vector<int>(30,0));
  for(i=0;i<n;i++){
    cin >> a.at(i);
    for(j=0;j<30;j++){
      d.at(i).at(j)=a.at(i)%2;
      a.at(i) /= 2;
    }
  }
  
  for(j=0;j<30;j++){
    int k=0;
    for(i=0;i<n;i++){
      k += d.at(i).at(j);
    }
    if(k%2==1){
      for(i=0;i<n;i++){
        d.at(i).at(j)=1-d.at(i).at(j);
      }
    }
  }
  
  for(i=0;i<n;i++){
    a.at(i)=0;
    for(j=0;j<30;j++){
      a.at(i) += d.at(i).at(j)*p2.at(j);
    }
  }
  
  cout << a.at(0);
  for(i=1;i<n;i++){
    cout << ' ' << a.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 34408
#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 main()
{
	int N;
	cin >> N;
	if (N % 1000 == 0) cout << 0 << endl;
	else cout << 1000 - (N % 1000) << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int N;
  cin>>N;
  string S;
  int size,digitSum=0;
  
  S=to_string(N);
  size=S.size();

  FOR(i,0,size){
    digitSum+=S[i]-'0';
  }

  if( N % digitSum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}



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

using namespace std;

int main () {
    string str;
    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";

    while (cin >> str) {
        cout << m[str] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n,m;
	cin>>n>>m;
	int a[m];
	rep(i,m){
		cin>>a[i];
		n-=a[i];
	}
	if(n<0){
		cout<<-1;
	}
	else{
		cout<<n;
	}
	re 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,te=0,fw=0; cin>>n; 
    string  s; cin>>s;
    for (int i=0;i<n;i++)
        if (s[i]=='E') te++;
    int ans=te; 
    for (int i=0;i<n;i++){
        if (s[i]=='E') te--;
        ans = min(ans,te+fw);
        if (s[i]=='W') fw++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3880
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    char b;
    cin >> b;
    
    if(b=='A'){
        cout << 'T' << endl;
    }
    else if(b=='T'){
        cout << 'A' << endl;
    }
    else if(b=='C'){
        cout << 'G' << endl;
    }
    else if(b=='G'){
        cout << 'C' << endl;
    }
}


Measured memory_bytes: 256
import math
import itertools
N = int(input())
xys = []
for i in range(N):
  x, y = map(int, input().split())
  xys.append((x, y))
ls = []
for Is in itertools.permutations(range(N)):
  l = 0
  for i in range(1, N):
    a, b = xys[Is[i-1]]
    x, y = xys[Is[i]]
    l += math.sqrt((x-a)**2+(y-b)**2)
  ls.append(l)
r = sum(ls)/len(ls)
print(r)


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

int main() {
    // cin.tie(0); ios::sync_with_stdio(0);
    int ans = 0;
    string a, b;
    cin >> a >> b;
    for (int i=0; i<a.size(); i++) {
        if (a[i] != b[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
#!/usr/bin/env python3
import sys

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def accum(s):
    value = 1
    for ss in s:
        value = value*ss
    return value

def solve(N: int):
    divisors = divisor(N)
    divisors.sort()
    answer = 10**12
    LEN = len(divisors)
    for i in range(0,LEN):
        seki = divisors[i]+divisors[LEN-1-i]
        answer = min(answer,seki)

    print(answer-2)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

using namespace std;

int N, c[200009], dp[200009], f[200009];
const int mod = 1e9 + 7;

void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &c[i]);
c[N + 1] = -1;
f[c[1]] = 1;
for (int i=1; i<=N; i++)
{
    if (c[i] == c[i + 1]) dp[i] = 0;
    else
    {
        dp[i] = f[c[i]];
        if (i < N)
            adto (f[c[i + 1]], dp[i]);
    }
}
printf ("%d\n", dp[N]);
return 0;
}


Measured memory_bytes: 2560
#include<cmath>
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
	string s;
	while(cin>>s,s!="#"){
		string ans="no";
		int n=s.size();
		for(int i=0;i<n;i++){
			if(s[i]=='('){
				string t;
				for(int j=i+1;j<n;j++){
					if(s[j]==')'){
						t=s.substr(i+1,j-i-1);
						break;
					}
				}
				int m=t.size();
				bool flag=true;
				//cout<<t<<endl;
				for(int j=0;j<m;j++){
					if(isalpha(t[j])){
						for(int k=j+1;k<m;k++){
							if(t[j]==t[k]){
								//cout<<"-----"<<endl;
								if(j==0){
									if(t[k-1]=='&'){
										
									}else{
										flag=false;
										break;
									}
								}else if(t.substr(j-1,2)!=t.substr(k-1,2)){
									//cout<<t.substr(j-1,2)<<" "<<t.substr(k-1,2)<<endl;
									flag=false;
								}
								
								
							}
							
						}
					}
				}
				if(flag){
					ans="yes";
				}
			}
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    for(int i=0; i<s.length(); i++){
        int c = (int)s[i]-(int)'A';
        c+=n;
        c%=26;
        c+='A';
        s[i] = (char)c;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long m[100005]={0},n,sum;
long long read(){
    long long ans=0;
    char last=' ',ch=getchar();
    while(ch<'0' || ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
int main()
{
    n=read();
    for(long long i=1;i<=n;i++)
    {
        int temp=read();
        m[temp]++;
        sum+=temp;
	}
    int q=read();
    int a,b;
    while(q--)
    {
        cin>>a>>b;
        sum+=m[a]*(b-a);
        m[b]+=m[a];
        m[a]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 4364
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

vector<int> erts(){
  vector<int> v(1000001,1);
  v[0]=v[1]=0;
  for(int i=2;i<=1000;++i)
    if(v[i])
      for(int j=i*i;j<=1000000;j+=i)
        v[j]=0;
  return v;
}

int main() {
  vector<int> pl = erts();
  while(1){
    int a,d,n;
    cin>>a>>d>>n;
    if(!a)break;
    while(1){
      if(pl[a]){
        if(n==1){
          cout<<a<<endl;
          break;
        }else{
          --n;
        }
      }
      a += d;
    }
  }
  return 0;
}

Measured memory_bytes: 4892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c, m;
    cin >> a >> b >> c;
    m = a * 10 + b + c;
    m = max(m, a + 10 * b + c);
    m = max(m, a + b + 10 * c);
    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

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

const int mod = 1e9 + 7;

signed main()
{
  int N;
  int sum = 1;
  int cnt[1005] = {0};
  bool prime[1005] = {0};

  cin >> N;
  
  for(int i = 2; i * i <= N; i++) {
    if(!prime[i]) {
      for(int j = i * i; j <= N; j += i) prime[j] = true;
    }
  }    
  
  for(int i = 2; i <= N; i++) {
    if(!prime[i]) {
      for(int j = i; j <= N; j += i) {
	int val = j;
	while(!(val % i)) cnt[i]++, val /= i;
      }
      (sum += sum * cnt[i]) %= mod;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String S=gs();
       int c=0;
       int i=0;
       int e=S.length()-1-i;
        while(i<e) {
        	if(S.charAt(i) != S.charAt(e)) {
        		c++;
        	} 
        	i++;
        	e=S.length()-1-i;
        }


        System.out.print(c);

//        if (N%2==0 && s.substring(0, N/2).equals(s.substring(N/2))) {
//        	System.out.println("Yes");
//        }else{
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;
using ll = long long;

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

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int l[n], r[n];
  l[0] = r[n - 1] = 0;
  rep(i, n - 1) l[i + 1] = gcd(l[i], a[i]);
  for (int i = n - 1; i >= 1; --i) r[i - 1] = gcd(r[i], a[i]);

  int ans = 1;
  rep(i, n) ans = max(ans, gcd(l[i], r[i]));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4740
import itertools
N,M = map(int, input().strip().split(' '))
A = [input().strip() for _ in range(N)]
B = [input().strip() for _ in range(M)]
for i,j in itertools.product(range(N-M+1), repeat=2):
  if sum(A[y+i][j:j+M] == B[y] for y in range(M)) == M:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
N, M, C=(int(x) for x in input().split())
B = list(map(int, input().split()))
A = [([] for _ in range(M)) for _ in range(N)]
cou = 0

for i in range(N):
    A[i] = list(map(int, input().split()))

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

print(cou)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define fz1(i,n) for((i)=1;(i)<=(n);(i)++)
using namespace std;
const int mod=998244353;
int n,m,i,j,k,a[405],b[405],s,fac[405],inv[405],fi[405],ans;
vector<int> dp[405],v[405];
vector<int> sub(vector<int> a,vector<int> b)
{
	int i;
	vector<int> c;
	for(i=0;i<a.size()||i<b.size();i++){
		int t=0;
		if(i<a.size()) t=(t+a[i])%mod;
		if(i<b.size()) t=(t-b[i]+mod)%mod;
		c.push_back(t);
	}
	return c;
}
vector<int> mul(vector<int> a,vector<int> b)
{
	int i,j;
	vector<int> c;
	if(!a.size()||!b.size()) return c;
	c.resize(a.size()+b.size()-1);
	for(i=0;i<a.size();i++)for(j=0;j<b.size();j++){
		c[i+j]=(c[i+j]+1ll*a[i]*b[j])%mod;
	}
	return c;
}
int main()
{
	fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;
	for(i=2;i<=400;i++){
		fac[i]=1ll*i*fac[i-1]%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fi[i]=1ll*fi[i-1]*inv[i]%mod;
	}
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d%d",&a[i],&b[i]);
		s+=a[i];
	}
	fz1(i,n){
		int t=1;
		for(j=0;j<b[i];j++){
			v[i].push_back((1ll*t*fi[j])%mod);
			t=1ll*t*a[i]%mod;
		}
/*		for(j=0;j<v[i].size();j++){
			cerr<<v[i][j]<<' ';
		}
		cerr<<endl;*/
	}
	dp[0].push_back(mod-1);
	fz1(i,n){
		for(j=s;j>=a[i];j--)if(dp[j-a[i]].size()){
			dp[j]=sub(dp[j],mul(dp[j-a[i]],v[i]));
/*			for(k=0;k<dp[j].size();k++){
				cerr<<dp[j][k]<<' ';
			}
			cerr<<endl;*/
		}
	}
	fz1(i,s){
		int t=1;
		for(j=0;j<dp[i].size();j++){
//			cerr<<dp[i][j]<<' ';
			t=1ll*t*inv[i]%mod;
			ans=(ans+1ll*fac[j]*dp[i][j]%mod*t)%mod;
//			cerr<<ans<<' ';
/*			if(ans==877213285){
				int x;
				x++;
			}*/
		}
//		cerr<<endl;
	}
	cout<<1ll*ans*s%mod<<endl;
	return 0;
}

Measured memory_bytes: 1024
while True:
    try:
        x = map(float, raw_input().split(" "))
        a = (x[2]*x[4]-x[1]*x[5])/(x[0]*x[4]-x[1]*x[3])
        b = (-x[3]*x[2]+x[0]*x[5])/(x[0]*x[4]-x[1]*x[3])
         
        if a == -0: a = 0
        if b == -0: b = 0
         
        print "%.3f %.3f" % (a, b)
     
    except EOFError:
        break

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    lint ans = ((N - M) * 100 + 1900 * M) * (1 << M);
    cout << ans << "\n";
}

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> a(N);
	for(int i(0);i<M;++i){
		int k;
		cin >> k;
		for(int j(0);j<k;++j){
			int s;
			cin >> s;
			s--;
			a[s] |= 1 << i;
		}
	}
	int p(0);
	for(int i(0);i<M;++i){
		int x;
		cin >> x;
		p |= x << i;
	}
	int ans(0);
	for(int s(0);s<(1<<N);s++){
		int t(0);
		for(int i(0);i<N;++i){
			if(s>>i & 1){
				t ^= a[i];
			}
		}
		if(t == p){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,ans;

void solve()
{
    for(i=1;i<=5;++i)
    {
        int x;
        cin>>x;
        if(!x)
            ans=i;
    }
    cout<<ans;
}

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

Measured memory_bytes: 3532
/*
 *  Created on: 24-October-2019
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
 
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n; cin>>n;
    int W; cin>>W;
    lli w[n+1], v[n+1];
    fi(i,1,n+1) cin>>w[i]>>v[i];
    lli dp[n+1][W+1];
    fi(i,0,n+1)
    {
    	fi(j,0,W+1)
    	{
    		if(i==0 || w==0) dp[i][j] = 0;
    		else if(j - w[i] >= 0)
    		{
    			dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i]] + v[i]);
    		}
    		else
    		{
    			dp[i][j] = dp[i-1][j];
    		}
    	}
    }
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79232
# 初期入力
import sys
input = sys.stdin.readline
N,X = (int(i) for i in input().split())
DP_all  =[0]*(N+1)
DP_p    =[0]*(N+1)
DP_all[0]   =1
DP_p[0]     =1

#レベル「i+1」バーガーの枚数
for i in range(N):
    DP_all[i+1] =DP_all[i] *2 +3
    DP_p[i+1]   =DP_p[i] *2  +1
#print("総枚数" ,DP_all)
#print("パティ枚数" ,DP_p)

#再帰でパティの枚数を求める L=レベル、x=食べる枚数
def  p_num(L,x):
    if x <=L:
        return 0
    if x ==DP_all[L]:
        return DP_p[L]
    elif x < DP_all[L] //2 +1:
        return p_num(L-1,x -1)
    elif x ==DP_all[L] //2 +1:
        return DP_p[L-1] +1
    elif x > DP_all[L] //2 +1:
        return DP_p[L-1] +1 +p_num(L-1,x -DP_all[L-1] -2)

ans =p_num(N,X)
print(ans)

Measured memory_bytes: 9112
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb(n) push_back(n)
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
#define PI 3.141592653589793
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	double a,b,h,m,am,hm,an,ct,c2;
	cin>>a>>b>>h>>m;
	am=m*6;
	hm=h*30;
	hm+=(30.0/60.0)*m;
	an=abs(am-hm);
	ct=cos((an*PI)/180.0);
	c2=(a*a)+(b*b)-(2*a*b*ct);
	cout<<setprecision(12)<<sqrt(c2);
	return;
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4216
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Scc {
    const int V; // ????????属
    vector<vector<int> > G, revG; // ??属???????????贈??\???????????即?????即??????????????属??????
    vector<int> order; // scc()????????其??即????????????????????????????????\???

    vector<int> vs; // ??属???????????????
    vector<char> used; // bfs??即(vector<bool>??????????????????char?????????)

    // @param v ????????属
    Scc(int v) : V(v), G(v), revG(v), order(v), used(v) { }

    void add_edge(int from, int to) {
        G[from].push_back(to);
        revG[to].push_back(from);
    }

    void dfs(int v) {
        used[v] = true;
        for(int to : G[v]) {
            if(used[to] == false) dfs(to);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k) {
        used[v] = true;
        order[v] = k;
        for(int to : revG[v]) {
            if(used[to] == false) rdfs(to, k);
        }
    }

    // @return ?????贈??????????????属??????DAG????????贈?????即??????????????属
    int compute() {
        vs.clear();
        fill(used.begin(), used.end(), false);
        for(int i = 0; i < V; i++) {
            if(used[i] == false) dfs(i);
        }

        int k = 0;
        reverse(vs.begin(), vs.end());
        fill(used.begin(), used.end(), false);

        for(int v : vs) {
            if(used[v] == false) rdfs(v, k++);
        }

        return k;
    }
};

int main() {
    int V, E; cin >> V >> E;
    Scc g(V);
    while(E--) {
        int s, t; cin >> s >> t;
        g.add_edge(s, t);
    }
    g.compute();

    int Q; cin >> Q;
    while(Q--) {
        int u, v; cin >> u >> v;
        if(g.order[u] == g.order[v]) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 2708
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e9+7;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);


int main()
{
    TB
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<'\n';
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
  	int n,k;
  	cin >> n >> k;
  	int a[k];
  
  	rep(i,0,k){
      cin >> a[i];
    }
  
  	sort(a,a+k,greater<int>());
  
  	a[0]--;
  
  	rep(i,1,k){
      a[0] -= a[i];
    }
  
  	cout << max(0,a[0]) << endl;
  
  	
  
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main(){
	int n,k,q;
	scanf("%d %d %d",&n,&k,&q);
	for(int i = 1;i <= q;i++)
	{
		int t;
		scanf("%d",&t);
		a[t]++;
	}
	for(int i = 1;i <= n;i++)
	{
		if(k - (q - a[i]) > 0)
			printf("Yes\n");
		else
			printf("No\n");
	}	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int calc(vector<string> s,int& i,int k){
    if(isdigit(s[i][k])){
        i++;
        return s[i-1][k]-'0';
    }
    char op=s[i][k];
    i++;
    ll ret=calc(s,i,k+1);
    while((int)s[i].size()>k+1){
        ll res=calc(s,i,k+1);
        if(op=='+')ret=ret+res;
        if(op=='*')ret=ret*res;
    }
    return ret;
}

int main(){
    int n;
    while(cin>>n,n!=0){
        vector<string> v;
        rep(i,n){
            string s;cin>>s;
            v.push_back(s);
        }
        v.push_back("");
        int j=0;
        cout<<calc(v,j,0)<<endl;
    }
    return 0;
}


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

//作業用配列
static int *buff;

static void margesort_all(int a[], int left, int right)
{
    //配列の先頭と末尾を比較
    if (left < right){
        int center = (left + right) / 2;
        int p = 0;
        int i;
        int j = 0;
        int k = left;
        
        //前半部をマージソート
        margesort_all(a, left, center);
        //後半部をマージソート
        margesort_all(a, center + 1, right);

        //配列の前半部a[left] ~ a[center]をbuff[0] ~ buff[center - left]にコピー
        for (i = left; i <= center; i++){
            buff[p++] = a[i];
        }

        //配列の後半部a[left] ~ a[center]とbuffにコピーした配列の前半部をマージした結果を配列aに格納
        while (i <= right && j < p){
            a[k++] = (buff[j] >= a[i]) ? buff[j++] : a[i++];
        }

        //配列buffに残った未格納部分の要素を配列aにコピー
        while (j < p){
            a[k++] = buff[j++];
        }
    }
}

int margesort(int a[], int n)
{
    //マージ結果を一時格納するための作業配列buffを生成
    if ((buff = calloc(n, sizeof(int))) == NULL){
        return (-1);
    }

    //配列全体をマージソート
    margesort_all(a, 0, n - 1);

    free(buff);

    return (0);
}

int main(void)
{
    int i, nx;
    //配列の先頭要素へのポインタ
    int *x;

    nx = 5;
    //calloc関数を用いてint型要素数5の配列xを生成
    x = calloc(nx, sizeof(int));

    //配列に数字を挿入
    for (i = 0; i < nx; i++){
        scanf("%d", &x[i]);
    }

    //配列xをマージソート
    margesort(x, nx);

    //ソートした配列を表示
    for (i = 0; i < 4; i++){
        printf("%d ", x[i]);
    }
    printf("%d\n", x[4]);

    //配列を破棄
    free(x);

    return (0);
}



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

using namespace std;

constexpr int N = 500000;

long long a[N + 5];
char s[N + 5];

int main() {
	queue<int> q;
	int n, u, i;
	long long ans;

	memset(a, -1, sizeof(a));
	scanf("%s%n", s + 1, &n);
	n++;

	if (s[1] == '<') {
		a[1] = 0;
		q.push(1);
	}

	if (s[n - 1] == '>') {
		a[n] = 0;
		q.push(n);
	}

	for (i = 2; i <= n - 1; i++) {
		if (s[i - 1] == '>' and s[i] == '<') {
			a[i] = 0;
			q.push(i);
		}
	}

	while (!q.empty()) {
		u = q.front();
		q.pop();

		if (s[u - 1] == '>' and a[u - 1] == -1) {
			a[u - 1] = a[u] + 1;
			q.push(u - 1);
		}

		if (s[u] == '<' and a[u + 1] == -1) {
			a[u + 1] = a[u] + 1;
			q.push(u + 1);
		}
	}

	ans = 0;

	for (i = 2; i <= n - 1; i++) {
		if (s[i - 1] == '<' and s[i] == '>') {
			a[i] = 1 + max(a[i - 1], a[i + 1]);
		}

	}

	for (i = 1; i <= n; i++) {
		ans += a[i];
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 5504
S = str(input())
K = int(input())

L = len(S)
rtn = 0
las = False

if (L == 1):
    rtn = K // 2

else:
    ichi = 0
    mae = S[0]
    i = 1
    while(i < L):
        las = False
        if (S[i] == mae):
            ichi += 1
            i += 1
            las = True
        if (i < L):
            mae = S[i]
        i += 1

    if (las and (i == L+1)): #らすかえた
        rtn = ichi * K

    else: #らすかえてない
        ni = 0
        mae = S[L-1]
        i = 0
        while(i < L):
            las = False
            if (S[i] == mae):
                ni += 1
                i += 1
                las = True
            if (i < L):
                mae = S[i]
            i += 1

        if (las and (i == L+1)): #らすかえた
            T = K // 2
            rtn = ichi * (K - T) + ni * T
        else:
            rtn = ichi + ni * (K - 1)

print(rtn)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll x; cin >> x;
    ll q = x / 11;
    ll r = x % 11;
    if(r > 6) cout << 2*q+2 << endl;
    else if(r==0) cout << 2*q << endl;
    else cout << 2*q+1 << endl;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int N; cin>>N;
    vector<int> P(N),Q(N);
    for (int i = 0; i < N; ++i) cin>>P[i];
    for (int i = 0; i < N; ++i) cin>>Q[i];

    vector<int> p(N), q(N);
    p = min(P,Q); q = max(P,Q);
    int ans = 0;
    while(p<q){
        next_permutation(p.begin(),p.end());
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int N,i,j,v,A[1000];
  scanf("%d",&N);
  for(i=0;i<N;i++)
    { scanf("%d",&A[i]); }

  	for(j=0;j<N;j++)
	  {
	    printf("%d",A[j]);
	    if(j != N-1){printf(" ");}
	    else {printf("\n");}
	  }
  for(i=1;i<N;i++)
      { v=A[i];
      for(j=i-1;j>=0 && A[j]>v;j--)
	  {
	    A[j+1]=A[j];
	    A[j]=v;
	  }
	for(j=0;j<N;j++)
	  {
	    printf("%d",A[j]);
	    if(j != N-1){printf(" ");}
	    else {printf("\n");}
	  }
      }
    return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String coffee = sc.next();
    if(coffee.charAt(2) == coffee.charAt(3) && coffee.charAt(4) == coffee.charAt(5)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

const double pi = 3.14159265358979323846;
const int mod = 1000000007;

int main(){
  int N, K;
  cin >> N >> K;

  int x[100];
  for(int i=0; i<N; i++) cin >> x[i];

  int sum = 0;
  for(int i=0; i<N; i++){
    sum += 2 * min(x[i],abs(K-x[i]));
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())

# Nが奇数の場合、(N-自分)に対しては辺を貼らない
# Nが偶数の場合、(N+1-自分)に対しては辺を貼らない

ans = []
odd = (N%2 == 1)
def needs_edge(i,j,N,odd):
  if odd:
    if N-i == j:
      return False
  else:
    if N+1-i == j:
      return False
  return True

for i in range(1,N):
  for j in range(i+1,N+1):
    if needs_edge(i,j,N,odd):
      ans.append([i,j])

print(len(ans))
for a in ans:
  print(*a)


Measured memory_bytes: 4124
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

struct Edge {
  int src, dest;
  int comp;
};

using Edges = vector<Edge>;
using Graph = vector<map<int,Edges>>;

void add_edge(Graph& g, int s, int d, int c) {
  g[s][c].push_back(Edge{s,d,c});
  g[d][c].push_back(Edge{d,s,c});
}

using Graph2 = vector<Edges>;

void add_edge(Graph2& g, int d) {
  int term = g.size()-1;
  g[d].push_back(Edge{d,term,0});
  g.back().push_back(Edge{term,d,1});
}

int main()
{
  int n,m;
  cin>>n>>m;
  Graph g0(n);
  for (int i:irange(0,m)) {
    int p,q,c;
    cin>>p>>q>>c;
    --p;--q;
    add_edge(g0,p,q,c);
  }
  Graph2 g1(n);
  vector<set<int>> vis(1000001);
  for(int i:irange(0,n)) {
    for (auto& ve:g0[i]) {
      int comp = ve.first;
      if (vis[comp].count(i)) continue;
      vis[comp].insert(i);
      int term = g1.size();
      g1.emplace_back();
      add_edge(g1, i);
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int j = q.front();
        q.pop();
        for (auto& e:g0[j][comp]) {
          if(vis[comp].count(e.dest)) continue;
          vis[comp].insert(e.dest);
          add_edge(g1, e.dest);
          q.push(e.dest);
        }
      }
    }
  }
  deque<int> q;
  constexpr int INF = 1000000000;
  vecint d(g1.size(), INF);
  q.push_back(0);
  d[0] = 0;
  while (!q.empty()) {
    int i = q.front();
    q.pop_front();
    for (auto& e:g1[i]) {
      if (d[e.dest] > d[i]+e.comp) {
        d[e.dest] = d[i]+e.comp;
        if (e.comp) {
          q.push_back(e.dest);
        } else {
          q.push_front(e.dest);
        }
      }
    }
  }
  if (d[n-1] < INF) {
    cout<<d[n-1]<<endl;
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 138504
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    x.push_back(X);
    vector<int> y(M);
    rep(i, M) cin >> y[i];
    y.push_back(Y);
    
    int max_x = *max_element(x.begin(), x.end());
    int min_y = *min_element(y.begin(), y.end());
    
    if (max_x < min_y) cout << "No War" << endl;
    else cout << "War" << endl;
    
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		for(int i=1;i<=n;i++) {
			int cnt=0;
			int num=i;
			while(num>0) {
				cnt++;
				num/=10;
			}
			if(cnt%2!=0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

struct Point{
    int x,y,h;
};

int main(void){
    int n;
    cin>>n;
    vector<Point> vp(n);
    int tall = -1;
    rep(i,n){
        int x,y,h;
        cin>>x>>y>>h;
        vp[i] = Point{x,y,h};
        if (h > 0) tall = i;
    }
    assert(tall>=0);
    rep(x,101)rep(y,101){
        int h = abs(vp[tall].x-x) + abs(vp[tall].y-y) + vp[tall].h;
        bool ng = false;
        rep(i,n){
            if (vp[i].h != max(h - abs(vp[i].x-x) - abs(vp[i].y-y), 0)) {
                ng = true;
            }
        }
        if (!ng) {
            cout << x << " " << y << " " << h << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

bool pal(string s) {
  string s2 = s;
  reverse(s2.begin(), s2.end());
  return s == s2;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  map<ll, ll> par;
  ll arr[n + 5];
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    par[arr[i]]++;
  }
  ll res = 0;

  for (auto &it : par) {
    res += it.second * (it.second - 1) / 2;
  }

  for (ll i = 1; i <= n; i++) {
    cout << res - (par[arr[i]] - 1) << en;
  }
  return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s;
    cin >> s;
    vll count(26);
    char c[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    rep(i,26){
        count[i] = 0;
        rep(j,SIZE(s))if(s[j] == c[i])count[i]++;
        if(count[i] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

int main() {

    int a[3][3];
    rep(i,3) {
        rep(j,3) {
            cin>> a[i][j];
        }
    }
    int n;
    cin>>n;
    vector<int> b(n);
    rep(i,n)    cin>>b[i];

    rep(i,n) {
        rep(j,3) {
            rep(k,3) {
                if(a[j][k]==b[i]) {
                    a[j][k]=0;
                }
            }
        }
    }

    if(a[0][0]==0&&a[0][1]==0&&a[0][2]==0)  cout<<"Yes"<<endl;
    else if(a[0][0]==0&&a[1][0]==0&&a[2][0]==0) cout<<"Yes"<<endl;
    else if(a[1][0]==0&&a[1][1]==0&&a[1][2]==0) cout<<"Yes"<<endl;
    else if(a[2][0]==0&&a[2][1]==0&&a[2][2]==0) cout<<"Yes"<<endl;
    else if(a[0][1]==0&&a[1][1]==0&&a[2][1]==0) cout<<"Yes"<<endl;
    else if(a[0][2]==0&&a[1][2]==0&&a[2][2]==0) cout<<"Yes"<<endl;
    else if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0) cout<<"Yes"<<endl;
    else if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    

 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  // 入力 (n∈３桁の整数, 100<=N<=999)
  int n;
  cin >> n;
  // nが回文数ならYes、でないならNo、を出力
  // 回分数：10進数で逆に並べても同じ数
  cout << (n/100 == n%10? "Yes":"No") << endl;
  return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 0, n){
        int p;
        cin >> p;
        ans += (p-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568