akhauriyash/Code-Regression huggingface dataset:
/*input
23
11 10 3
10 8 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[3];
ll b[3];

vector<int> idx;

int main(){
	IOS;
	ll n;
	cin>>n;
	REP(i,3) cin>>a[i];
	REP(i,3) cin>>b[i];

	REP(i,3) if(a[i]<=b[i]) idx.pb(i);

	if(SZ(idx)==0){
		REP(i,3) swap(a[i],b[i]);
		REP(i,3) idx.pb(i);
	}

	ll ans=n;
	if(SZ(idx)==1){
		{
			ll cnt=n/a[idx[0]];
			n=n%a[idx[0]]+cnt*b[idx[0]];
		}
		{
			int x,y;
			if(idx[0]==0) x=1;
			else x=0;
			y=3-x-idx[0];

			for(int i=0;i*b[x]<=n;i++){
				ll rem=n-i*b[x];
				rem=rem%b[y]+rem/b[y]*a[y];
				ans=max(ans,rem+i*a[x]);
			}
		}
	}
	else if(SZ(idx)==2){
		{
			ll bst=n;
			int x=idx[0],y=idx[1];

			for(int i=0;i*a[x]<=n;i++){
				ll rem=n-i*a[x];
				rem=rem%a[y]+rem/a[y]*b[y];
				bst=max(bst,rem+i*b[x]);
			}
			n=bst;
		}
		{
			int i=3-idx[0]-idx[1];
			ll cnt=n/b[i];
			ans=n-cnt*b[i]+cnt*a[i];
		}
	}
	else{
		for(int i=0;i*a[0]<=n;i++) for(int j=0;i*a[0]+j*a[1]<=n;j++){
			ll rem=n-i*a[0]-j*a[1];
			rem=rem%a[2]+rem/a[2]*b[2];
			ans=max(ans,rem+i*b[0]+j*b[1]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	int x[m];
	for(int i = 0; i < m; i++)cin >> x[i];
	sort(x, x + m);
	int dist[m-1];
	for(int i = 0; i < m - 1; i++)dist[i] = x[i + 1] - x[i];
	sort(dist, dist + m - 1);
	int res = 0;
	for(int i = 0; i < m - n; i++)res += dist[i];
	cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int i,j,n[5][14],maisuu,num;
  char mark,dummy;
  scanf("%d",&maisuu);
 
  for(i=0; i < 5; i++){
    for(j=0; j < 14; j++){
      n[i][j]=0;
    }
  }
 
  for(i=0; i < maisuu; i++){
    scanf("%c",&dummy);
    scanf("%c %d",&mark,&num);
 
    if(mark == 'S'){
      n[0][num] = 1;
    }
    if(mark == 'H'){
      n[1][num] = 1;
    }
    if(mark == 'C'){
      n[2][num] = 1;
    }
    if(mark == 'D'){
      n[3][num] = 1;
    }
  }
  for(i = 0; i < 4; i++){
    for(j=1; j < 14; j++){
       
      if(n[i][j]==0 && i == 0) printf("S %d\n",j);
      if(n[i][j]==0 && i == 1) printf("H %d\n",j);
      if(n[i][j]==0 && i==2) printf("C %d\n",j);
      if(n[i][j]==0 && i==3) printf("D %d\n",j);
    }
  }
   
  return 0;
}

Measured memory_bytes: 596
import sys
input = sys.stdin.readline

class Trie:
    class Node:
        def __init__(self):
            self.nxt = [-1] * 26
            self.is_end = False

    def __init__(self, N):
        self.nodes = [self.Node()]
        self.paths = [[] for _ in range(N)]

    def add(self, s, i):
        node = 0
        for c in s:
            c = ord(c) - ord('a')
            self.paths[i].append(node)
            if self.nodes[node].nxt[c] == -1:
                self.nodes[node].nxt[c] = len(self.nodes)
                self.nodes.append(self.Node())
            node = self.nodes[node].nxt[c]
        self.nodes[node].is_end = True

    def query(self, s, i):
        ret = 0
        suffix = set()
        for j in range(len(s) - 1, -1, -1):
            suffix.add(ord(s[j]) - ord('a'))
            node = self.paths[i][j]
            for c in suffix:
                if self.nodes[node].nxt[c] != -1:
                    ret += self.nodes[self.nodes[node].nxt[c]].is_end
        return ret

N = int(input())
S = [input().rstrip()[::-1] for _ in range(N)]
trie = Trie(N)
ans = 0
for i, s in enumerate(S):
    trie.add(s, i)
for i, s in enumerate(S):
    ans += trie.query(s, i)
print(ans - N)

Measured memory_bytes: 484432
#include<stdio.h>
int main()
{
    char a,b,c;
    scanf("%c %c",&a,&b);
        if(a=='H')
        {
            if(b=='H')
                c='H';
            else
                c='D';
        }
        if(a=='D')
        {
            if(b=='H')
                c='D';
            else
                c='H';
        }
         printf("%c\n",c);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


const long nmax=200005;


long long fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(long i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}


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

 ll n,a,b;
  cin >> n >> a >> b;
 ll res=myPow(2ll,n,mod)-1;
 comint(); 
  
  ll x=1,y=1;
  rep(i,0,a) x*=(n-i),x%=mod;
  x*=finv[a],x%=mod;
  rep(i,0,b) y*=(n-i),y%=mod;
  y*=finv[b],y%=mod;
   
  cout << (res-x-y+2*mod)%mod << endl;
  
}


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

int main() {
  int N, W; cin >> N >> W;
  int w[N], V[N]; for (int i = 0; i < N; i++) cin >> w[i] >> V[i];
  long dp[W+1]; for (int i = 0; i <= W; i++) dp[i] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = W; j >= w[i]; j--) {
      dp[j] = max(dp[j], dp[j-w[i]] + V[i]);
    }
  }
  cout << dp[W] << endl;
}

Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

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

bool is_so(ll X){
    for(ll i = 2; i <= sqrt(X); i++){
        if(X % i == 0){
            return false;
        }
    }

    return true;
}

int main(){
    ll X;
    cin >> X;

    while(!is_so(X)){
        X++;
    }

    cout << X << endl;

    return 0;
}

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

public class Main {

    long MOD = (long)1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        String s = sc.next();

        int[] cnts = new int[26];
        for (int i = 0; i < len; i++) {
            cnts[s.charAt(i) - 'a']++;
        }
        long ans = 1L;
        for (int i = 0; i < 26; i++) {
            ans = ((cnts[i] + 1) * ans) % MOD;
        }
        System.out.println((ans + MOD - 1) % MOD);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23724
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pii pair<int,int>
#define pll pair<int,int>
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
#define adj(N) vector<vector<int>> ADJ(N+1)


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

	string S;
	READ(S);
	string mod="";
	FORI(i,0,S.length())
	{
		if(S[i]=='B' && S[i+1]=='C')
		{
			mod=mod+"D";
			i++;
		}
		else
		{
			mod=mod+S[i];
		}
	}
	ll dc=0;
	ll ac=0;
	ll ans=0;
	FORD(i,mod.length()-1,-1)
	{
		if(mod[i]=='D')
		{
			dc++;
		}
		else if(mod[i]=='A')
		{
			ans+=dc;
		}
		else
		{
			dc=0;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1452
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int N,A;

	cin >> N >> A;

	cout << (A>=(N % 500) ? "Yes" : "No" ) << endl;

	return 0;

}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   vector<ll>d(n);
   map<ll,int>mp;
    for (int i = 0; i < n; ++i) {
        cin >>d[i];
        mp[d[i]]++;
    }
   ll m;cin >>m;
   bool flg=true;
    for (int j = 0; j < m; ++j) {
        ll t;cin >>t;
        if(mp[t]==0)flg=false;
        else {
            mp[t]--;
        }
    }
   if(flg)puts("YES");
   else puts("NO");
   return 0;
}

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

using namespace std;


int main() {
    char tmp;

    cin >> tmp;

    if (tmp == 'A') {
        cout << 'T';
    } else if (tmp == 'C') {
        cout << 'G';
    } else if (tmp == 'G') {
        cout << 'C';
    } else {
        cout << 'A';
    }
    return 0;
}

Measured memory_bytes: 256
c, n = map(int, input().split(' '))

l=list(map(int, input().split(' ')))

diffs=[]
for i in range(1,n):
  diffs.append(l[i]-l[i-1])
diffs.append(c-l[-1]+l[0])

print(sum(diffs)-max(diffs))
  
  

Measured memory_bytes: 99680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

const int inf=1<<29;
int n,dp[100],dp2[200];
vector<vector<pair<int,int> > > e;

void rec(int c,int p){
	fr(i,e[c])if(i->first!=p&&e[i->first].size()>1){
		rec(i->first,c);
		dp[c]+=2*i->second+dp[i->first];
	}
	dp2[c]=dp[c];
	fr(i,e[c])if(i->first!=p&&e[i->first].size()>1){
		dp2[c]=min(dp2[c],dp[c]-i->second-dp[i->first]+dp2[i->first]);
	}
}
int main(){
	while(cin>>n,n){
		e.clear(); e.resize(n);
		rep(i,n-1){
			int a,b,t; cin>>a>>b>>t;
			a--; b--;
			e[a].pb(mp(b,t)); e[b].pb(mp(a,t));
		}
		rep(i,n)dp[i]=0,dp2[i]=inf;
		rec(0,-1);
		cout<<dp2[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#include<mutex>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
int arr[20][20];
int brr[20][20];
int crr[20];
int fff(int n){
	int sum=0;
	while(n){
		sum+=n%2;
		n/=2;
	}
	return sum;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>crr[i];
		for(int j=0;j<crr[i];j++){
			cin>>arr[i][j]>>brr[i][j];
		}
	}
	int ans=0;
	for(int i=pow(2,n)-1;i>=0;i--){
		int c=1;
		for(int j=0;j<n;j++){
			if(!(i&(1<<j))){
				continue;
			}
			for(int z=0;z<crr[j];z++){
				if(((i>>(arr[j][z]-1))&1)^brr[j][z]){
					c=0;
					break;
				}
					
			}
			
		}
		if(c){
			ans=max(ans,fff(i));
		}
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include <iterator>
#include <map>
#include<cmath>
using namespace std;

int main (){
int i;
 char c,a[]={'a','i','o','e','u'};
 cin>>c;
 for( i=0;i<5;i++)
        if(c==a[i]){
            cout<<"vowel"<<endl;
            break;
        }
if(i==5)cout<<"consonant"<<endl;


return 0;
}

















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

int main() {
  int n;
  vector<int> a;
  cin>>n;
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    if(x%2==0) a.push_back(x);
  }
  int f = 0;
  for(int i=0;i<a.size();i++){
    if(a[i]%3==0 || a[i]%5==0) f++;
  }
  if(f==a.size()) cout<<"APPROVED";
  else cout<<"DENIED";
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      a: i64,
      xs: [i64; n],
    }
    let nx = 50*50usize;
    let ys: Vec<i64> = xs.into_iter().map(|x| x-a).collect();
    let mut dp = vec![vec![0u64; 2*nx+1]; n+1];
    for i in 0..n {
        let y = ys[i];
        dp[i+1][ (y+nx as i64) as usize ] += 1;

        for v in 0..dp[i].len() {
            dp[i+1][v] += dp[i][v];
            let nv = v as i64 + y;
            if nv >= 0 && nv <= 2*nx as i64 {
                let nv = nv as usize;
                dp[i+1][nv] += dp[i][v];
            }
        }
    }
    println!("{}", dp[n][nx]);
}


Measured memory_bytes: 6396
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;

	ll lcm;
	cin >> lcm;
	ll saisho = lcm;

	bool dame = 0;
	rep1(i, N - 1) {
		ll a;
		cin >> a;
		ll g = __gcd(lcm, a);
		ll bai = a / g;
		if (lcm > 2e9 || !(bai & lcm / g & 1)) {
			dame = 1;
			break;
		}
		lcm = lcm * bai;
	}

	if (dame) co(0);
	else {
		ll kotae = (lcm / 2 + M) / lcm;
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

bool is_pal(string s){
    string s1 = s;
    reverse(all(s));
    return s==s1;
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s; cin>>s;
    int n = sz(s);
    int v1 = (n-1)/2;
    int v2 = (n+3)/2;
    string s1 = s.substr(0, v1);
    string s2 = s.substr(v2-1);
    if(is_pal(s) && is_pal(s1) && is_pal(s2)){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	vector<long long>X(N);
	long long ans = 0;
	for (long long i = 0; i < N; i++) cin >> X.at(i);
	for (long long i = 1; i < N; i++) {
		ans += min(A * (X.at(i) - X.at(i - 1)), B);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
const int maxn = 1e3 + 4, mod = 1e9 + 7;
typedef pair<int,int> ii;
typedef pair<long long, long long> ll;
int n, a[maxn], t; 
bool dp[maxn], ok;
vector<int> ans;

void _accepted_by_one_hit_()
{
    #ifdef NTMA
        freopen("abc.inp", "r", stdin);
        freopen("abc.out", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
void quaylui(int x, int pos = 0)
{
      if (x == 0){
            ok = true;
            for(auto c: ans) cout << c << " ";
            return;
      }
      for(int i=pos+1; i<=n; ++i) if (x >= a[i]) {
            ans.push_back(a[i]);
            quaylui(x-a[i], i);
            ans.pop_back();
            if (ok) return;
      }
}

int main()
{
      _accepted_by_one_hit_();

      int n, m;
      cin >> n >> m;
      cout << n*(n-1)/2 + m*(m-1)/2;
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    string s;cin>>s;
    std::vector<int> v;
    for(int i=0;i<n;i++){
        v.push_back(s[i]);
    }
    vector<int>:: iterator it;
    it  = unique(v.begin(),v.end());
    v.resize(distance(v.begin(),it));
    cout<<v.size();
    return 0;
}


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

int main(){
    string str;
    int N,K;
    cin >> N >> K;
    cin >> str;
    if(str[K-1]=='A'){
        str[K-1]='a';
    }
    else if(str[K-1]=='B'){
        str[K-1]='b';
    }
    else if(str[K-1]=='C'){
        str[K-1]='c';
    }
    cout << str;
    cin >> K;
}

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

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

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

  int a[n];
  for(int i = 0;i < n;i ++){
    scanf("%d",&a[i]);
  }

  qsort(a,n,sizeof(int),up);

  int s , t , u;
  int ans = 0;
  for(int i = 0;i < n-2;i ++){
    s = a[i];
    for(int j = i+1;j < n-1;j ++){
      t = a[j];
      for(int k = j+1;k < n;k ++){
        u = a[k];
        if(s + t > u && s != t && t != u && u != s){
          ans ++;
        }
      }
    }
  }

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

  return 0;

}

Measured memory_bytes: 1708
//Δ_D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
LL n,s;
int main()
{
	LL x,y;
	cin>>n;
	for(x=1;x*x<=n;x=x+1){
		if(n%x)
			continue;
		y=n/x;
		if(x<y-1)
			s+=y-1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final long INF =  1_000_000_000_000_000_000L;
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextInt();
        }

        long[] pow = new long[Math.max(N+1,32)];
        for (int i = 0; i < N+1; i++) {
            pow[i] = INF;
        }
        pow[0] = 1;
        for (int i = 1; i <= 30; i++) {
            pow[i] = 2*pow[i-1];
        }
        // pow[30] 1_000_000_000;

        long[] PMax = new long[N+1];
        for (int i = 0; i < N+1; i++) {
            PMax[i] = INF;
        }

        PMax[0] = 1;
        for (int i = 1; i <= N; i++) {
            PMax[i] = Math.min(2*PMax[i-1]-A[i],INF);
            if (PMax[i] == INF) {
                break;
            }
            if (i < N && PMax[i] <= 0) {
                System.out.println(-1);
                return;
            }
            if (i == N && PMax[i] < 0) {
                System.out.println(-1);
                return;
            }
        }

        if (A[N] > pow[N]) {
            System.out.println(-1);
            return;
        }
        long ans = A[N];
        long pre = A[N];
        for (int i = N-1; i >= 0; i--) {
            long PMax2 = Math.min(PMax[i],pre);
            long now = PMax2+A[i];
            if (now > pow[i]) {
                System.out.println(-1);
                return;
            }
            ans += now;
            pre = now;
        }

        System.out.println(ans);
    }
}


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

int w, h;
bool data[99][99]; //y,x

int solve(int x, int y){

  if(x < 0 || y < 0 || x == w || y == h) return 0;
  if(!data[y][x]) return 0;

  data[y][x] = false;

  for(int i=-1;i<2;i++) for(int j=-1;j<2;j++) solve(x+j, y+i);

  return 1;
}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];

    int ret = 0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(data[i][j]) ret += solve(j, i);

    cout << ret << endl;
  }

}

Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int n, a[100];

int main(){
	cin >> n;
	int odd = 0, even = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (a[i] % 2 == 0) even++;
		else odd++;
	}
	int ans = pow(3, n);
	ans -= pow(2, even);
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf 2e9
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define LL long long
using namespace std;
int n,k;
bool ok;
int main(){
	cin>>n>>k;
	(n%k==0) ? cout<<"0\n" : cout<<"1\n";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  int s = 0;
  int cnt = 0;
  int i = 0;
  
  while(i < n) {
    cnt++;
    if (a[s] == 2) {
      cout << cnt << endl;
      return 0;
    }
    else s = a[s] - 1;
    i++;
  }
  cout << -1 << endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ok = s[a] == '-';
    for (size_t i = 0; i < s.size(); i++)
    {
        if (i != a) {
            ok &= '0' <= s[i] && '9' >= s[i];
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int solve(int h[],int mi[],int i,int n)
{   
    if(mi[i]!=-1)
    return mi[i];
    else if(i==n-1)
    {mi[i-1]==0;
     return 0;}
    else if(i==n-2)
    { mi[n-2]=abs(h[n-1]-h[n-2]);
     return abs(h[n-1]-h[n-2]);}
    else
    {
        mi[i]=min(solve(h,mi,i+1,n)+abs(h[i+1]-h[i]),
                    solve(h,mi,i+2,n)+abs(h[i+2]-h[i]));
        return mi[i];
    }
}
int main()
{int n,i;
 cin>>n;
 int h[n],mi[n];
 for(i=0;i<n;i++)
 cin>>h[i];
 for(i=0;i<n;i++)
 mi[i]=-1;
 solve(h,mi,0,n);
 cout<<mi[0];
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, L, A[101010];

int main()
{
	scanf("%d%d", &N, &L);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);
	
	for (int i = 0; i < N - 1; ++i) {
		if (A[i] + A[i + 1] >= L) {
			puts("Possible");
			for (int j = 0; j < i; ++j) printf("%d\n", j + 1);
			for (int j = N - 2; j >= i; --j) printf("%d\n", j + 1);
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}


Measured memory_bytes: 1152
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;

int n;
int a[105];
const int Mod=1'000'000'007;

int ksmii(int a,int b){
	if(!b){
		return 1;
	}
	int ff=ksmii(a,b>>1);
	ff=1LL*ff*ff%Mod;
	if(b&1){
		ff=1LL*ff*a%Mod;
	}
	return ff;
}

pair<int,int> solve(int l,int r,int lim){
	int minx=Mod,cnt;
	for(int i=l;i<=r;i++){
		if(a[i]<minx){
			minx=a[i];
			cnt=1;
		}else if(a[i]==minx){
			cnt++;
		}
	}
	if(cnt==r-l+1){
		return make_pair((ksmii(2,r-l+1)-2+Mod)%Mod,ksmii(2,minx-lim-1));
	}
	pair<int,int> ans;
	int L=-1,rem=r-l+1;
	int x1=1,x2=1;
	for(int i=l;i<=r+1;i++){
		if(L==-1&&a[i]>minx){
			L=i;
		}else if(L!=-1&&a[i]<=minx){
			rem-=i-L;
			pair<int,int> tmp=solve(L,i-1,minx);
			x1=1LL*x1*(tmp.first+4LL*tmp.second%Mod)%Mod;
			x2=2LL*x2*tmp.second%Mod;
			L=-1;
		}
	}
	x1=(x1-x2+Mod)%Mod;
	ans.first=((1LL*x1*ksmii(2,rem)%Mod)+(1LL*x2*((ksmii(2,rem)-2+Mod)%Mod)%Mod))%Mod;
	ans.second=1LL*x2*ksmii(2,minx-lim-1)%Mod;
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	if(n==1){
		printf("%d\n",ksmii(2,a[1]));
		return 0;
	}
	int peak=1;
	for(int i=1;i<=n;i++){
		if(a[i]>a[i-1]&&a[i]>a[i+1]){
			peak=1LL*peak*ksmii(2,a[i]-max(a[i-1],a[i+1]))%Mod;
			a[i]=max(a[i-1],a[i+1]);
		}
	}
	pair<int,int> ans=solve(1,n,0);
	printf("%lld\n",1LL*peak*((ans.first+2LL*ans.second%Mod)%Mod)%Mod);
	return 0;
}

Measured memory_bytes: 256
// C++ (GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/m-solutions2019/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e6 + 3;
const int LIMIT = 1010101;
LL FAC[LIMIT], INV[LIMIT];

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果(mod版).
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0LL;
    if(n == k || k == 0LL) return 1LL;
    LL ret = FAC[n] * INV[k] % MOD * INV[n - k] % MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int Q;
    scanf("%d", &Q);
    FAC[0] = 1;
    repx(i, 1, LIMIT) FAC[i] = (LL)i * FAC[i - 1] % MOD;
    rep(i, LIMIT)     INV[i] = mPow(FAC[i], MOD - 2);
    
    // 2. クエリ回答(解説通り).
    rep(i, Q){
        LL x, d, n;
        scanf("%lld %lld %lld", &x, &d, &n);
        
        // 2-1. d が 0 の 場合.
        if(d == 0){
            LL ans = mPow(x, n);
            printf("%lld\n", ans);
        }
        
        // 2-2. d が 0 でない 場合.
        if(d != 0){
            LL xd = x * mPow(d, MOD - 2) % MOD; // (x / d) を 計算.
            LL q1 = xd / MOD;
            LL q2 = (xd + n - 1) / MOD;
            // 1000003 の倍数 が 見つかったか否かで 分岐.
            if(q2 > q1){
                puts("0");
            }else{
                // xd が 0 か 否かで 分岐.
                if(xd == 0){
                    puts("0");
                }else{
                    LL r1 = (xd + MOD - 1) % MOD;
                    LL r2 = (xd + MOD + n - 1) % MOD;
                    LL ans = FAC[r2] * INV[r1] % MOD * mPow(d, n) % MOD;
                    printf("%lld\n", ans);
                }
            }
        }
    }
    return 0;
    
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll X; cin >> X;
  for (int i = 1; ; i++) {
    if (2 * X <= i * (i + 1)) {
      std::cout << i << "\n";
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
f = 1
for a in A:
    if a % 2 == 0:
        if not (a % 3 == 0) and not (a % 5 == 0):
            f = 0
            print('DENIED')
            break
if f:
    print('APPROVED')

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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++)  cin >> p[i];
    int cnt = 0;
    for(int i = 0; i < n; i++)  cnt += (p[i]-1 != i);
    if(cnt <= 2)    cout << "YES" << endl;
    else            cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

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



Measured memory_bytes: 256
N, P = map(int, input().split())

if N == 1:
    print(P)
else:
    prime = [0] * (10**6+1)
    index = 2
    tmp = 0
    while P > 1 and index < 10**6+1:
        if P % index == 0:
            tmp += 1
            P //= index
            if P == 1:
                prime[index] = tmp
        else:
            prime[index] = tmp
            tmp = 0
            if index == 2:
                index += 1
            else:
                index += 2
    
    
    if prime[2] >= N:
        ans = 2 ** (prime[2]//N)
    else:
        ans = 1
    for i in range(3, 10**6+1, 2):
        ans *= max(1, i ** (prime[i]//N))
    
    print(ans)

Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
	int n;
	for(int i=0;i<5;i++)
		cin>>a[i];
	cin>>n;
	int flag = 0;
	for(int i=0;i<5;i++)
		for(int j=i+1;j<5;j++){
			if(abs(a[i]-a[j])>n)
				flag = 1;
		}
	if(!flag)
		cout<<"Yay!\n";
	else 
		cout<<":(\n";
} 

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, h: [i64; n]};
    let mut dp = vec![0; n];
    dp[1] = (h[0] - h[1]).abs();

    for i in 2..n {
        dp[i] = std::cmp::min(
            dp[i - 2] + (h[i] - h[i - 2]).abs(),
            dp[i - 1] + (h[i] - h[i - 1]).abs(),
        )
    }

    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3996
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5
1 2 3 4 5
)");
#define cin input
#endif

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

	ll a;
	int count = 0;
	REP(i,n)
	{
		cin >> a;
		if (a%2==1)
			count++;
	}

	cout << (count%2==1 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    if(N != A.size()) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
using ll=long long;
int main() {
	string S;
	cin >> S;
	map<char,int>a;
	ll y=0;
	while(S[y]){
		y++;

	}
	for (int i = 0; i <y; i++) {
		a[S[i]]++;
	}
	if (a['a'] - a['c']<2 && a['a'] - a['c'] > -2 && a['a'] - a['b']<2 && a['a'] - a['b'] > -2 && a['c'] - a['b'] < 2 && a['c'] - a['b'] > -2)
	{
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 512
def main():
    N = int(input())
    D = []
    for _ in range(N):
        a, b = (int(i) for i in input().split())
        D.append(int(a == b))

    if any(sum(D[i:i+3]) == 3 for i in range(N-3+1)):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62408
#include<stdio.h>
int	a,b,t[17][17],cnt,x,y;
void func(int x,int y)
{
	if(x==a&&y==b) cnt++;
	else{
		if(x+1<=a&&t[y][x+1]==0) func(x+1,y);
		if(y+1<=b&&t[y+1][x]==0) func(x,y+1);
	}
}
int main(void){
	int n,i,j;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++) t[i][j]=0;
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			t[y][x]=-1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
	return 0;
}

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

//自分の直前の同じ数を覚えたい
//配列でもいいのかもしれない
//

int main(){
    int N;cin >> N;
    int C[200200];
    int M =pow(10,9)+7;

    int INF =pow(10,7);
    int scan[200200]; //iにはiが書かれた直前のものが書かれている
    int before[200200];

    for(int i=0; i<N; i++){
        scan[i]=INF;
        before[i]=INF;
    }
    
    for(int i=0; i<N; i++){
        cin >> C[i];
    }

    for(int i=N-1; i>=0; i--){
        if(scan[C[i]]!=INF){
            before[scan[C[i]]]=i;
        }
        scan[C[i]]=i;
    }
    int dp[200200]; //dp[i]は前i個しか操作しないときの場合の数

    dp[0]=1;
    for(int i=0; i<N-1; i++){
        //dp[i+2]を決めたい
        //before[i+2]が何もないな
        if(before[i+1]==INF){
            dp[i+1]=dp[i];
        }
        else{
            if(before[i+1]==i)
            dp[i+1]=dp[i];
            else
            dp[i+1]=(dp[i]+dp[before[i+1]])%M;            
        }
    }
    cout << dp[N-1] <<endl;

/*    for(int i=0; i<N; i++){
        cout << before[i] << endl;
    }
 */   
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    for(i=sqrt(n)+1;i>=1;i--)
    {
        if(n%i==0)break;
    }
    cout<<i+(n/i)-2<<endl;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

map<string, int> alp_anagram_cnt(vector<string> &v) {
    map<string, int> ans;
    for (auto &&i : v) {
        sort(i.begin(), i.end());
        if (ans.count(i) == 0) {
            ans[i] = 1;
        } else {
            ans[i]++;
        }
    }
    return ans;
}

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

    int N;
    cin >> N;
    vector<string> s(N);
    for (auto &&i : s) {
        cin >> i;
    }
    auto m = alp_anagram_cnt(s);
    ll ans = 0;
    for (auto &&i : m) {
        ll a = i.second;
        if (a == 1)
            continue;
        ans += a * (a - 1) / 2;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
  
    cin >>a>>b>>c;
  
    char ans1=a[0]-32;
    char ans2=b[0]-32;
    char ans3=c[0]-32;
  
    cout <<ans1<<ans2<<ans3;
}

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

    int dp[201][100002];
signed main() {
    int n,x;
    cin>>n>>x;
    int s[n];
    for(int i=0;i<n;i++)cin >>s[i];
    fill(dp[0],dp[n+1],int(0));
 
   // cerr<<dp[0][0];
    sort(s,s+n);
  
   long long a;
    dp[n][x]=1;
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=x;j++){

            a=dp[i][j%s[i]]+dp[i+1][j];a=a%MAX;
            
            dp[i][j%s[i]]=a;
            a=dp[i][j]+long(i)*dp[i+1][j];a=a%MAX;
            
            
             dp[i][j]=a;
        }
    }
    long long ans=0,p;

    for(long long j=0;j<=x;j++){
        p= dp[0][j];
       
        ans=(ans+j*p)%MAX;
   
    }

    cout<<ans;

    return 0;


}


Measured memory_bytes: 78720
def gcd(a, b)
  a, b = b, a if a < b
  loop do
    r = a%b
    break if r == 0
    a, b = b, r
  end
  return b
end

def lcm(a, b)
  a * b / gcd(a, b)
end

while gets do
  a, b = $_.split(' ').map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end

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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		System.out.println(reader.readLine().toUpperCase());
	}
}

Measured memory_bytes: 16856
import heapq
import numpy as np
from math import ceil

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = a * (-1)
a = list(a)
heapq.heapify(a)

for i in range(m):
    num = heapq.heappop(a)
    num = ceil(num / 2)
    heapq.heappush(a, num)

print(-1*sum(a))


Measured memory_bytes: 23132
fun main(args: Array<String>) {
    val (a, b, x) = readLine()!!.split(' ').map { it.toDouble() }

    var l = 0.0
    var r = 90.0

    while (l + 1e-9 < r) {
        val m = (r + l) / 2

        val b0 = Math.tan(m * Math.PI / 180) * a

        if (b0 <= b) {
            val x0 = ((a * b0 / 2) + (a * (b - b0))) * a
            if (x0 < x) {
                r = m
            } else {
                l = m
            }
            continue
        }

        val a0 = Math.tan((90 - m) * Math.PI / 180) * b
        val x0 = a0 * b / 2 * a
        if (x0 < x) {
            r = m
        } else {
            l = m
        }
    }

    println(l)
}


Measured memory_bytes: 38132
#include <bits/stdc++.h>
using namespace std;
long long wt[110], val[110], dp[100020][110];
long long fun(long long n, long long i)
{
    if (n <= 0)
        return 0;
    if (i < 0)
        return 0;
    if (dp[n][i] != -1)
        return dp[n][i];
    if (wt[i] > n)
        return dp[n][i] = fun(n, i - 1);
    return dp[n][i] = max(val[i] + fun(n - wt[i], i - 1), fun(n, i - 1));
}
int main()
{
    long long n, tot, x;
    cin >> n >> tot;
    for (x = 0; x < n; x++)
        cin >> wt[x] >> val[x];
    memset(dp, -1, sizeof(dp));
    long long ans = fun(tot, n - 1);
    cout << ans << endl;
}

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

using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	string s1="",s2="";
	for(int i=0;i<(b-'0');i++){
		s1+=a;
	}
	for(int i=0;i<(a-'0');i++){
		s2+=b;
	}
	cout<<min(s1,s2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
typedef pair<int,int> P;
int dw[2][9]={{1,1,1,1,1,2,2,2,3},{-1,-1,-1,-1,-1,-2,-2,-2,-3}};
int dh[2][9]={{-2,-1,0,1,2,-1,0,1,0},{-2,-1,0,1,2,-1,0,1,0}};
char mp[61][31];
int dis[2][60][30];
int w,h,ans;
void dijkstra(int si,int sj, int sk){
	rep(i,2) rep(j,h) rep(k,w) dis[i][j][k]=1e+8;
	dis[si][sj][sk]=0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,si*h*w+sj*w+sk));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int vs=p.second;
		int vi=vs/(h*w),vj=(vs/w)%h,vk=vs%w;
		if(dis[vi][vj][vk]<p.first) continue;
		rep(i,9){
			int nj=vj+dh[vi][i],nk=vk+dw[vi][i],ni=1-vi;
			if(0<=nj && nj<h && 0<=nk && nk<w && mp[nj][nk]!='X' && mp[nj][nk]!='S'){
				int &dn=dis[ni][nj][nk],&dv=dis[vi][vj][vk],cost=0;
				if(mp[nj][nk]!='T') cost=mp[nj][nk]-'0';
				if(dn>dv+cost){
					dn=dv+cost;
					que.push(P(dn,ni*h*w+nj*w+nk));
				}
			}
		}
	}
	rep(j,w) if(mp[0][j]=='T') rep(i,2) ans=min(ans,dis[i][0][j]);
}
int main(){
	while(true){
		scanf("%d%d",&w,&h);
		if(w==0) break;
		ans=1e+8;
		rep(i,h) rep(j,w) scanf(" %c",&mp[i][j]);
		rep(j,w) if(mp[h-1][j]=='S') rep(i,2) dijkstra(i,h-1,j);
		if(ans==1e8) ans=-1;
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t = 0;
    while (true) {
        if (t % 2 == 0) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        t++;
    }
}

Measured memory_bytes: 3104
// Binary Search
// 所要時間 8分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()

int main() {

    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n){
        cin >> s[i];
    }
    sort(all(s));
    int q;
    cin >> q;
    vector<int> t(q);
    int ans = 0;
    rep(i, q){
        cin >> t[i];
        if(t[i] == *lower_bound(all(s), t[i])){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3376