akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;
 
int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0, x = 0;
    int last, at;
    cin >> last;
    n--;
    while(n--) {
        cin >> at;
        if(at <= last) x++;
        else ans = max(ans,x), x = 0;
        last = at;
    }
    ans = max(ans,x);
    cout << ans << endl; 
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int a = reader.nextInt();
		int b = reader.nextInt();
		int c = reader.nextInt();
      System.out.println(a+b+c+Math.max(a,Math.max(b,c))*9);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21332
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
H = LI()

ans = 0
tmp = 0
now = H[0]
for i in range(1,N):
    if now >= H[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
    now = H[i]

ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 16644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[102][102],b[102][102],v[102],cnt[102][102],mat[102];
vector<int>zh[102][102];
int find(int x){
	int i;
	for(i=1;i<=n;i++)if(a[x][i]&&!v[i]){
		v[i]=1;
		if(!mat[i]||find(mat[i])){
			mat[i]=x;
			return 1;
		}
	}
	return 0;
}
int main(){
	int i,j,x,be,k,nt;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf("%d",&x);
			be=(x-1)/m+1;
			cnt[i][be]++;
			zh[i][be].push_back(x);
		}
	}
	for(i=1;i<=m;i++){
		//printf("%d\n",i);
		for(j=1;j<=n;j++)
		 for(k=1;k<=n;k++)a[j][k]=(cnt[j][k]!=0);
		memset(mat,0,sizeof(mat));
		for(j=1;j<=n;j++){
			memset(v,0,sizeof(v));
			assert(find(j));
		}
		//puts("-1");
		for(j=1;j<=n;j++){
			nt=mat[j];
			//printf("%d %d\n",j,nt);
			b[nt][i]=zh[nt][j].back();
			zh[nt][j].pop_back();
			cnt[nt][j]--;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)printf("%d ",b[i][j]);
		puts("");
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++)
		 for(k=j+1;k<=n;k++)if(b[j][i]>b[k][i])swap(b[j][i],b[k][i]);
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)printf("%d ",b[i][j]);
		puts("");
	}
}
/*
做m次二分图匹配
不知道为什么这是对的 
*/

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

int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int SUM(int n)
{
    int sum = 0;
    string s = to_string(n);
    for (int i = 0; i < s.length(); i++)
    {
        sum += ctoi(s[i]);
    }
    return sum;
}

int main()
{
    int n;
    cin >> n;
    if (n % SUM(n) == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int[] cost = new int[n];
    cost[0] = 0;
    cost[1] = Math.abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
      int cost1 = cost[i-1] + Math.abs(h[i] - h[i-1]);
      int cost2 = cost[i-2] + Math.abs(h[i] - h[i-2]);
      cost[i] = Math.min(cost1, cost2);
    }
    
    System.out.println(cost[n-1]);
  }
}


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

vector<int>g[200005];
int colr[200005];
int ans[200005];
void dfs(int cur,int par,int col){
   
    colr[cur] = col;  
    for(auto i: g[cur]){
      if( i != par) dfs(i,cur,3-col);
    }

}

int main(){

   int n;
   cin >> n;

   for(int i =0;i<n-1;i++){
        int u,v;cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
   } 
 //  cout << "input"<<endl;
   dfs(0,-1,1);
   int rc=0;
   int bc =0;
   for(int i =0;i<n;i++){
       if( colr[i] == 1) rc++;
       else bc++;
   }
   
  // cout << rc << " " << bc <<endl;

  vector<int> ans(n+1);
  int coltol = 1;
  if( rc > bc){
     rc^=bc^=rc^=bc;
     coltol = 2;
  }
  if( rc <= n/3){
   // cout <<"came here"<<endl;
  // for(int i =0;i<n;i++) cout << colr[i] <<" \n"[i==n-1];
    int i = 1;
    int k = 1;
    vector<int> used(n+1,0);
    while( i <=n){
      if( colr[i-1] == coltol) {
          ans[i] = 3*k;
          used[3*k] = 1;
          k++;
          i++;
          
      } else i++;
    }
   int p =1; 
  for(int i =1;i<=n;i++){
    if(!ans[i]){
        while(used[p]) p++;
        ans[i] = p;
        used[p] =1;
    }
  }
for(int i =1;i<=n;i++) cout << ans[i]<<" \n"[i==n];
  }
  else{
    int k =0;
    int l =0;
    for(int i =1;i<=n;i++){
       if(colr[i-1] == 1 && 3*k+1<=n) ans[i] = 3*k+1,k++;
       else if( colr[i-1] == 2 && 3*l+2<=n) ans[i] = 3*l +2,l++;
    }  
   // for(int i =1;i<=n;i++) cout << ans[i]<<" \n"[i==n];
    int m =1;

    for(int i =1;i<=n;i++){
      if(!ans[i]) ans[i] =3*m,m++;
    }
    
    for(int i =1;i<=n;i++) cout << ans[i]<<" \n"[i==n];

  }
 
}

Measured memory_bytes: 19072
C = []
for _ in range(3):
    c1, c2, c3 = map(int, input().split())
    tmp = [c1, c2, c3]
    C.append(tmp)

if not(C[0][0]-C[0][1] == C[1][0]-C[1][1] == C[2][0]-C[2][1]):
    print('No')
    exit(0)

if not(C[0][1]-C[0][2] == C[1][1]-C[1][2] == C[2][1]-C[2][2]):
    print('No')
    exit(0)

if not(C[0][0]-C[1][0] == C[0][1]-C[1][1] == C[0][2]-C[1][2]):
    print('No')
    exit(0)

if not(C[1][0]-C[2][0] == C[1][1]-C[2][1] == C[1][2]-C[2][2]):
    print('No')
    exit(0)
print('Yes')


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int C[3][3];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  rep(i, 3)rep(j, 3)cin >>C[i][j];
  rep(a1,101)rep(a2,101)rep(a3,101) {
    vector<int>a={a1,a2,a3};
    vector<int>b={C[0][0]-a1,C[1][1]-a2,C[2][2]-a3};
    bool ok = true;
    rep(i,3)rep(j,3)if (C[i][j]!=a[i]+b[j]) ok =false;
    if (ok) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x = 100000;
	int i,n;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		x = x * 1.05;
		if(x % 1000 != 0)
			x = (x/1000+1) * 1000;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<string.h>

int main(){
  char str[1024];
  int i;
  char *ret;

  scanf("%s",str);

if(
   (strstr(str,"S")==NULL && strstr(str,"N") != NULL) || (strstr(str,"N")==NULL && strstr(str,"S") != NULL) || (strstr(str,"W")==NULL && strstr(str,"E") != NULL) || (strstr(str,"E")==NULL && strstr(str,"W") != NULL))
   printf("No");
else
  printf("Yes");



return 0;

}

Measured memory_bytes: 128
def main():
    N, M = map(int, input().split())
    
    if N == M:
        ans = 1
        for i in range(1, N+1):
            ans *= i
            ans = ans % (10 ** 9 + 7)
        ans = (ans ** 2) * 2
    elif abs(N - M) == 1:
        ans = 1
        for i in range(1, N+1):
            ans *= i
            ans = ans % (10 ** 9 + 7)
        for i in range(1, M+1):
            ans *= i
            ans = ans % (10 ** 9 + 7)
    else:
        ans = 0

    print(ans % (10 ** 9 + 7))



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
# R[i]を山iからダムiへの流出量とすると次の漸化式が成り立つ
# R[i + 1] = A[i] - R[i]
# 山iへの降雨量は2 * R[i]
# 
# 仮にR[1] = rとすると
# R[2] = A[1] - r
# R[3] = A[2] - A[1] + r
# R[4] = A[3] - A[2] + A[1] - r
# R[N] = A[N-1] - A[N-2] .. - A[1] + r
# 
# 山1からダムNへの流出量はA[N] - R[N] (= r) なので
# A[N] - A[N-1] + A[N-2] .. + A[1] == 2 * r

N = gets.to_i
A = gets.split.map(&:to_i)
r = A.inject(0){|s,a| a - s} / 2
X = Array.new(N)
N.times.inject(r) do |s, i|
  X[i] = 2 * s
  A[i] - s
end
puts X * ' '


Measured memory_bytes: 15236
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const llint big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,m,k;cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i*j+(n-i)*(m-j)==k){cout<<"Yes"<<endl;return 0;}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

vector<int> prefix_function(vector<int> s) {
    int n = (int)s.size();
    vector<int> pi(n,0);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	int n;
	cin>>n;

	vector<int> a(n) , b(n) , c;
	for(int i=0 ; i<n ; ++i)
		cin>>a[i];
	for(int i=0 ; i<n ; ++i)
		cin>>b[i];

	for(int i=0 ; i<n ; ++i)
		c.push_back( b[i]^b[(i+1)%n] );

	c.push_back(-1);
	for(int i=0 ; i<n ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );
	
	for(int i=0 ; i<n-1 ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );

	vector<int> k = prefix_function(c);
	for(int i=0 ; i<k.size() ; ++i){
		if( k[i] == n ){
			int x = i - 2*n;
			cout<<x<<" "<<(b[0]^a[x])<<'\n';
		}
	}
}



Measured memory_bytes: 10092
package main

import "fmt"

const Q int = 1000000007

func main() {
	var N, ans int
	fmt.Scan(&N)
	ans = 1
	m := map[int]int{}
	for i := N; i > 0; i-- {
		d := prime(i)
		for k, v := range d {
			m[k] += v
		}
	}
	for _, v := range m {
		ans *= (v + 1)
		ans %= Q
	}
	fmt.Println(ans)
	//fmt.Println(m)
	//fmt.Println(len(m))
}

func prime(n int) map[int]int {
	r := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for {
			if n%i != 0 {
				break
			}
			r[i] += 1
			n /= i
		}
	}
	if n != 1 {
		r[n] = 1
	}
	return r
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += (n - 1) / i;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(void) {
    string s;
    string ans = "";
    cin >> s;
    for (int i=0; i<s.size()-8; i++) {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int x;
    cin >> x;
    out(x/3);
}


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

using namespace std;
using ll = long long;

int main() {
  vector<vector<int> > as(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> as[i][j];
  int n;
  cin >> n;
  vector<int> bs(n);
  rep(i, n) cin >> bs[i];
  bool ok = false;
  rep(i, 3) {
    int cnt = 0;
    rep(j, n) {
      if (bs[j] == as[i][0]) {
        cnt++;
      }
      if (bs[j] == as[i][1]) {
        cnt++;
      }
      if (bs[j] == as[i][2]) {
        cnt++;
      }
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
    cnt = 0;
    rep(j, n) {
      if (bs[j] == as[0][i]) {
        cnt++;
      }
      if (bs[j] == as[1][i]) {
        cnt++;
      }
      if (bs[j] == as[2][i]) {
        cnt++;
      }
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (bs[i] == as[0][0]) {
      cnt++;
    }
    if (bs[i] == as[1][1]) {
      cnt++;
    }
    if (bs[i] == as[2][2]) {
      cnt++;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cnt = 0;
  rep(i, n) {
    if (bs[i] == as[2][0]) {
      cnt++;
    }
    if (bs[i] == as[1][1]) {
      cnt++;
    }
    if (bs[i] == as[0][2]) {
      cnt++;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
N, M = [int(s) for s in input().split()]
AC = [0] * 10 ** 5
WA = [0] * 10 ** 5

wa = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if AC[p] == 0:
        if s == 'WA':
            WA[p] += 1
        else:
            AC[p] += 1

print(sum(AC), sum(map(lambda x: x[0] * x[1], zip(AC, WA))))

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

A.sort(reverse=True)
ans = 0
tmp = 0
j = 0
for i in range(len(A)-1):
    if i == 0:
        ans += A[0]
        j += 1
    elif i % 2 == 0:
        ans += tmp
    else:
        tmp = A[j]
        ans+=tmp
        j += 1
print(ans)

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

int main(){
	int n,m;	cin>>n>>m;
	int sum=0;
	for(int i=0;i<m;i++){
		int a;	cin>>a;
		sum+=a;
	}

	if(n-sum>=0)cout<<n-sum<<endl;
	else cout<<"-1"<<endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int c = 0, d = i;
		while (d >= 10) {
			c += d % 10;
			d /= 10;
		}
		c += d;
		if (c >= a && c <= b) ans += i;
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
// finish date: 2019/06/09

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int modpow(int a, int b) {
    if (b == 0) return 1;
    int temp = modpow(a, b / 2);
    if (b % 2 == 1) return mul(mul(temp, temp), a);
    else {
        return mul(temp, temp);
    }
}


string L;
int ans;


int dfs(int pos) {
    int tmp = 0;
    if (pos == L.length()) return 1;
    if (L[pos] == '1') {
        tmp = add(tmp, modpow(3, L.length() - pos - 1));
        tmp = add(tmp, mul(2,dfs(pos + 1)));
    } else {
        tmp = add(tmp, dfs(pos + 1));
    }
    return tmp;

}

int main() {
    cin >> L;
    ans = 0;
    ans = dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    String[] s= new String[n];
	    Map<String, Integer> m=new HashMap<String,Integer>();
	    int c=0;
	    for (int i=0; i<n; i++) {
	    	s[i]=gs();
	    	if (!m.containsKey(s[i])) {
	    		c++;
	    		m.put(s[i], 0);
	    	}
	    }
	   
	  
	    System.out.println(c);
	    
        //System.out.println(Math.pow(l/3, 3));
//        if (a<b) {
//        	System.out.print(Math.max(b-a-w, 0));
//        }else {
//        	System.out.print(Math.max(a-b-w, 0));
//        }


	}

	// 文字列として入力を取得
	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: 78856
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define whyqxxx
#define M N

int n, m;
int tot = 0, fir[N], nxt[N << 1], to[N << 1];
int x[N << 1], y[N << 1], z[N << 1];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int vis[N], d[N];

void dfs(int u) {
    vis[u] = 1;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (vis[v]) continue;
        dfs(v);
        if (d[v]) z[(i + 1) / 2] ^= 1, d[v] = 0, d[u] ^= 1;
    }
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i),
        addEdge(x[i], y[i]), addEdge(y[i], x[i]), d[x[i]] ^= 1, z[i] = 1;
    dfs(1);
    if (d[1]) {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= m; ++i)
        if (z[i]) printf("%d %d\n", x[i], y[i]);
        else printf("%d %d\n", y[i], x[i]);
    return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;

    if((a+b)>(a-b)&&(a+b)>a*b){
        cout<<a+b<<endl;
    }else if((a-b)>a*b)cout<<a-b<<endl;
    else cout<<a*b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

ll score(char rsp, int r, int s, int p) {
    if (rsp == 'r') return p;
    else if (rsp == 's') return r;
    else return s;
}

int main() {
    fast_io
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll total = 0;
    rep(i,n) {
        if (i >= k) {
            if (t[i-k] == t[i]) {
                t[i] = '#';
                continue;
            }
        }
        total = total + score(t[i], r, s, p);
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 512
K = int(input())
num = 0
gu = []
ki = []
for i in range(K):
  if i%2 == 0:
    gu.append(i)
  else:
    ki.append(i)
  a = len(gu)
  b = len(ki)
  num = a*b
  
print(num)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int a,b,sum = 0;
    scanf("%d %d",&a,&b);
    //printf("%d %d\n",a, b );
    for(int sockets = 1; sockets < b;) {
        --sockets;
        ++sum;
        sockets += a;
        //printf("%d %d\n", sockets,sum);
        }
    printf("%d\n", sum);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector <int> v(n);
  rep(i, n) {
    int a;
    cin >> a;
    v.at(a-1) = i+1;
  }
  rep(i, n) {
    cout << v.at(i) << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<int> toporogical_sort(const vector<vector<int> > g){
	int n = g.size();
	vector<int> in_degree(n,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_degree[g[i][j]]++;
		}
	}

	vector<int> res;
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_degree[i]==0) S.push(i);
	}

	while(!S.empty()){
		int p = S.top();
		S.pop();
		res.push_back(p);
		for(int i = 0; i < g[p].size(); i++){
			in_degree[g[p][i]]--;
			if(in_degree[g[p][i]]==0) S.push(g[p][i]);
		}
	}

	return res;
}

int main()
{
	int V,E;
	cin>>V>>E;
	vector<vector<int> > g(V,vector<int>());
	for(int i = 0; i < E; i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
	}

	vector<int> t_sort = toporogical_sort(g);
	for(int i = 0; i < t_sort.size(); i++){
		cout << t_sort[i] << endl;
	}

	return 0;
}


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

int main(){
  string a;
  cin>> a;
  int c = 0;
  if(a[0]=='1'){
    c=c+1;
  }
  if(a[1]=='1'){
    c=c+1;
  }
  if(a[2]=='1'){
    c=c+1;
  }
  cout << c << endl;
}

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

int main() {
    int N, K, ans=0;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=1;i<=N;i++) {
        cin >> A[i];
        if(A[i]>=K) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> monsters(n + 1);
    for (int i = 0; i < n + 1; i++) {
        cin >> monsters[i];
    }
    int last = monsters[0];
    ll killed = 0;
    for (int i = 1; i < n + 1; i++) {
        int kill;
        cin >> kill;
        int new_last = monsters[i];
        if (last < kill) {
            if (new_last + last > kill) {
                killed += kill;
                new_last -= kill - last;
            }
            else {
                killed += (new_last + last);
                new_last = 0;
            }
        }
        else {
            killed += kill;
        }
        last = new_last;
    }
    cout << killed;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
    string s;
    int res = 99999999;
    cin >> s;

    for (int i = 0; i < s.size() - 2; i++) {
        res = min(res, abs(753 - stoi(s.substr(i, 3))));
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char x, y;
    cin>>x;
    cin>>y;
    if(x > y)
    {
        cout<<">"<<endl;
    }
    else if(x == y)
    {
        cout<<"="<<endl;
    }
    else
    {
        cout<<"<"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
l = [int(x) for x in list(str(s))]

ans_a = 0
for i in range(len(s)):
	if i%2 ==0 and l[i] == 0:
		pass
	elif i%2==1 and l[i] ==1:
		pass
	else:
		ans_a += 1

ans_b = 0
for i in range(len(s)):
	if i%2 ==0 and l[i] == 1:
		pass
	elif i%2 ==1 and l[i] == 0:
		pass
	else:
		ans_b += 1
print(min(ans_b,ans_a))

Measured memory_bytes: 4724
def make_comb_dp(n):
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1
        dp[i][i] = 1
    for i in range(2, n + 1):
        for j in range(1, i):
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
    return dp

mod=10**9+7
N,K=map(int,input().split())
C=make_comb_dp(N)
for i in range(1,K+1):
    print(int(C[N+1-K][i]*C[K-1][i-1])%mod)


Measured memory_bytes: 478976
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	for(int i=0;i<b.size();i++){
		cout<<a[i]<<b[i];
	}
	if(a.size()>b.size())cout<<a[a.size()-1];
	cout<<endl;
	return 0;
}


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

int main()
{
    int n, m, r, to_visit[8];
    long long shortest_way[8][8];
    scanf("%d%d%d", &n, &m, &r);
    for (int i = 0; i < r; i++)
    {
        scanf("%d", to_visit + i);
        to_visit[i]--;
    }
    {
        long long cost[200][200]{};
        std::fill(cost[0], cost[0] + 40000, 1000000000000);
        for (int i = 0; i < n; i++)
            cost[i][i] = 0;
        for (int i = 0; i < m; i++)
        {
            int a, b, c;
            scanf("%d%d%d", &a, &b, &c);
            cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int k = 0; k < n; k++)
                {
                    cost[j][k] = std::min(cost[j][k], cost[j][i] + cost[i][k]);
                }
            }
        }
        for (int i = 0; i < r; i++)
        {
            for (int j = 0; j < r; j++)
                shortest_way[i][j] = cost[to_visit[i]][to_visit[j]];
        }
    }

    int permutation[8]{};
    long long ans = 1000000000000;
    for (int i = 0; i < r; i++) permutation[i] = i;
    do
    {
        long long sum{};
        for (int i = 1; i < r; i++)
            sum += shortest_way[permutation[i - 1]][permutation[i]];
        ans = std::min(ans, sum);
    } while (std::next_permutation(permutation, permutation + r));

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

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct Doubling{
    vector<vector<int>> table;
    const int ub_log;
    const int n;

    Doubling(int _n) : n(_n), ub_log(32 - __builtin_clz(_n)) {
        table.assign(ub_log, vector<int>(n, n));
    }
    
    void set(int cur, int nxt){
        table[0][cur] = nxt;
    }

    void build(){
        for(int k = 0; k + 1 < ub_log; ++k){
            for(int i = 0; i < n; ++i){
                if(table[k][i] < n) table[k + 1][i] = table[k][table[k][i]];
            }
        }
    }

    int query(int a, int b){
        int res = 0;
        while(a < b){
            if(a == b)  return res;
            if(table[0][a] >= b)    return res + 1;
            for(int k = 1; k < ub_log; ++k){
                if(table[k][a] == b)    return res += 1 << k;
                if(table[k][a] > b){
                    a = table[k - 1][a];
                    res += 1 << (k - 1);
                    break;
                }
                if(k == ub_log - 1){
                    a = table[k][a];
                    res += 1 << k;
                }
            }
        }
        return res;
    }

    void print(){
        for(int k = 0; k < ub_log; ++k){
            for(int i = 0; i < n; ++i){
                cerr << table[k][i] << ' ';
            } cerr << '\n';
        }
    }
};

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

    int N, L, Q;
    cin >> N;
    vector<int> x(N);
    for(int i = 0; i < N; ++i)  cin >> x[i];
    cin >> L >> Q;
    Doubling table(N);
    for(int i = 0; i < N - 1; ++i){
        int p = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin();
        table.set(i, p - 1);
    }
    table.build();
    for(int i = 0; i < Q; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(a > b)   swap(a, b);
        cout << table.query(a, b) << '\n';
    }
}

Measured memory_bytes: 10596
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w,k;
	int ans=0;
	cin >>h>>w>>k;
	vector<string> c(h);
	rep(i,h){
		cin>>c[i];
	}
	int cnt=0;
	rep(bit,1<<(h+w)){
		cnt=0;
		for(int i=0;i<h;i++){
			if(!(bit & (1<<i))){continue;}
			for(int j=0;j<w;j++){
				if(bit & (1<<(h+j)) and c[i][j]=='#' ){
					cnt++;
				}
			}
		}
		if(cnt==k){
			ans++;
		//	clog<<bitset<12>(bit)<<endl;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <bitset>
#define ll long long
using namespace std;


int main() {
	int n;
	cin >> n;
	cout << (n - 2)* 180 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = Integer.parseInt(sc.next());
int[] a=new int[n+1];
int[] b=new int[n+1];
int c=0;    
for (int i = 1; i <= n; i++) {
    a[i]=Integer.parseInt(sc.next());
    if(a[i]!=2){c++;}
}
if(c==n){
    out.println(-1);
}else{
    int temp=1;
    for (int i = 1; i <= n; i++) {
        b[i]=a[temp];
        temp=b[i];
        if(b[i]==2){
            out.println(i);
            break;
        }else if(i==n){
            out.println(-1);
        }
    }
}
}
}

Measured memory_bytes: 49728
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
D = list(map(int, input().split()))
D.sort()

num = N // 2
ans = D[num] - D[num-1]
print(ans)

Measured memory_bytes: 14428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int r = sc.nextInt();

		if (n >= 10) {
			System.out.println(r);
		} else {
			int k = 100 * (10 - n);
			System.out.println(r + k);
		}
		sc.close();
	}

}


Measured memory_bytes: 35624
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

vector<vector<int>> edges;
bool seen[2048];

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

	int n, k; cin >> n >> k;
	edges = vector<vector<int>>(n, vector<int>());
	forn(i, n - 1) {
		int a, b; cin >> a >> b; a--, b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	
	int best = 0;
	queue<pair<int,int>> q;
	if (k % 2) {
		forn(i,n) for (int edge : edges[i]) {
			int tot = 2;
			q.push({0, i}); q.push({0, edge});
			memset(seen, 0, sizeof(seen)); seen[i] = true, seen[edge] = true;
			while (!q.empty()) {
				auto cur = q.front(); q.pop();
				
				for (int neigh : edges[cur.S]) if (!seen[neigh] && cur.F + 1 <= k / 2) {
					seen[neigh] = true;
					tot++;
					q.push({cur.F + 1, neigh});
				}
			} 
			best = max(best, tot);
		}
	} else {
		forn(i,n) {
			int tot = 1;
			q.push({0, i});
			memset(seen, 0, sizeof(seen)); seen[i] = true;
			while (!q.empty()) {
				auto cur = q.front(); q.pop();
				
				for (int neigh : edges[cur.S]) if (!seen[neigh] && cur.F + 1 <= k / 2) {
					seen[neigh] = true;
					tot++;
					q.push({cur.F + 1, neigh});
				}
			} 
			best = max(best, tot);
		}
	}
	cout << n - best << endl;
}


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

using namespace std;
using ll = long long;

int main() {
	ll n, m, x, ans = 1e18;
	cin >> n >> m >> x;
	ll c[12][13] = {};
	rep(i,n) rep(j,m + 1) cin >> c[i][j];
	for (int i = 0; i < (1 << 12); i++) {
		ll rez[13] = {};
		rep(b,12) {
			if (i >> b & 1) {
				rep(j,m+1) rez[j] += c[b][j];
			}
		}
		int count = 0;
		rep(j,m) if (rez[j + 1] >= x) count++;
		if (count == m) ans = min (ans, rez[0]);
	}
	if (ans == 1e18) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n;
    cin >> m;
    if (m % n == 0) cout << n + m << endl;
    else cout << m - n << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if
#define unint unsigned int
#define sint short int
#define lint long long int
#define Size 100000

sint foundString(string s, string g,sint x);

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    sint x;
    string s,gs="ABC";
    cin>>x>>s;
    cout<<foundString(s,gs,x)<<endl;
    return 0;
}

sint foundString(string s, string g,sint x)
{
    int res=0;
    for(int i=0;i<x-2;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(s[i] == g[j])
            {
                if(s[i+1]== g[j+1])
                {
                    if(s[i+2] == g[j+2])
                    {
                        res++;
                    }
                }
            }
        }
    }
    return res;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, H, W;
vector<pii> V;

int edge_id(int x, int y){
    if(x==0) return y;
    if(y==H) return H+x;
    if(x==W) return H+W+(H-y);
    if(y==0) return H+W+H+(W-x);
    return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>W>>H>>N;
    rep(i,N){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        
        int x=edge_id(x1,y1);
        int y=edge_id(x2,y2);
        if(x!=-1&&y!=-1){
            V.push_back({x,i});
            V.push_back({y,i});
        }
    }
    sort(all(V));
    vector<int> A;
    for(auto& v:V){
        if(A.size()&&A.back()==v.second) A.pop_back();
        else A.push_back(v.second);
    }
    cout1((A.size()?"NO":"YES"));
}

Measured memory_bytes: 2672
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++)

const ll mod = 1000000000+7;

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

ll comb(ll n, ll r) {
    ll count1 = 1;
    ll count2 = 1;
    for(ll i = n; i >= n-r+1; i--) {
        count1 = (count1*i)%mod;
    }
    for(ll i = r; i >= 1; i--) {
        count2 = (count2*i)%mod;
    }
    ll x = pow(count2, mod-2);
    return count1*x%mod;
}

int main() {
    ll n;
    ll a, b;
    std::cin >> n >> a >> b;
    ll ans = pow(2, n)-1;
    ans = (ans+mod-comb(n, a))%mod;
    ans = (ans+mod-comb(n, b))%mod;
    //cout << ans << endl;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
char end[]="END OF INPUT";
int main(void){
    int mozi,sum,temp,i,s,t,sign=0,line[100];
    for(;t=0,sign==0;){
        sign=1;
        memset(line,0,sizeof(line));
        for(s=0;(mozi=getchar())!='\n';){
            if(sign==1 && end[s++]!=mozi)
                sign=0;
            if(mozi!=' ')
                line[t++]=1;
            else
                line[t++]=0;
        }
        if(sign==0){
            for(sum=0,i=0;i<t;i++){
                if(line[i]==1)
                    sum++;
                if(line[i]==0||i==t-1){
                    printf("%d",sum);
                    sum=0;
                }
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string S;
	cin >> S;
	int l = S.size(), count = 0, left = 0, hajime = 0;
	vector<int>c(l, 0);
	for (int i = 0; i < l; i++)
	{
		if (S[i] == 'R') {
			if (i!=l-1&&S[i + 1] == 'R') {
				c[i] = 0;
				count++;
			}
			else if(i != l - 1 && S[i + 1] == 'L'){
				left = i;
				count++;
			}
		}
		else {
			if (i != l - 1 && S[i + 1] == 'R') {
				count++;
				if (count%2&&!((left - hajime) % 2)) {
					c[left] = (count + 1) / 2;
					c[left + 1] = count / 2;
				}
				else if(count%2)
				{
					c[left+1] = (count + 1) / 2;
					c[left] = count / 2;
				}
				else {
					c[left + 1] = count / 2;
					c[left] = count / 2;
				}

				hajime = i + 1;
				count = 0;
			}
			else if(i!=l-1&&S[i+1]=='L')
			{
				c[i + 1] = 0;
				count++;
			}
		}
		if (i==l-1&&count != 0)
		{
			count++;
			if (count % 2 && !((left - hajime) % 2)) {
				c[left] = (count + 1) / 2;
				c[left + 1] = count / 2;
			}
			else if (count % 2)
			{
				c[left + 1] = (count + 1) / 2;
				c[left] = count / 2;
			}
			else {
				c[left + 1] = count / 2;
				c[left] = count / 2;
			}

		}
	}
	for (int i = 0; i < l; i++)
	{
		cout << c[i]<<" ";
	}
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;
	cin >> s;
	sort(every(s));
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) puts("Yes");
	else puts("No");

	return Accepted;
}

// B...a

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


vector<int>ve;
void solve(){
	int n;
cin>>n;
	if(n==0) exit(0);
	ve.clear();
	
	for(int i=1;i*i<=n;i++){
		if(n%i) continue;
		if(i*i==n)ve.pb(i);
	else ve.pb(i),ve.pb(n/i);
	}
	
	int lo=0,si;
	
	for(auto v:ve){
		if(v%2==0) continue;
		
		int no=n/v;
		if(2*no-v+1>=2){
			if(lo<v){
				lo=v;
				si=no-(v-1)/2;
			}	
		}
		if(v-2*no>=1){
			if(lo<2*no){
				lo=2*no;
				si=(v-2*no+1)/2;
			}
		}
	}
	cout<<si<<" "<<lo<<endl;

}

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

    int t;
    	//cin>>t;
    	for(int i=0;;i++){
    		solve();
    	
    	}
    	return 0;
    	
            }


Measured memory_bytes: 3128