akhauriyash/Code-Regression huggingface dataset:
MOD = 10**9 + 7
n, oddness = [int(item) for item in input().split()]
# Oddness must be even
if oddness % 2 ==  1:
    print(0)
    exit()
oddness //= 2
max_oddness = 1250 + n
max_pending = n//2 + 2

dp = [[[0] * (max_oddness) for _ in range(max_pending)] for _ in range(n)]
dp[0][0][0] = 1
dp[0][1][1] = 1
for i in range(1, n):
    for j in range(min(i+1, n//2+1)):
        for k in range(oddness+1):
            dp_ijk_prev = dp[i-1][j][k]
            # Oddness increase by num of pending item
            # Do not connect
            dp[i][j+1][k+j+1] += dp_ijk_prev 
            # Choose 2 from pending items
            if j > 0:
                dp[i][j-1][k+j-1] += dp_ijk_prev * j*j
            # Connect in line 
            dp[i][j][k+j] += dp_ijk_prev
            # Choose 1 from pending items
            dp[i][j][k+j] += dp_ijk_prev * j * 2
            dp[i][j][k+j] %= MOD

print(dp[n-1][0][oddness] % MOD)

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

int main() {
    int N;
    cin >> N;
    if (N == 0) {
        cout << 2 << endl;
        return 0;
    }
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<long long> luca = {2, 1};
    for (int i = 2; i <= N; i++) {
        long long l = luca[i - 1 - 1] + luca[i - 1];
        luca.push_back(l);
    }
    printf("%lld\n", *(luca.end() - 1));
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = (1..N).filter(|&i| S[i - 1] != S[i]).count() + 1;

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll, ll>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll sz=1e6+100;
bool mark[sz];
vector<ll> prime;
ll siz;
void seive()
{
    ll i,j,k;
    ll sq=sqrt(sz);
    for(i=3;i<sz;i+=2)
    {
       mark[i]=true;
    }
    prime.pb(2);
    for(i=3;i<=sq;i+=2)
    {
        if(mark[i])
        {
            for(j=i*i;j<sz;j+=2*i) mark[j]=false;
        }
    }
    mark[1]=true;
    mark[2]=true;
    for(i=3;i<sz;i+=2) if(mark[i]) prime.pb(i);
    siz=prime.size();
}

ll fact(ll x)
{
      ll ct=0;
      ll i,j,k;
      if(x>0) ++ct;
      ll sq=sqrt(x);
      for(i=0;i<siz && prime[i]<=sq;i++)
      {
          if(x<sz && mark[x]) break;
          if(x%prime[i]==0)
          {
              ++ct;
              while(x%prime[i]==0) x/=prime[i];
              sq=sqrt(x);
          }
          
      }

      if(x>1) ++ct;
      return ct;
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    seive();
    while(cin>>p>>q)
    {
        n=__gcd(p,q);
        ll ans=fact(n);
        cout<<ans<<endl;
    }

}

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

int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll t = x % d;
    ll idou = x / d;
    //cout << "t " << t << " idou " << idou << endl;
    ll nokori = k - idou;
    if(nokori < 0){
        cout << x - k*d << endl;
    } else if(nokori % 2 == 0){
        cout << t << endl;
    } else {
        cout << d-t << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
typedef long long ll;
const int MAXN = 200000;
int A[MAXN + 5], n; ll k;
int vis[MAXN + 5], stk[MAXN + 5], tp;
void get_ans(int x) {
	for(int i=x;i<=n;i++) {
		if( vis[A[i]] ) {
			while( tp && stk[tp] != A[i] )
				vis[stk[tp--]] = false;
			tp--;
		}
		else stk[++tp] = A[i];
		vis[A[i]] ^= 1;
	}
	for(int i=1;i<=tp;i++)
		printf("%d ", stk[i]);
}
int nxt[60][MAXN + 5];
ll dis[60][MAXN + 5];
int adj[MAXN + 5];
int nt(int x) {return x == n ? 1 : x + 1;}
int main() {
	scanf("%d%lld", &n, &k);
	for(int i=1;i<=n;i++) scanf("%d", &A[i]);
	for(int i=n;i>=1;i--) adj[A[i]] = n + i;
	for(int i=n;i>=1;i--) {
		dis[0][i] = adj[A[i]] / n;
		nxt[0][i] = adj[A[i]] % n + 1;
		adj[A[i]] = i;
	}
	for(int i=1;i<60;i++)
		for(int j=1;j<=n;j++) {
			nxt[i][j] = nxt[i-1][nxt[i-1][j]];
			dis[i][j] = dis[i-1][j] + dis[i-1][nxt[i-1][j]];
		}
	int s = 1;
	for(int i=59;i>=0;i--)
		if( dis[i][s] < k )
			k -= dis[i][s], s = nxt[i][s];
	get_ans(s);
}

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

    using namespace std;
     
    int main(){
    	int n, a;
    	scanf("%d", &n);
    	int order[n] = {};
    	int prev;
    	scanf("%d",&prev);
    	for (int i = 1; i < n; ++i){
    		scanf("%d",&a);
    		if(a==prev+1) order[prev-1]++;
    		prev = a;
    	}
    	int cnt=0;
    	for (int i = 0; i < n; ++i){
    		scanf("%d",&a);
    		cnt+=a;
    	}
    	for (int i = 0; i < n-1; ++i){
    		scanf("%d",&a);
    		if(order[i]!=0){
    			cnt += a;
    		} 
    	}
    	printf("%d", cnt);
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

bool cmp(pair<ll,ll> a, pair<ll,ll> b){
    if(a.first != b.first){
        return a.first > b.first;
    }

    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return true;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m; cin >> n >> m;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i++){
        cin >> vec[i];
    }
    sort(all(vec));

    vector<pair<ll,ll>> card(m);
    rep(i, m){
        ll b, c; cin >> b >> c;
        card[i] = make_pair(c, b);
    }
    sort(all(card));
    
    ll now = m-1;
    for(ll i = 0; i < n; i++){
        if(card[now].second <= 0){
            now -= 1;
        }
        if(vec[i] < card[now].first){
            vec[i] = card[now].first;
            card[now].second--;
        }
    }

    ll ans = 0;
    rep(i, n){
        ans += vec[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int n;
	cin >> n;
	cout << n*n*n << endl;
}


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

int N;
int arr[111111];
int cnt;
int idx = 1;
bool visit[111111];

int main() 
{
	cin >> N;
	for(int i = 1; i <= N; i++)
		scanf("%d", &arr[i]);
		
	visit[1] = true;
	while(1)
	{
		if(idx == 2)
			break;
			
		cnt++;
		idx = arr[idx];
		
		if(visit[idx])
		{
			cnt = -1;
			break;
		}
	
		visit[idx] = true;
	}
	
	cout << cnt;
}

Measured memory_bytes: 768
var
	n,m,c,i,j,ans,s,a:longint;
	t:array[0..100] of longint;
begin
	readln(n,m,c);
	ans:=0;
	for i:=1 to m do read(t[i]);
	for i:=1 to n do
	begin
		s:=0;
		for j:=1 to m do
		begin
			read(a);
			s:=s+a*t[j];
		end;
		if s+c>0 then inc(ans);
	end;
	writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

int solve(int a, int b) {
  if (a <= b) {
    int rez = b - a;
    if (-a <= b) {
      rez = min(rez, b + a + 1);
    }
    if (a <= -b) {
      rez = min(rez, -b - a + 1);
    }
    return rez;
  }
  else {
    int rez = 2e9 + 20;
    if (a <= -b || b < 0) {
      rez = min(rez, 1 + solve(a, -b));
    }
    if (-a <= b || a < 0) {
      rez = min(rez, 1 + solve(-a, b));
    }
    rez = min(rez, 2 + solve(-a, -b));
    return rez;
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b;
  cin >> a >> b;
  cout << solve(a, b) << '\n';
} 

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

int A,B,C,D;

int main(){
    cin>>A>>B>>C>>D;
    while(1){
        C=C-B;
        if(C<=0)break;
        A=A-D;
        if(A<=0)break;
    }
    if(A>C){printf("Yes");}else {printf("No");}
}

Measured memory_bytes: 3684
if __name__ == '__main__':
    [n,k] = [int(i) for i in input().split()]
    m = dict()
    for i in range(1,n+1,1):
        m[i] = []
    for i in range(1,k+1,1):
        d = input()
        for j in input().split():
            m[int(j)].append(i) 

    count = 0
    for i in m.keys():
        if len(m[i]) == 0:
            count+=1
    print(count)

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

int main(){
  string a,q;
  int n;
  cin >> a>>n;
  int z,x;
  string c;
  int t=0;
  for(int i=0;i<n;i++){
    cin>>z;
    if(z==1){
      t++;
    }
    else if(z==2){
      cin >>x>>c;
      if(t%2==0&&x==1)q=q+c;
      else if(t%2==0&&x==2)a=a+c;
      else if(t%2==1&&x==2)q=q+c;
      else if(t%2==1&&x==1)a=a+c;
    }
  }
  if(t%2==0){
    reverse(a.begin(),a.end());
    a=a+q;
    reverse(a.begin(),a.end());   
    cout <<a<<endl;
  }
  else if(t%2==1){
    reverse(a.begin(),a.end());
    a=a+q;
    cout<<a<<endl;
  }
}


Measured memory_bytes: 1660
/*
    考虑一对位置的相对大小
    记 f_{i, j, k} 表示 i 次操作后 a_j > a_k 的概率
    最后要乘上 2 ^ q 
    时间复杂度 O(n * (n + q)) 
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 3005, mod = 1e9 + 7, inv2 = (mod + 1) >> 1;

int n, q;
int a[N];
int f[N][N], g[N][N];

inline void Inc(int &u, const int v) { if((u += v) >= mod) u -= mod; }

int main() {
    scanf("%d %d", &n, &q);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            f[i][j] = a[i] > a[j];
    int pw2 = 1;
    for(int Case = 1, x, y; Case <= q; ++Case) {
        scanf("%d %d", &x, &y);
        pw2 = (pw2 + pw2) % mod;
        for(int i = 1; i <= n; ++i) {
            g[i][x] = f[i][x], g[x][i] = f[x][i];
            g[i][y] = f[i][y], g[y][i] = f[y][i];
        }
        f[x][y] = 1LL * (f[x][y] + g[y][x]) * inv2 % mod;
        f[y][x] = 1LL * (f[y][x] + g[x][y]) * inv2 % mod;
        for(int i = 1; i <= n; ++i) if(i != x && i != y) {
            f[i][x] = 1LL * (f[i][x] + g[i][y]) * inv2 % mod;
            f[x][i] = 1LL * (f[x][i] + g[y][i]) * inv2 % mod;
            f[i][y] = 1LL * (f[i][y] + g[i][x]) * inv2 % mod;
            f[y][i] = 1LL * (f[y][i] + g[x][i]) * inv2 % mod;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j)
            ans = (ans + 1LL * pw2 * f[i][j]) % mod;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 70784
import sys
input = sys.stdin.readline
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
li = [0] * M
for i in range(M) :
    li[i] = [int(i) for i in input().split()]
ans = [0] * M
sum = 0
for i in range(N) :
    sum += T[i]
for i in range(M) :
    k = sum - T[li[i][0] - 1] + li[i][1]
    ans[i] = k
for i in range(M) :
    print(ans[i])

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

int main(int argc, char const *argv[]) {
    int x;
    cin >> x;

    for (long long a = -200; a <= 200; a++) {
        for (long long b = -200; b <= 200; b++) {
            if (a*a*a*a*a - b*b*b*b*b == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
  int N;
  cin >> N;
  rep(i, N) {
    int tmp;
    cin >> tmp;
    if (tmp % 2)
        continue;
    if (tmp % 3 != 0 && tmp % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
    }
  }
    cout << "APPROVED" << endl;

  return 0;
}


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

int main(){
  int N,L;
  vector<string> str;
  
  cin >> N >> L;
  
  for(int i = 0;i < N;++i){
	string tmp_str;
    cin >>  tmp_str;
    str.push_back(tmp_str);  
  }
  
  sort(str.begin(),str.end());
  
  string result ="";
  for(int i = 0;i < N;++i) result = result + str[i]; 
  cout << result << endl; 
  return 0;
}

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

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

  int N, T;
  cin >> N >> T;
  vector<pair<int, int> > v(N);
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    v[i].first = a;
    v[i].second = b;
  }

  sort(v.begin(), v.end());

  for(int i = 0; i < N; i++) {
    if(v[i].second > T) continue;
    cout << v[i].first << endl;
    return 0;
  }

  cout << "TLE" << endl;
  return 0;

}


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

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

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

struct block { i64 w, s, v; };

void solve() {
    i64 n;
    cin >> n;

    vector<block> b(n);
    for (auto& [ w, s, v ] : b) cin >> w >> s >> v;
    sort(all(b), [](block &x, block &y) { return x.w + x.s < y.w + y.s; });

    vector<i64> dp(2e4 + 10);
    for (auto& [ w, s, v ] : b) {
        for (i64 i = s; i >= 0; i--) {
            dp[i + w] = max(dp[i + w], dp[i] + v);
        }
    }
    cout << *max_element(all(dp)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (row[i]) {
      for (int j = 0; j < w; j++) {
        if (col[j]) {
          cout << s[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll x;
  cin >> x;

  ll a[N], b[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    b[i] = a[i];
  }

  // k=0
  ll ans = 0LL;
  for(int i=0;i<N;i++) ans += b[i];

  // 0<k<N-1
  for(int k=1;k<N;k++){
    for(int i=0;i<N;i++){
      int ind = i - k;
      if(i - k >= 0){
        b[i] = min(b[i], a[ind]);
      }
      else{
        b[i] = min(b[i], a[N + ind]);
      }
    }

    ll sum = 0LL;
    for(int i=0;i<N;i++) sum += b[i];
    ans = min(ans, sum + k * x);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

int main()
{
	ll n, result = 0;
	cin >> n;
	vector<ll> vet(n);
	for (int i = 0; i < n; ++i) {
		cin>> vet[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		if (vet[i] > vet[i + 1]) {
			result += vet[i] - vet[i + 1];
			vet[i + 1] = vet[i];
		}
	}
	cout << result << endl;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    int x = 7 % k;
    //cout << x << endl;
    for (int i = 1; i <= k; ++i) {
        if (x == 0) {
            cout << i << '\n';
            return 0;
        }
        x = (x * 10 + 7) % k;
        //cout << x << endl;
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<unordered_map>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<bitset>
#define ll long long 
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int arr[105][3];
ll n,w;
ll dp[105][100005];
ll fun(int item, int rem) {
	if (rem < 0)
		return -1e9;
	if (item == n + 1)
		return 0;
	if (dp[item][rem] != -1)
		return dp[item][rem];
	return dp[item][rem]=max(arr[item][2] + fun(item + 1, rem - arr[item][1]), fun(item + 1, rem));
}
int main()
{
	  cin >> n>>w;
	  for (int i = 1; i <= n; i++)
		  for (int j= 1;j<= 2; j++)
			  cin >> arr[i][j];
	  memset(dp, -1, sizeof dp);
	  cout << fun(1, w);

	return 0;
}

Measured memory_bytes: 82304
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> pos(n + 1);
  REP(i, n) {
    int p; cin >> p;
    pos[p] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp = 1;
    while (i + 1 <= n && pos[i] < pos[i + 1]) {
      ++tmp;
      ++i;
    }
    ans = max(ans, tmp);
  }
  cout << n - ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    Int n, m;
    cin>>n>>m;
    if(n == 0 && m == 0) break;
    
    vector<string> A(n);
    cin>>A;

    
    Int ans = 0;
    if(n <= 22){
      vector< bitset<500> > bin(n);
      for(int i=0;i<n;i++)
	for(int j=0;j<m;j++) bin[i][j] = (A[i][j] - '0');
      
      for(Int i=0;i<(1<<n);i++){
	bitset<500> stock = 0;
	for(Int j=0;j<n;j++){
	  if((i>>j&1) == 0) continue;
	  stock ^= bin[j];
	}
	if(stock == 0) ans = max(ans, (Int)__builtin_popcount(i));
      }
    }
    else{
      vector<Int> bin(n, 0);
      for(int i=0;i<n;i++)
	for(int j=0;j<m;j++) bin[i] |= (A[i][j] - '0') << j;
	    
      vector<vector<_int> > dp(n+1, vector<_int>(1<<m, -10000));
      dp[0][0] = 0;
      for(Int i=0;i<n;i++){
	for(Int j=0;j<(1<<m);j++){
	  Max(dp[i+1][j], dp[i][j]);
	  Max(dp[i+1][j ^ bin[i]], (_int)(dp[i][j] + 1));
	}
      }
      ans = dp[n][0];
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 208388
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
	long N, K;
	string S;
	cin >> N >> K >> S;
	
	long pos0 = 0, pos1 = 1;
	long j = 0;
	long ans = 0;

	for (int i = 0; i < (N - 1); i++) {
		if (S.at(i) == S.at(i + 1)) {
			ans++;
		}
	}

	for (long i = 0; i < K; i++) { // K回繰り返す
		for (j = pos0 + 1; j < N; j++) {
			if (S.at(pos0) != S.at(j)) {
				pos1 = j;
				ans++;
				break;
			}
		}

		if (j == N) {
			break;
		}

		for (j = pos1 + 1; j < N; j++) {
			if (S.at(pos1) != S.at(j)) {
				pos0 = j;
				ans++;
				break;
			}
		}

		if (j == N) {
			pos0 = N;
			break;
		}

		//string tempS1, tempS2;
		//tempS2 = S.substr(pos1, pos0 - pos1);
		//reverse(tempS2.begin(), tempS2.end());
		//for (long k = 0; k < pos0 - pos1; k++) {
		//	if (tempS2.at(k) == 'L') {
		//		tempS2.at(k) = 'R';
		//	}
		//	else {
		//		tempS2.at(k) = 'L';
		//	}
		//}
		//tempS1 = S.substr(0, pos1) + tempS2 + S.substr(pos0, N - pos0);
		//S = tempS1;
		////cout << S << endl;

	}



	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
A, B, C = list(map(int, input().split()))
K = int(input())

b_cnt = 0
while A >= B:
    B *= 2
    b_cnt += 1

c_cnt = 0
while B >= C:
    C *= 2
    c_cnt += 1

# print(A, B, C)
# print(b_cnt, c_cnt)

if b_cnt + c_cnt <= K:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;

lint calc(lint a,lint b){
    if(b == 0)return 1;
    if(b % 2 == 0){
        lint c = calc(a,b/2);
        return c * c;
    }else{
        return a * calc(a,b - 1);
    }
}

int main(){
    lint n;
    cin >> n;
    int q = sqrtl(n);
    vector<pair<lint,int>> a;
    lint ans = 0;
    lint num = 2;
    lint cnt = 0;
    int index = 0;
    while(1){
        if(n % num == 0){
            cnt++;
            if(cnt == 1){
                a.push_back(make_pair(num,cnt));
                index = a.size() - 1;
            }else{
                a[index].second++;
            }
            n /= num;
        }else{
            cnt = 0;
            num++;
        }
        if(n == 1) break;
        if(num > q){
            a.push_back(make_pair(n,1));
            break;
        }
    }
    cnt = 1;
    num = 2;
    REP(i,a.size()){
        int time = a[i].second;
        while(1){
            cnt += num;
            if(cnt > time){
                ans += num - 1;
                cnt = 1;
                num = 2;
                break;
            }
            num++;
        }
    }
    println(ans);

    return 0;
}

Measured memory_bytes: 3716
def rm_123(A):
	for a in set(A):
		if set([a,a+1,a+2]) <= set(A):
			A1 = A[:]
			for i in range(3): A1.remove(a+i)
			return judge(A1)

def rm_111(A):
	for a in set(A):
		if A.count(a) >= 3:
			A1 = A[:]
			for i in range(3): A1.remove(a)
			return judge(A1)

def judge(A):
	return len(A) == 0 or rm_123(A) or rm_111(A)

for _ in range(input()):
	n = map(int,raw_input().split())
	R = []; G = []; B = []
	s = raw_input().split()
	for i in range(len(n)):
		if   s[i] == "R": R.append(n[i])
		elif s[i] == "G": G.append(n[i])
		elif s[i] == "B": B.append(n[i])
	print 1 if judge(R) and judge(G) and judge(B) else 0
	

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, k, ta, ti, flag;
	vector<int> v, w1, w2;

	cin>> n >> k;
	v.resize(n);
	w1.resize(n+1);
	w2.resize(n+1);

	rep(i, n) cin >> v[i];

	//PV(v);
	rep(i, k) {
		rep(j, n){
			w1[j]=0;
			w2[j]=0;
		}
		rep(j, n){
			ta=max(0, j-v[j]);
			ti=min(n-1, j+v[j]);
			//if(ta!=j) w1[ta]++;
			//if(ti!=j) w2[ti]++;
			w1[ta]++;
			w2[ti]++;
		}
		
		//PV(w1);
		//PV(w2);
		flag=1;
		v[0]=w1[0];
		if(v[0]!=n) flag=0;
		for(int j=1;j<n;j++){
			v[j]=v[j-1]+w1[j]-w2[j-1];
			if(v[j]!=n) flag=0;
		}
		//PV(v);
		if(flag){
			PV(v);
			return 0;
		}
	}
 
	PV(v);
	return 0;
}

/*
	PV(v);
	rep(i, k) {
		rep(j, n){
			w[j]=0;
			rep(l, n){
				if(abs(l-j)<=v[l]) w[j]++;
			}
		}
		rep(j, n) v[j]=w[j];
		PV(v);
	}
*/

Measured memory_bytes: 6364
//
//  main.cpp
//  contest
//
//  Created by TmpGuest on 2020/4/18.
//  Copyright © 2020 TmpGuest. All rights reserved.
//

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(0);
    double pi=3.14159265358979323846;
    int i;
    cin>>i;
    cout<<2*i*pi<<endl;
    
    return 0;
}


Measured memory_bytes: 3788
#include<cstdio>
#include<algorithm>
using namespace std;

#define M 1000000007

int main(){
  long long a,b;
  long long ans;  
  long long aa,bb;
  
  scanf(" %lld %lld",&a,&b);
  
  aa = bb = 1;
  for(int i=1;i<=a;i++){
    aa = (aa * i) % M;
  }
  for(int i=1;i<=b;i++){
    bb = (bb * i) % M;
  }
  
  if(a == b){
    printf("%lld\n",(aa*bb*2)%M);
  } else if(a+1 == b || a-1 == b){
    printf("%lld\n",(aa*bb)%M);
  } else {
    printf("%d\n",0);
  }
  
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	double T, A;
	cin >> T >> A;
	vector<double> H(N);
	for (int i = 0;i < N;i++) {
		cin >> H[i];
	}
	int res = 0;
	vector<double> at(N);
	vector<double> atd(N);
	double s = 10000;
	for (int i = 0;i < N;i++) {
		at[i] = T - 0.006*H[i];
		atd[i] = fabs(at[i] - A);
		if (s > atd[i]) {
			s = atd[i];
			res = i+1;
		}
	}

	cout << res << endl;
	
}

Measured memory_bytes: 256
function main(input) {
  var D = input[0].split(" ")[0]-0;
  var G = input[0].split(" ")[1]-0;
  var lines = [];
  var pafemap = [];
  for(var i=1;i<=D;i++){
    lines.push(input[i].split(" ").map(v=>v-0));
    pafemap.push(i*100*lines[i-1][0]+lines[i-1][1]);
  }
  var ans = 100*100;
  for(var i=0;i<Math.pow(2,D);i++){
    var st = ("0000000000" + i.toString(2)).slice(-D);
    var score = 0;
    var nums = 0;
    var npafe = [];
    for(var j=0;j<st.length;j++){
      if(st[j]=="1"){
        score += pafemap[j];
        nums += lines[j][0];
      }else{
        npafe.push({
          i: j+1, num: lines[j][0],
        });
      }
    }
    if(score<G){
      npafe.reverse();
      for(var j=0;j<npafe.length;j++){
        var num = npafe[j].num-1;
        var scr = npafe[j].i*100;
        if(score+scr*num<G){
          score+=scr*num;
          nums+=num;
        }else{
          var n = Math.min(num, Math.ceil((G-score)/scr));
          score+=scr*n;
          nums+=n;
          break;
        }
      }
    }
    if(score>=G)
      ans = Math.min(ans, nums);
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int main() {
	// your code goes here
	string s;
	cin >> s;
	long long int ans = 0;
	for (long long int i = 0; i < s.length();i++) {
	    ans += (s[i] - 48);
	}
	if (ans % 9 == 0)   cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3740
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

int main(void) {

	ll n, k;
	cin >> n >> k;
	cout << ll(k * pow(k - 1, n - 1)) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int sum=0;
  for(int i=0;i<n;i++){
    int l,r;
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll N,M,S;
    cin>>N>>M>>S;
    ll max_a = 0;
    vector<vector<ll>> uv(N);
    ll cost[N][N] = {};
    ll delay[N][N] = {};
    rep(i,M){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        --u;--v;
        uv[u].push_back(v);
        uv[v].push_back(u);
        cost[u][v] = cost[v][u] = a;
        delay[u][v] = delay[v][u] = b;
        max_a = max(max_a,a);
    }
    vector<ll> C(N),D(N);
    rep(i,N){
        cin>>C[i]>>D[i];
    }
    ll ans[N] = {};

    deque<ll> pos,coin,sum_time;
    pos.push_back(0);
    ll max_coin = max_a*(N-1);
    if(S>max_coin){
        S = max_coin;
    }
    coin.push_back(S);
    sum_time.push_back(0);

    
    ll dp[N][max_coin+1];
    rep(i,N){
        rep(j,max_coin+1){
            dp[i][j] = -1;
        }
    }
    ll p,c,t;
    ll arrival_t,money;
    while(!pos.empty()){
        p = pos.front();pos.pop_front();
        c = coin.front();coin.pop_front();
        t = sum_time.front();sum_time.pop_front();
        
        for(auto next:uv[p]){
            if(c>= cost[p][next]){
                arrival_t = t + delay[p][next];
                money = c - cost[p][next];
                if(dp[next][money] == -1 || dp[next][money]>arrival_t){
                    dp[next][money] = arrival_t;
                    if(ans[next]==0){
                        ans[next]= arrival_t;
                    }else{
                        ans[next] = min(ans[next],arrival_t);
                    }
                    pos.push_back(next);
                    coin.push_back(money);
                    sum_time.push_back(arrival_t);
                }
            }
        }
        
        while(c!=max_coin){
            c += C[p];
            t += D[p];
            if(c>max_coin){
                c = max_coin;
            }
            if(dp[p][c]==-1||dp[p][c]>t){
                dp[p][c]=t;
                pos.push_back(p);
                coin.push_back(c);
                sum_time.push_back(t);
            }else{
                break;
            }
        }
    }

    rep(i,N-1){
        cout<<ans[i+1]<<"\n";
    }

    return 0;
}


Measured memory_bytes: 9972
#include <cstdio>
#include <cstring>

#include <vector>
#include <algorithm>

using namespace std;

#define NMAX 1000
#define CMAX 100000

static int c;
static int m[NMAX + 10][NMAX + 10];

bool solve(int n) {
    int p = n / 2;
    if (n <= 2)
        return false;
    else if (n & 1) {
        if (n == 3) {
            m[1][1] = m[2][1] = ++c;
            m[3][2] = m[3][3] = ++c;
        } else {
            for (int i = 3; i < n; i++) {
                m[i - 1][i] = m[i - 1][i + 1] = ++c;
                m[i][i] = m[i + 1][i] = ++c;
            }
            m[1][1] = m[2][1] = ++c;
            m[1][2] = m[1][3] = ++c;
            m[3][1] = m[3][2] = ++c;
            m[1][n] = m[2][n] = ++c;
            m[n][1] = m[n][2] = ++c;
            m[n - 1][n] = m[n][n] = ++c;
        }
    } else {
        if (n == 4) {
            m[1][1] = m[1][2] = ++c;
            m[2][1] = m[2][2] = ++c;
            m[3][3] = m[3][4] = ++c;
            m[4][3] = m[4][4] = ++c;
            m[1][3] = m[2][3] = ++c;
            m[1][4] = m[2][4] = ++c;
            m[3][1] = m[4][1] = ++c;
            m[3][2] = m[4][2] = ++c;
        } else {
            if (!solve(n / 2))
                return false;
            for (int i = 1; i <= p; i++)
            for (int j = 1; j <= p; j++)
                m[p + i][p + j] = m[i][j] ? m[i][j] + c : 0;
            c *= 2;
        }
    }
    return true;
}

static vector<int> G[CMAX + 10];
static bool mark[100];
static char z[CMAX + 10];

int main() {
    int n;
    scanf("%d", &n);
    if (solve(n)) {
        for (int x = 1; x <= n; x++)
        for (int y = 1; y <= n; y++) {
            constexpr int dx[] = {-1, 1, 0, 0};
            constexpr int dy[] = {0, 0, -1, 1};
            for (int i = 0; i < 4; i++) {
                int tx = x + dx[i];
                int ty = y + dy[i];
                if (1 <= tx && tx <= n &&
                    1 <= ty && ty <= n &&
                    m[x][y] != m[tx][ty])
                    G[m[x][y]].push_back(m[tx][ty]);
            }
        }

        for (int u = 1; u <= c; u++) {
            for (int v : G[u])
                mark[z[v]] = true;
            for (z[u] = 1; mark[z[u]]; z[u]++) ;
            for (int v : G[u])
                mark[z[v]] = false;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++)
                putchar(m[i][j] ? 'a' + z[m[i][j]] - 1 : '.');
            putchar('\n');
        }
    } else puts("-1");
    return 0;
}


Measured memory_bytes: 7680
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x;
int main(){
    int n;
    cin>>n;
    vector<int> t(n),x(n),y(n);
    rep(i,n)cin>>t.at(i)>>x.at(i)>>y.at(i);
    for(int i=0;i<n;i++){
        if(t.at(i)%2!=(x.at(i)+y.at(i))%2){
            cout<<"No"<<endl;
            return 0;
        }
        else{
            if((x.at(i)+y.at(i))>t.at(i)){
                cout<<"No"<<endl;
                return 0;
            }
            else if(i>1){
                int dist = (x.at(i)-x.at(i-1))+(y.at(i)-y.at(i-1));
                int dif_t = t.at(i)-t.at(i-1);
                if(dif_t<dist){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}




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

using namespace std;
int cnt[26];
int main()
{
    string x;
    cin>>x;
    for(int i=0;i<x.size();i++){
        cnt[x[i]-'a']++;
    }
    long long ans=0;
    for(int i=0;i<x.size();i++){
        cnt[x[i]-'a']--;
        ans+=(long long)x.size()-i-1LL-(long long)cnt[x[i]-'a'];
    }
    cout<<ans+1LL<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int a,b,c,t;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)t=a,a=b,b=t;
	if(b>c)t=b,b=c,c=t;
	if(a>b)t=a,a=b,b=t;
	printf("%d %d\n",a,c);
}


Measured memory_bytes: 2108
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . which "YES" "NO" . solve "AKIHABARA"

solve [] [] = True
solve [c] [] = c == 'A'
solve [] _ = False
solve _ [] = False
solve (c1:t) ss@(c2:s)
	| c1 == c2 = solve t s
	| c1 == 'A' = solve t ss
	| otherwise = False

Measured memory_bytes: 380
/**
	Language: C++ 11
	Author  : ebby21
**/

#include <bits/stdc++.h>

using namespace std;

#define FASTIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define DEBUG(var) cerr << '\n' << #var << "\t:\t" << var << '\n'
#define FORF(i, L, U) for (ll i = (L); i <= (U); ++i)
#define FORR(i, U, L) for (ll i = (U); i >= (L); --i)
#define FORE(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef unsigned int ui;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

int main() {
	FASTIO();
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans = n/(a+b) * a;
	n%=a+b;
	if(n<a){
		ans+=n;
	}else{
		ans+=a;
	}
	cout<<ans<<'\n';
	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()
{
	int n;
	cin>>n;
	vec a(n);
	rep(i,0,n)a[i]=read();
	sort(all(a));
	int ans=0;
	rep(i,0,n)ans=ans+a[i]*((i%2)?1:-1);
	cout<<abs(ans)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int N;
vector<vector<int>>G;
ll memo[int(1e5) + 1][2];
vector<bool> visited;

ll dfs(int parent, int parentColor, int wher) {
    if(memo[parent][parentColor] != -1) return memo[parent][parentColor];
    ll ret = 1;
    for(int next : G[parent]) {
        if(next == wher)continue;
        if(parentColor == 0) { //白
            ret = ret * (dfs(next, 0, parent) + dfs(next, 1, parent)) % MOD;
        }else {
            ret = ret * dfs(next, 0, parent) % MOD;
        }
    }
    return memo[parent][parentColor] = ret % MOD;
}

int main() {
    cin >> N;
    G.resize(N);
    rep(i, N - 1) {
        int x, y; cin >> x >> y; --x, --y;
        G[x].pb(y); G[y].pb(x);
    }
    rep(i, N + 1) {
        rep(j, 2) {
            memo[i][j] = -1;
        }
    }
    //Node0を白にする通り数 + 黒にする通り数
    ll ans = dfs(0, 0, 0);
    ans += dfs(0, 1, 0);
    cout << ans % MOD << endl;
}


Measured memory_bytes: 15616
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/dsu>
using namespace atcoder;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, q; cin >> n >> q;
  dsu d(n);
  while (q--) {
    int type, u, v; cin >> type >> u >> v;
    if (type == 0) {
      d.merge(u, v);
    } else {
      cout << d.same(u, v) << '\n';
    }
  }
  
  return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  REP(i,1000){
    stringstream ssub;
    ssub << setw(3) << setfill('0') << i;
    string ss = ssub.str();
    int p = 0;
    while(s[p]!=ss[0]){
      p++;
      if(p==n-2) break;
    }
    if(p==n-2) continue;
    p++;
    while(s[p]!=ss[1]){
      p++;
      if(p==n-1) break;
    }
    if(p==n-1) continue;
    p++;
    while(s[p]!=ss[2]){
      p++;
      if(p==n) break;
    }
    if(p==n) continue;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long N, D, X, Y, count = 0;
    scanf("%ld %ld",&N, &D);
    
    for(long i = 0; i < N; i++)
    {
        scanf("%ld %ld", &X, &Y);
        if(X*X + Y*Y <= D*D)
            count++;
    }
    
    printf("%ld\n", count);
}


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

int main(){
    string A, S, C, ASC, A0, S0, C0;
    cin >> A >> S >> C;
    A0 = A.at(0);
    S0 = S.at(0);
    C0 = C.at(0);
    ASC = A0+S0+C0;
    cout << ASC << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 105
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int A,B;
bool grid[MAXN][MAXN];
void print()
{
    puts("100 100");
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++) 
            if(grid[i][j]) printf("#"); else printf(".");
        puts("");
    }
}
int main()
{
    scanf("%d%d",&A,&B);
    if(A==1)
    {
        memset(grid,false,sizeof(grid));
        for(int i=1;i<=100;i+=2)
            for(int j=1;j<=100;j+=2)
                if(B) grid[i][j]=true,B--;
    }
    else if(B==1)
    {
        memset(grid,true,sizeof(grid));
        for(int i=1;i<=100;i+=2)
            for(int j=1;j<=100;j+=2)
                if(A) grid[i][j]=false,A--;
    }
    else
    {
        memset(grid,false,sizeof(grid));
        for(int i=1;i<=100;i++) grid[50][i]=true;
        for(int i=52;i<=100;i++)
            for(int j=1;j<=100;j++)
                grid[i][j]=true;
        A-=2;B-=2;
        for(int i=1;i<49;i+=2)
            for(int j=1;j<=100;j+=2)
                if(B) grid[i][j]=true,B--;
        for(int i=53;i<=100;i+=2)
            for(int j=1;j<=100;j+=2)
                if(A) grid[i][j]=false,A--;
    }
    print();
    return 0;
}



Measured memory_bytes: 256
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))


max1=-1
max2=-10

max1_ind=-100
max2_ind=-100

for i in range(len(S)):
        if S[i] > max1:
                max2=max1
                max2_ind = max1_ind

                max1=S[i]
                max1_ind=i
        elif S[i] > max2:
                max2=S[i]
                max2_ind=i

for i in range(len(S)):
        if i != max1_ind:
                print(max1)
        else:
                print(max2)

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

const ll kMod = 1e9 + 7;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<bool> ok_step(N + 1, true);
  for (int i = 0; i < M; i++) {
    int in;
    cin >> in;
    ok_step[in] = false;
  }
  vector<ll> dp(N + 1);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= min(N, i + 2); j++) {
      if (ok_step[j]) {
        dp[j] += dp[i];
        dp[j] %= kMod;
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024