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

int c(const void * d, const void * e)
{
   return ( *(int*)d - *(int*)e );
}
int main()
{
    int i, j, N, max=0, count;
    scanf("%d", &N);
    int a[3*N];
    for(i=0;i<(N*3);i+=3){
        scanf("%d", a+i);
        a[i+1]=a[i]-1;
        a[i+2]=a[i]+1;
    }
    if(N==1)max=1;
    else{

        int current=a[0]+1;
        qsort(a, N*3, sizeof(int), c);
        for(j=0;j<(N*3);j++){
            if(current!=a[j]){
                current=a[j];
                count=1;
            }
            else{
                count+=1;
                if(count>max)max=count;
            }
        }
    }
    if(max==0)max=1;
    printf("%d", max);
    return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000000000000
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int flag=0;
  for(int i=0;i<N;i++){
    flag|=A[i]%2;
  }

  if(flag){
    cout<<"first"<<endl;
  }else{
    cout<<"second"<<endl;
  }
}


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

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

	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int count;
	count = 0;
	rep(i, a + 1)
	{
		rep(j, b + 1)
		{
			rep(k, c + 1)
			{
				if (500 * i + 100 * j + 50 * k == x)
					count++;
			}
		}
	}
	cout << count << endl;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  int x=-1, y=-1, z=-1;
  bool loop = true;
  for (int i=0; i<N+1; i++) {
    for (int j=0; j<N+1-i; j++) {
      for (int k=0; k<N+1-i-j; k++) {
        if (10000*i+5000*j+1000*k==Y && i+j+k==N) {
          x = i;
          y = j;
          z = k;
          loop = false;
          break;
        }
      }
      if (!loop) break;
    }
    if (!loop) break;
  }
  cout << x << " " << y << " " << z << endl;
}

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

int main(){
	int N;
	cin >> N;
	ll A[N],s(0),sum(0);
	for(int i(0);i<N;++i){
		cin >> A[i];
		A[i] *= 2;
		sum += A[i];
		if(i%2==1) s+=A[i];
	}
	int ans1 = sum/2 - s;
	cout << ans1;
	int prev(ans1);
	for(int i(0);i<N-1;++i){
		cout << ' ' << A[i] - prev;
		prev = A[i] - prev;
	}
	return 0;
}

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

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


Measured memory_bytes: 256
MOD = 998244353

def main():
    n, k = map(int, input().split())
    rng = [list(map(int, input().split())) for _ in range(k)]
    dp = [0]*(n+5)
    dp[1] = 1
    for i in range(1, n):
        dp[i] += dp[i-1]
        dp[i] %= MOD
        for l, r in rng:
            if i+l <= n:
                dp[i+l] += dp[i]
                dp[i+l] %= MOD
            if i+r+1 <= n:
                dp[i+r+1] -= dp[i]
                dp[i+r+1] %= MOD
    print(dp[n] % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 75116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,k,arr[N];



inline int mul(int a,int b){return (a*1ll*b)%MOD;}
inline int add(int a,int b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,MOD-2);}
int fac[N];
int invfac[N];
void pre()
{
    fac[0] = 1;
	invfac[0] = inv(1);
	forn(i,1,N-10)
	{
		fac[i] = fac[i-1]*i;
		fac[i]%=MOD;
		invfac[i] = inv(fac[i]);

	}
}
int ncr(int n,int r)
{
    if(r>n)return 0;
    return mul(fac[n],mul(invfac[r],invfac[n-r]));
}




void solve()
{
    
    cin>>n>>k;
    forn(i,1,n)cin>>arr[i];
    sort(alln(arr));

    int mx = 0 , mn = 0;

    forn(i,k,n)
    {
    	mx = add(mx,mul(arr[i],ncr(i-1,k-1)));
    }
   	reverse(alln(arr));

   	forn(i,k,n)
   	{
   		mn = add(mn,mul(arr[i],ncr(i-1,k-1)));
   	}

   	cout<<(mx-mn+MOD)%MOD;



}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    pre();
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

int main(){
  long long x,i,j;
  cin >> x;
  vector<long long> a(121);
  for(i=0;i<121;i++){
    a.at(i)=i*i*i*i*i;
  }
  
  for(i=0;i<121;i++){
    for(j=0;j<121;j++){
      if(a.at(i)-a.at(j)==x){
        cout << i << " " << j << endl;
        return 0;
      }
      if(a.at(i)+a.at(j)==x){
        cout << i << " -" << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3640
def dfs(i):
  global count
  global seen
  global G

  end = True
  for n in range(N):
    if seen[n] == 0 and n != i:
      end = False

  if (end):
    count += 1
    return

  seen[i] = 1
  for g in G:
    if g[0] == i:
      if seen[g[1]] == 1:
        continue
      dfs(g[1])
  
    if g[1] == i:
      if seen[g[0]] == 1:
        continue
      dfs(g[0])

  seen[i] = 0

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

G = []

for i in li:
  G.append([i[0]-1, i[1]-1])

count = 0
seen = [0] * N
dfs(0)

print(count)

Measured memory_bytes: 3064
unittest
{
	assert( [ "2", "3 1 4 1 5 9" ].parse.expand.solve == 1 );
	assert( [ "1", "1 2 3" ].parse.expand.solve == -1 );
	assert( [ "3", "8 2 2 7 4 6 5 3 8" ].parse.expand.solve == 5 );
}



import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( n, as );
}

auto solve( long n, long[] as )
{
	// 「前1/3のグループ」と「後ろ2/3のグループ」と「後ろのグループから取り除かれたグループ」に分ける
	auto rbt_a = redBlackTree!( true )( as[ 0 .. n ] );
	auto rbt_b = redBlackTree!( true )( as[ n .. $ ] );
	auto rbt_c = redBlackTree!( true, long )();
	while( n < rbt_b.length )
	{
		rbt_c.insert( rbt_b.back );
		rbt_b.removeBack;
	}
	
	// 後ろのグループから一つずつ前のグループに移動したときのスコアを計算
	auto at = rbt_a[].sum;
	auto bt = rbt_b[].sum;
	auto ans = at - bt;
	foreach( a; as[ n .. n * 2 ] )
	{
		if( a in rbt_c )
		{
			rbt_c.removeKey( a );
		}
		else
		{
			rbt_b.insert( rbt_c.front );
			rbt_b.removeKey( a );
			bt += rbt_c.front - a;
			rbt_c.removeFront;
		}
		rbt_a.insert( a );
		at += a - rbt_a.front;
		rbt_a.removeFront;
		
		ans = max( ans, at - bt );
	}
	return ans;
}


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

using namespace std;

#define ll long long
#define INF 123456789101112
#define MAX 65560
ll val[MAX];
ll arr[16][16];
ll ans[MAX];

int main()
{
    ll n;
    scanf("%lld", &n);
    for(ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            scanf("%lld", &arr[i][j]);
        }
    }
    for(ll mask = 0; mask < (1<<n); mask++){
        for(ll i=0; i<n; i++){
            for(ll j=i+1; j<n; j++){
                if(mask & (1<<i)){
                    if(mask & (1<<j)){
                        val[mask] += arr[i][j];
                    }
                }
            }
        }
    }
    memset(ans, 0, sizeof ans);
    for(ll mask = 1; mask < (1<<n); mask++){
        for(ll i = mask; i>0; i=(i-1)&mask){
            ans[mask] = max(ans[mask], val[i]+ans[mask^i]);
        }
    }
    ll x = (1<<n) - 1;
    cout << ans[x];
}


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

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

  int ans = 1;
  rep(i,1,N) ans = min(ans * 2, ans + K);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>

typedef unsigned long long ull;
const ull B = 100000007;

using namespace std;

bool contain(string,string);

int main(void){
  string str;
  while(getline(cin,str)){
   
    while(1){
	int fg=0;
      for(int j=0;j<26;j++){
	for(int i=0;i<str.length();i++)
	  if(isalpha(str[i]))str[i] = (str[i]=='z')? 'a' : str[i] + 1;

	if(contain("that",str)||contain("the",str)||contain("this",str)){
	  cout << str << endl;
	  fg=1;
	  break;
	}
      }
      if(fg)break;
    }
  }
  return 0;
}

bool contain(string a,string b){
  int al=a.length(),bl=b.length();
  if(al>bl)return false;

  ull t=1;
  for(int i=0;i<al;i++)t*=B;

  ull ah=0,bh=0;
  for(int i=0;i<al;i++)ah=ah*B+a[i];
  for(int i=0;i<al;i++)bh=bh*B+b[i];

  for(int i=0;i+al<=bl;i++){
    if(ah==bh)return true;
    if(i+al<bl) bh=bh*B+b[i+al]-b[i]*t;
  }
  return false;
}

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

# define ll long long 
# define VI vector<int>
# define VL vector<ll>
# define PII pair<int,int> 
# define VII vector<PII>
# define mp make_pair
# define pb push_back
# define vt vector
# define PI acos(-1)
# define ld long double
# define endl "\n"
# define all(c) (c).begin(), (c).end()
# define ft first 
# define sd second 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i) 
# define F0R(i,b) for(int i = 0 ; i < b ; ++i) 


/* VARIABLES */
int n, q ;
/* END OF VARIABLES */


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

	int n ; 
	cin >> n ; 
	vt<int> a(n) ; 
	F0R(i,n) cin >> a[i] ; 
	ll ans=0;
	int j=0 ; 
	ll s1=0, s2=0 ;
	F0R(i,n) {
		if(i>0) s1 -= a[i-1] , s2 ^= a[i-1] ;
		while(j<n && s1+a[j] == (s2 ^a[j])) {
			s1 += a[j] ;
			s2 ^= a[j] ; 
			j++ ;
		}
		ans += j-i;
	}

	cout << ans ;

		
	return 0 ; 
	
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll L;

int div(ll a) {
	int cnt = 0;
	while(a % 2 == 0) {
		cnt++;
		a /= 2;
	}
	return cnt;
}
struct trie {
	int G[MAX_N][2];
	int A[100];
	int M;

	trie() { init(); }
	void init() {
		memset(G, -1, sizeof(G));
		M = 1;
	}

	void add(const string& str) {
		int n = sz(str);
		int v = 0;
		rep(i, 0, n) {
			int y = str[i] - '0';
			if(G[v][y] == -1) {
				G[v][y] = M++;
			}
			v = G[v][y];
		}
	}
	void show() {
		rep(i, 0, 10) {
			debug(i, G[i][0], G[i][1]);
		}
	}

	void dfs(int v, int d) {
		// debug(v, d);
		int cnt = 0;
		if(G[v][0] != -1) {
			dfs(G[v][0], d + 1); 
			cnt++;
		}
		if(G[v][1] != -1) {
			dfs(G[v][1], d + 1);
			cnt++;
		}
		if(cnt == 1) {
			if(L - d >= 1) A[div(L - d)]++;
		}
	}
	bool win() {
		dfs(0, 0);
		rep(i, 0, 70) {
			if(A[i] % 2) return true;
		}
		return false;
	}
};

int N;
trie T;
string str[MAX_N];

void solve() {
	cin >> N >> L;
	rep(i, 0, N) {
		cin >> str[i];
		T.add(str[i]);
	}
	if(T.win()) {
		cout << "Alice\n";
	}
	else cout << "Bob\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

int main(void)
{
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s) a--;
    if (u == t) b--;

    cout << a << " " << b << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string s;
	int k;
	cin>>s>>k;
	set <string> S;
	For(l,1,min((int)s.size(),k))
	{
		rep(i,0,s.size())
		{
			S.insert(s.substr(i,l));
			if(S.size()>k)S.erase(--S.end());
		}
	}
	cout<<*(--S.end())<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};


int main() {
  int h, w;
  cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  ch--; cw--; dh--; dw--;

  vector<vector<int>> dist(h, vector<int>(w, INF));

  deque<P> q;
  q.emplace_back(ch, cw);
  dist[ch][cw] = 0;

  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop_front();

    rep(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (s[nx][ny] == '#') continue;
      if (dist[nx][ny] <= dist[x][y]) continue;
      dist[nx][ny] = dist[x][y];
      q.emplace_front(nx, ny);
    }

    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i;
        int ny = y + j;
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#') continue;
        if (dist[nx][ny] <= dist[x][y] + 1) continue;
        dist[nx][ny] = dist[x][y] + 1;
        q.emplace_back(nx, ny);
      }
    }
  }

  int ans = dist[dh][dw];
  if (ans == INF) ans = -1;
  cout << ans << endl;

}

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

int main(){
    string s;   cin >> s;
    int cnt = 0;
    if(s[0] == '1') cnt++;
    if(s[1] == '1') cnt++;
    if(s[2] == '1') cnt++;

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  FOR(i, 1, 9) {
    FOR(j, 1, 9) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    ll n,m;
    cin >> n >> m;
    for(ll i=1;i<=m;i++){
        ll x;
        cin >> x;
        n = n - x;
    }
    if(n<=-1)n=-1;
    cout << n << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 1 + 1e5;
const ll oo = 1  +1e18;
typedef pair < int, int > II;
typedef pair < int, II > III;



int main(){
    vector < int > a ;

    a.push_back(0);

    a.push_back(100);

    a.push_back(101);

    a.push_back(102);

    a.push_back(103);
    
    a.push_back(104);

    a.push_back(105);

    int n;

    cin >> n;

    vector < int > dp (n + 1);
    
    dp[0] = 1;

    for (int i = 100; i <= n; i++){

        for (int j = 1; j <= 6; j++){

            if (a[j] <= i)

                dp[i] = (dp[i] == 1 || dp[i - a[j]] == 1);
        }
    }
    
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int M = 1e6;
const int MX = 200005;

int main() {
  int n, m = 26;
  cin>>n;
  vi c(m);
  cin>>c;
  vvi s(n,vi(m));
  cin>>s;
  vi t(n);
  cin>>t;
  rep(i,n) --t[i];
  int ans = 0;
  vi p(m);
  rep(i,n) {
    ans += s[i][t[i]];
    rep(j,m) p[j]++;
    p[t[i]] = 0;
    rep(j,m) ans -= p[j]*c[j];
    cout<<ans<<endl;
  }
  return 0;
}






















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

int main() {
  int N;
  cin >> N;
  
  int HI,FU,MI,YO;
  YO = N/1000;
  MI = (N-YO*1000)/100;
  FU = (N-YO*1000-MI*100)/10;
  HI = N%10;
  
  if (FU == MI && (HI == FU || MI == YO)){
  cout << "Yes" << endl;
  }    
  else {
  cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<char>> a(H, vector<char>(W));
	rep(i, 0, H) rep(j, 0, W) { cin >> a[i][j]; }

	int cnt[128] = {};
	rep(i, 0, H)rep(j, 0, W) {
		cnt[a[i][j]]++;
	}
	int odd = 0;
	rep(i, 0, 26) {
		if (cnt['a' + i] % 2 == 1)
			odd++;
	}
	if (odd > 1) {
		cout << "No" << endl;
		return 0;
	}
	if (odd == 1) {
		if (H % 2 != 1 || W % 2 != 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	int c4 = (H / 2)*(W / 2);
	int c2 = (H % 2)*(W / 2) + (W % 2)*(H / 2);
	dump(c4, c2);
	dump(cnt);
	rep(i, 0, 26) {
		int sub = min(c4, cnt['a' + i] / 4);
		c4 -= sub;
		cnt['a' + i] -= sub * 4;
	}

	dump(cnt);
	rep(i, 0, 26) {
		int sub = min(c2, cnt['a' + i] / 2);
		c2 -= sub;
		cnt['a' + i] -= sub * 2;
	}

	dump(cnt);
	bool ok = true;
	rep(i, 0, 26) {
		if (cnt['a' + i] > 1) {
			ok = false;
		}
	}
	dump(c4, c2);
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
    int n;
    string str;
    cin >> n >> str;
    if(n&1)
    {
        cout << "No\n";
    }
    else
    {
        if(str.substr(0,str.size()/2)==str.substr(str.size()/2,str.size()/2))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


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

int main() {
    int N, M, X; cin >> N >> M >> X;
    int A[M];
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    int lower_cost = 0;
    int upper_cost = 0;
    for (int i = 0; i < M; i++) {
        if (A[i] > X) {
            upper_cost++;
        } else if (A[i] < X) {
            lower_cost++;
        }
    }
    cout << min(upper_cost, lower_cost) << endl;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		long res = 0;
		if(M-2*N >0){
			res = (M-2*N)/4+N;
		}
		else{
			res = M/2;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    set<tuple<int,int,int> >f;
    //r,l,id
    map<int,vector<tuple<int,int,int> > > pos;
    REP(i,n){
      string c;
      cin >> c;
      if(c=="W"){
	int id,se;
	cin >> id >> se;
	int tmp=0;
	for(;;){
	  auto ite=(f.lower_bound(make_tuple(tmp+1,0,0)));
	  if(ite==f.end()){
	    auto ma=make_tuple(tmp+se,tmp,id);
	    f.insert(ma);
	    pos[id].push_back(ma);
	    break;
	  }
	  int sup,suc;
	  tie(suc,sup,ignore)=*ite;
	  if(tmp<sup){
	    if(tmp+se<=sup){
	      auto ma=make_tuple(tmp+se,tmp,id);
	      f.insert(ma);
	      pos[id].push_back(ma);
	      break;
	    }else{
	      auto ma=make_tuple(sup,tmp,id);
	      f.insert(ma);
	      pos[id].push_back(ma);
	      se-=sup-tmp;
	    }
	  }
	  tmp=suc;
	}
      }else if(c=="D"){
	int id;
	cin >> id;
	for(auto x:pos[id]) f.erase(x);
	pos[id].clear();
      }else if(c=="R"){
	int p;
	cin >> p;
	auto x=f.lower_bound(make_tuple(p+1,0,0));
	if(x==f.end()){
	  cout << -1 << endl;
	}else{
	  int l,id;
	  tie(ignore,l,id)=*x;
	  if(l<=p) cout << id << endl;
	  else cout << -1 << endl;
	}
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 28184
#include <iostream>
#include <string>
#include <deque>

int main(int argc, char *argv[]){
    int N, Q;
    std::string S;
    std::cin >> N >> Q >> S;

    int old_i=0, new_i;
    int j=0;
    std::deque<int> pos;
    while((new_i = S.find("AC",old_i))!=std::string::npos){
        for(int k=old_i; k<=new_i; ++k){
            pos.push_back(j);
        }
        old_i = new_i+1;
        ++j;
    }
    for(int k=old_i; k<N; ++k){
        pos.push_back(j);
    }

    pos.push_front(0);
    int l,r;
    for(int i=0; i<Q; ++i){
        std::cin >> l >> r;
        std::cout << pos[r] - pos[l] << std::endl;
    }
    

    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,X,Y = inputIL()



res = [0 for i in range(N)]

for i in range(1,N):
  for j in range(i+1,N+1):
    temp = min(j-i,abs(i-X)+1+abs(j-Y))
    res[temp]+=1
    
for item in res[1:]:
  print(item)
      

Measured memory_bytes: 71640
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)

	var arrX [2]int
	arrX[0] = a
	arrX[1] = b

	var arrY [2]int
	arrY[0] = c
	arrY[1] = d

	//var x, y int
	var tmp int
	tmp = arrX[0] * arrY[0]
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			if (arrX[i] * arrY[j]) > tmp {
				tmp = arrX[i] * arrY[j]
			}
		}
	}
	fmt.Println(tmp)
}


Measured memory_bytes: 1832
import random
import copy
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0

types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = max(ans+10**6,0)
all = sum(sc)
for _ in range(17000):
    types2 = [0]*D
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,D+1))
    #print(l)
    #print(ind,types[ind]-1)
    l.pop(ind-1)
    ind2=random.choice(l)
    spans=ind//26
    for i in range(D):
        types2[i]=types[i]
    buf=types[ind]
    types[ind]=types[ind2-1]
    types[ind2-1]=buf
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = max(ans+10**6,0)
    all2 = sum(sc2)
    if all2<=all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
        #print(114514)
    #print(all)
    #input()
for i in range(D):
    print(types[i])







Measured memory_bytes: 85324
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	rnd
	int n, col;
	cin >> n >> col;
	vector <string> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector <int> a(n);
	for (int i = 0; i < n; i++) {	
		a[i] = i;
	}
	auto check = [&] (vector <string> tt) {
		vector <string> t(col);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < col; j++) {
				t[j] += tt[i][j];
			}
		}
		map <string, int> m;
		for (int i = 0; i < col; i++) {
			m[t[i]]++;
		}
		int c = 0;
		for (int i = 0; i < col; i++) {
			if(m[t[i]] == 0)	continue;
			string tmp = t[i];
			m[t[i]]--;
			reverse(all(tmp));
			if(t[i] == tmp) {
				if(m[tmp] == 0) {
					c++;
				}
				else {
					m[tmp] -= 1;
				}
			}
			else {
				if(m[tmp] == 0)
					return false;
				else
					m[tmp] -= 1;
			}
		}
		if(c == 0)
			return true;
		else if(c == 1 && col % 2 == 1)	
			return true;
		else
			return false;
	};
	int rt = 50000;
	while(rt--) {
		vector <string> tt(n);
		vector <pair<int, int>> t;
		for (int i = 0; i < n / 2; i++)	
			t.emplace_back(i, 2);
		if(n % 2)	
			t.emplace_back(n/ 2, 1);
		for (int i = 0; i < n; i++) {
			int sz = (int) t.size();
			int id = uid(0, sz - 1)(rng);  
			if(t[id].ss == 2)
				tt[t[id].ff] = v[i];
			else
				tt[n - t[id].ff - 1] = v[i];
			t[id].ss--;
			if(t[id].ss == 0) {
				t.erase(t.begin() + id);
			}
		}
		if(check(tt)) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO";
}


Measured memory_bytes: 256
/*
P135
POJ 2718 Smallest Difference
*/


#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
using namespace std;

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

void solve()
{
    int x1=0, x2=0;
    bool ans = true;
    for(int i=0; i<10; ++i)
    {
        if(x1 < x2) swap(x1, x2);
        if(x1 < a[i]) x1 = a[i];
        else if(x2 < a[i]) x2 = a[i];
        else {ans = false; break;}
    }
    if(ans) printf("YES\n");
    else printf("NO\n");
}



vector<int> L_bucket;
vector<int> R_bucket;

bool dfs2(int d){
    if(d == 10) return true;
    bool flag;
    if(L_bucket.size() == 0 || L_bucket.back() < a[d]){
        L_bucket.push_back(a[d]);
        flag = dfs2(d+1);
        L_bucket.pop_back();
    }
    if(flag) return true;
    if(R_bucket.size() == 0 || R_bucket.back() < a[d]){
        R_bucket.push_back((a[d]));
        flag = dfs2(d+1);
        R_bucket.pop_back();
    }
    if(flag) return true;
    return false;
}

void solve2()
{
    if(dfs2(0)) printf("YES\n");
    else printf("NO\n");
}

int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        read();
        solve();
    }
}

Measured memory_bytes: 1168
from collections import deque

def a():
    H,W = map(int,input().split())
    S = ["" for _ in range(H)]
    for _ in range(H):
        S[_] = input()
    b = lambda n:S[n//W][n%W] == '.'
    v = list(filter(b,range(H*W)))
    u = list(map(lambda n:(n%W,n//W),v))

    le = len(v)

    def bfs(root):
        i = 0
        depth = [[-1]*W for _ in range(H)]
        in_que = [[0]*W for _ in range(H)]
        q = deque()
        q.append((root,0))
        xx,yy = root
        in_que[yy][xx] = 1
        while i < le:
            r,d = q.popleft()
            x,y = r
            depth[y][x] = d
            i += 1
            for dx,dy in ((1,0),(-1,0),(0,1),(0,-1)):
                dx += x
                dy += y
                if 0 <= dx < W and 0 <= dy < H and in_que[dy][dx] == 0 and S[dy][dx] == ".":
                    q.append(((dx,dy),d+1))
                    in_que[dy][dx] = 1
        return depth
    
    print(max([max([max(y) for y in x]) for x in map(bfs,u)]))

a()





Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

ll n,m,x,c[15],a[15][15],s[15],ans=1e9,sum;

int main()
{

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

    cin >> n >> m >> x;
    for(ll i=0; i<n; i++){
        cin >> c[i];
        for(ll j=0; j<m; j++) cin >> a[i][j] , s[j]+=a[i][j];
    }

    for(ll i=0; i<m; i++){
        if( s[i] < x ){
            cout << -1;
            return 0;
        }
    }

    for(ll mask=1; mask<=(1LL<<n); mask++){
        sum = 0;
        for(ll i=0; i<m; i++) s[i] = 0;

        for(ll bit=0; bit<n; bit++){
            if( mask&(1LL<<bit) ){
                sum+=c[bit];
                for(ll i=0; i<m; i++) s[i]+=a[bit][i];
            }
        }

        for(ll i=0; i<m; i++){
            if( s[i] < x ){
                sum = 1e9;
            }
        }

        ans = min( ans , sum );
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;

int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    ll a, b, n; cin>>a>>b>>n;
    ll r = (b<=n? b-1: n);
    cout<<(a*r/b) - a*(r/b);
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int ans = a;
	if(a > b)
		ans--;
	cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


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

    int A, B;
    cin >> A >> B;
    if(A <= 8 and B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 3584
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
X = [[] for _ in range(N)]
P = [-1] * N
for i in range(N-1):
    a, b = map(int, input().split())
    X[a-1].append((i, b-1))
    #print(X)
    #P[b-1] = a-1
#print(X)

Q = deque([(0, -1)])
ANS = [-1] * (N-1)
cmax = 0
while Q:
    x, c0 = Q.pop()
    c = 1
    for i, y in X[x]:
        if c == c0: c += 1
        ANS[i] = c
        Q.append((y, c))
        c += 1
    cmax = max(cmax, c-1)

print(cmax)
for ans in ANS:
    print(ans)

Measured memory_bytes: 28068
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int ar[101];
int main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = 0;
  for(int i=a; i<b; i++) ar[i]++;
  for(int i=c; i<d; i++) ar[i]++;
  REP(i,101) if (ar[i] == 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S;
	int h;
	int m;
	int s;
	
	scanf("%d",&S);
	h = S/3600;
	m = S%3600/60;
	s = S%60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>

int main()
{
   int l,r;
   std::cin >> l >> r;
   if (r-l > 2019) {
      l%=2019;
      r=l+2019;
   } else {
      l%=2019;
      r%=2019;
   }
   int min(2018);
   for (int i=l; i<r; i++) {
      for (int j=i+1; j<=r; j++) {
         int prod = i*j;
         int mod = prod%2019;
         if (mod < min) min = mod;
      }
   }
   std::cout << min << std::endl;
   
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main() {
    string str;

    int element,n,m,ans;
    cin >> n >> m;

    int A[n][m], b[m], c[n];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
        }
    }

    for(int i=0;i<m;i++){
        cin >> b[i];
    }

    for(int i=0;i<n;i++){
        c[i] = 0;
        for(int j=0;j<m;j++){
            c[i] += A[i][j] * b[j];
        }
        cout << c[i] << endl;
    }


}


Measured memory_bytes: 3108
#!/usr/bin/env python3


def main():
    a, b, c = map(int, input().split())
    k = int(input())

    for i in range(k):
        if a < b < c:
            break
        elif a >= b:
            b *= 2
        elif b >= c:
            c *= 2

    if a < b < c:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String line = br.readLine();

	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < line.length(); i++) {
	    	char c = line.charAt(i);
	    	String s = String.valueOf(c);

	    	String lowerStr = s.toLowerCase();
	    	if (lowerStr.equals(s)) {
	    		sb.append(s.toUpperCase());
	    	} else {
	    		sb.append(s.toLowerCase());
	    	}
	    }
	    System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        sc.close();
        int dx = x2 - x1;
        int dy = y2 - y1;
        int x3 = x2 - dy;
        int y3 = y2 + dx;
        int x4 = x3 - dx;
        int y4 = y3 - dy;
        System.out.println(x3 + " " + y3 + " " + x4 + " " + y4 + " ");

    }

}

Measured memory_bytes: 21588
#include<iostream>

using namespace std;

int main(){
    string s;
    cin >> s;

    bool check[26];
    for(int i=0;i<26;i++)check[i] = false;

    for(int i=0;i<s.length();i++){
        for(int j=0;j<26;j++){
            if(s[i]==char(int('a')+j)){
                if(check[j]){
                    cout << "no" << endl;
                    return 0;
                }
                check[j] = true;
            }
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
using namespace std;

typedef pair<int,int> PII;
typedef pair<int,PII> PIII;

vector<string> m(1000);

int main(){

    int H,W,N;
    
    cin >> H >> W >> N;

    for(int i=0;i<H;++i)
        cin >> m[i];

    int sx[10],sy[10];

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j)
            if(m[i][j]=='S'){
                sx[0] = i;
                sy[0] = j;
            } else if(isdigit(m[i][j])){
                int x = m[i][j]-'0';
                sx[x] = i;
                sy[x] = j;
            }
    }

    int ans = 0;

    for(int n=0;n<N;++n){
    
        priority_queue<PIII,vector<PIII>,greater<PIII> > q;
        q.push(make_pair(0,make_pair(sx[n],sy[n])));

        m[sx[n]][sy[n]]     = n   + '0';
        m[sx[n+1]][sy[n+1]] = n+1 + '0';

        while(!q.empty()){

            pair<int,PII> p = q.top(); q.pop();

            if(p.second.first == sx[n+1] && p.second.second == sy[n+1]){
                ans += p.first;
                break;
            }

            const int d[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

            for(int i=0;i<4;++i){

                int x = p.second.first+d[i][0];
                int y = p.second.second+d[i][1];

                if(0<=x && x<H && 0<=y && y<W && m[x][y]!='X' && m[x][y]!=n+'0'){

                    m[x][y] = n+'0';
                    q.push(make_pair(p.first+1,make_pair(x,y)));

                }

            }

        }

    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 2064
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

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

    int ans = 0;

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

    cout << ans << endl;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a7=1000000007;
ll inf=100000000000000000;

int main()
{
  ll n;cin>>n;
  ll l[n];
  for(ll i=0;i<n;i++)cin>>l[i];
  sort(l,l+n);
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      ll k=j+1;
      while(l[k]<l[i]+l[j]){
        ans++;k++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
player 1 will win when grundy1 != grundy2
2^m - number of G' such as grundy1 = grundy2
f[S] = number of subset edge in S vertex such as grundy1 = grundy2
split S to T and U. every vertex in T has grundy !=0 and otherwise in U
Every vertex in T need connect to U
Non restrict that every vertex in U connect to T
=> because of how to calculate grundy number
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 16;
const int M = (1<<maxn);
const int base = 1e9+7;

int n,m,out[maxn][M],f[M],pw[M];

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int x,y;
        cin>>x>>y;
        x--; y--;
        out[x][1<<y] = 1;
    }
    pw[0]=1;
    for (int i=1;i<=m;i++) pw[i] = (pw[i-1]*2ll)%base;
    vector<int> all;
    for (int i=0;i<n;i++)
        for (int tt=0;tt<(1<<n);tt++)
            out[i][tt] = out[i][tt - (tt&(-tt))] + out[i][tt&(-tt)]; //(tt&(-tt) = last 1-bit in tt
    for (int tt=0;tt<(1<<n);tt++) {
        if ((tt&1) != ((tt&2)/2)) continue;
        f[tt]=1;
        all.clear();
        for (int s=tt;s;s=(s-1)&tt) all.push_back(s);
        for (auto sT : all) {
            if ((sT&1) != ((sT&2)/2)) continue;
            int sU = sT ^ tt;
            int tmp = f[sT];
            for (int i=0;i<n;i++) {
                if (sT & (1<<i)) tmp = 1ll*tmp * (pw[out[i][sU]] - 1) % base; //every vertex in T must be connect to U
                if (sU & (1<<i)) tmp = 1ll*tmp * pw[out[i][sT]] % base; // no necessary vertex in U must be connect to T
            }
            f[tt] = (f[tt] + tmp) % base;
        }
    }
    //cout<<f[(1<<n)-1]<<endl;
    cout<<(pw[m] - f[(1<<n)-1] + base)%base<<endl;
}


Measured memory_bytes: 3584