akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: usize = read!();
    let mut b:usize = 0;
    let mut c:usize = 0;
    for i in 105..=a {
        for j in 1..=i {
            if i%2==1 {
                if i%j==0 {
                    b+=1;
                }
            }
        }
        if b==8 {
            c+=1;
        }
        b=0;
    }
    println!("{}",c)
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int H, W, N; scanf("%d %d %d", &H, &W, &N);
  int r, c;
  vector<pair<int, int> > v;
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &r, &c);
    for (int dr = 0; dr < 3; ++dr) {
      for (int dc = 0; dc < 3; ++dc) {
        int nr = r - dr, nc = c - dc;
        if (1 <= nr and nr + 2 <= H and 1 <= nc and nc + 2 <= W) {
          v.push_back(make_pair(nr, nc));
        }
      }
    }
  }

  sort(v.begin(), v.end());
  int m = v.size();
  vector<ll> ans(10, 0);
  ll total = 1LL * (H - 2) * (W - 2);
  ll sum = 0;
  for (int i = 0; i < m; ) {
    int j = i;
    while (j < m and v[j] == v[i]) { ++j; }
    int cnt = j - i;
    ++ans[cnt];
    ++sum;
    i = j;
  }
  ans[0] = total - sum;
  for (int i = 0; i < 10; ++i) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> B(N);
    cin >> B;

    REP(i, N) {
        if (B[i] > i + 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> ans(N);
    vector<bool> used(N);
    REP(i, N) {
        int cnt = 0;
        int last = -1;
        REP(j, N) {
            if (used[j]) continue;
            cnt++;
            if (B[j] == cnt) {
                last = j;
            }
        }
        used[last] = true;
        ans[i] = B[last];
    }
    reverse(ALL(ans));
    FORE(x, ans) {
        cout << x << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,all=0;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d.at(i);
  }
  for(int i;i<n;i++){
    for(int i2=i+1;i2<n;i2++){
      all+=d.at(i)*d.at(i2);
      //cout<<all<<endl;
    }
  }
  cout<<all<<endl;
}


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

int main()
{
  char a, b;
  cin >> a >> b;
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
    cout << 'H' << endl;
  }
  else{
    cout << 'D' << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,L,R) for (ll i = L; i <= R; i++) 
int main()
{
    
    //ll n;cin>>n;
    //ll a[n+34]={0}; //RAM-RAM!!
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
bool visit[111111];
int main(){
  int K;
  cin>>K;
  deque<PA> que;
  que.PB(MA(1,1));
  while(!que.empty()){
    PA P=que.front();que.pop_front();
    if(visit[P.FI]){
      continue;
    }
    visit[P.FI]=true;
    if(P.FI==0){
      cout<<P.SE<<endl;
      break;
    }
    int V=P.FI;
    int cost=P.SE;
    que.PB(MA((V+1)%K,cost+1));
    que.push_front(MA((V*10)%K,cost));
  }
  return 0;
}


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

int main(){
  int x;
  cin >> x;
  if (x < 600) cout << 8 << endl;
  else if (x < 800) cout << 7 << endl;
  else if (x < 1000) cout << 6 << endl;
  else if (x < 1200) cout << 5 << endl;
  else if (x < 1400) cout << 4 << endl;
  else if (x < 1600) cout << 3 << endl;
  else if (x < 1800) cout << 2 << endl;
  else if (x < 2000) cout << 1 << endl;
  
  return 0;
}
    
    

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,b,c,i,sum=0,l;

    scanf("%d %d %d",&a,&b,&c);

    if(a>b)
    {
        for(i=b;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

     else if(a<b)
    {
        for(i=a;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

    else if(a==b)
    {
        for(i=a;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_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 set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,Q;
  cin >> N >> Q;
  vector<pair<P,int>> L(N);
  rep(i,N) {
    int a,b,c;
    cin >> a >> b >> c;
    L[i] = make_pair(P(a-c,b-c),c);
  }
  set<P> D;
  rep(i,Q) {
    int d;
    cin >> d;
    D.insert(P(d,i));
  }
  vi ans(Q,-1);
  sort(rng(L),[](pair<P,int> &l,pair<P,int> &r) {
    return l.second < r.second;
  });
  rep(i,N) {
    pair<P,int> l = L[i];
    int s = l.first.first;
    int g = l.first.second;
    auto it = D.lower_bound(P(s,-1));
    while(it != D.end()) {
      if(it->first >= g) break;
      ans[it->second] = l.second;
      D.erase(it++);
    }
  }
  rep(i,Q) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 200011
#define maxLog 19

int n, i, j, pos, V, k, limit, id, conf, new_conf, mini;
int x[maxN];
vector<int> v;
int l[maxLog][maxN], r[maxLog][maxN];

int dpL[1 << maxLog], dpR[1 << maxLog];
vector< pair<int, int> > ord, que;

bool ans[maxN];

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d%d", &n, &V);
    for (i = 1; i <= n; i++) scanf("%d", &x[i]);
    v = {V / 2};
    while (v.back() != 0) v.pb(v.back() / 2);
    k = v.size();

    for (i = 0; i < k; i++) {
        l[i][1] = 1;
        for (pos = 2; pos <= n; pos++) {
            if (x[pos] - x[pos - 1] <= v[i])
                l[i][pos] = l[i][pos - 1];
            else
                l[i][pos] = pos;
        }

        r[i][n] = n;
        for (pos = n - 1; pos > 0; pos--) {
            if (x[pos + 1] - x[pos] <= v[i])
                r[i][pos] = r[i][pos + 1];
            else
                r[i][pos] = pos;
        }
    }

    limit = 1 << k;
    for (i = 0; i < limit; i++) {
        dpL[i] = 0;
        dpR[i] = n + 1;
    }

    for (conf = 0; conf < limit; conf++) {
        for (id = 0; id < k; id++) {
            if (conf & (1 << id)) continue;
            new_conf = conf | (1 << id);

            dpL[new_conf] = max(dpL[new_conf], min(n, r[id][ dpL[conf] + 1 ]));
            dpR[new_conf] = min(dpR[new_conf], max(1, l[id][ dpR[conf] - 1 ]));
        }
    }

    for (conf = 0; conf < limit; conf++)
        ord.pb(mp(dpL[conf], dpR[(limit - 1) ^ conf]));

    sort(ord.begin(), ord.end());
    reverse(ord.begin(), ord.end());

    for (i = 1; i <= n; i = j) {
        for (j = i + 1; j <= n && x[j] - x[j - 1] <= V; j++);
        que.pb(mp(i, j - 1));
    }

    reverse(que.begin(), que.end());

    pos = 0;
    mini = n + 2;

    for (auto e : que) {
        while (pos < ord.size()) {
            if (ord[pos].first + 1 < e.first) break;
            mini = min(mini, ord[pos].second);
            pos++;
        }

        if (mini <= e.second + 1) {
            for (i = e.first; i <= e.second; i++)
                ans[i] = true;
        }
    }

    for (i = 1; i <= n; i++) {
        if (ans[i])
            printf("Possible\n");
        else
            printf("Impossible\n");
    }


    return 0;
}


Measured memory_bytes: 37488
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n;
int a[200000+5];
int b[200000+5];
//int ans[]

int main(){
	scanf("%d", &n);
	FOR(i,1,n){
		scanf("%d", a+i);
	}
	bool ans = true;
	
	/* 
	FOR(i,1,n/2){
		int cnt = i;
		int sm = 0;
		while(cnt <= n){
			sm += a[cnt];
			cnt += i;
		}
		if(sm % 2 != a[i]) ans = false;
	}*/
	//FOR(i,n/2+1,n) b[i] = a[i];

	for(int i=n/2;i>=1;i--){
		int cnt = i+i;
		int sm = 0;
		while(cnt <= n){
			sm += a[cnt];
			cnt += i;
		}
		if(sm % 2 == a[i]) a[i] = 0;
		else a[i] = 1;
	}

	int one = 0;
	FOR(i,1,n){
		if(a[i] == 1) one += 1;
		//cout << a[i] << ' ';
	}
	
	cout << one << endl;
	FOR(i,1,n){
		if(a[i] == 1) cout << i << ' ';
	}
	//cout << endl;
    return 0;
}


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

N, A, B, C = map(int, input().split())
s = [input().rstrip() for _ in range(N)]
ans = []

def add(c, comb):
    global A, B, C
    if comb == 'AB':
        if c == 'A':
            ans.append('A')
            A += 1
            B -= 1
        else:
            ans.append('B')
            A -= 1
            B += 1
    if comb == 'BC':
        if c == 'B':
            ans.append('B')
            B += 1
            C -= 1
        else:
            ans.append('C')
            B -= 1
            C += 1
    if comb == 'AC':
        if c == 'A':
            ans.append('A')
            A += 1
            C -= 1
        else:
            ans.append('C')
            A -= 1
            C += 1

for i in range(N):
    if s[i] == 'AB':
        if A == B == 0:
            print('No')
            exit()
        if i < N - 1 and A == B == 1 and C == 0 and s[i+1] != 'AB':
            if s[i+1] == 'BC':
                add('B', 'AB')
            else:
                add('A', 'AB')
        else:
            if A > B:
                add('B', 'AB')
            else:
                add('A', 'AB')
    if s[i] == 'BC':
        if B == C == 0:
            print('No')
            exit()
        if i < N - 1 and B == C == 1 and A == 0 and s[i+1] != 'BC':
            if s[i+1] == 'AB':
                add('B', 'BC')
            else:
                add('C', 'BC')
        else:
            if B > C:
                add('C', 'BC')
            else:
                add('B', 'BC')
    if s[i] == 'AC':
        if A == C == 0:
            print('No')
            exit()
        if i < N - 1 and A == C == 1 and B == 0 and s[i+1] != 'AC':
            if s[i+1] == 'AB':
                add('A', 'AC')
            else:
                add('C', 'AC')
        else:
            if A > C:
                add('C', 'AC')
            else:
                add('A', 'AC')
print('Yes')
print(*ans, sep='\n')

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


int main(){
int n;
cin >> n;
int count = 0;
int mx = 0;
int k, ans;

if (n == 1)
{
    ans = 1;
    goto goal;
}


for (int i = 0; i < n; i++)
{
    count = 0;
    k = i + 1;
    while (k % 2 == 0)
    {
        k /= 2;
        count++;
    }

    if (count > mx)
    {
        ans = i + 1;
        mx = count;
    }
    
    
    
}
goal:
cout << ans << endl;
}

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  for (auto &&i : a)
  {
    cin >> i;
  }
  int q;cin>>q;
  vector<int> m(q);
  vector<bool> b(q, false);
  for (auto &&i : m)
  {
    cin >> i;
  }
  for (int i = 0; i < (1 << n); i++)
  {
    long long tmpsum = 0;
    for (int j = 0; j < n; j++)
    {
      if(i & 1<<j)
      {
        tmpsum += a.at(j);
      }

    }
    for (int i = 0; i < q; i++)
    {
      if (tmpsum == m.at(i))b.at(i) = true;
    }
    
    
    
  }
  
  for (auto &&i : b)
  {
    if(i)cout << "yes"<< endl;
    else cout << "no" << endl;
  }
  
  
}


Measured memory_bytes: 3088
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  const int MAXP = 1000000+1;
  bool prime[MAXP];
  fill(prime, prime+MAXP, true);
  prime[0] = prime[1] = false;
  for(int i=2;i<MAXP;++i)
	if(prime[i])
	  for(int j=i+i;j<MAXP;j+=i) prime[j] = false;

  while(true){
	int a, d, n; cin >> a >> d >> n; if(a == 0 && d == 0) break;
	for(;;a+=d)
	  if(prime[a])
		if(--n <= 0){
		  cout << a << endl;
		  break;
		}
  }
  return 0;
}

Measured memory_bytes: 2164
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#include<set>
#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define newline cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007


int main() {

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

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif


	int n, k;
	cin >> n >> k;

	vector<int> ht(n);
	vector<int> cost(n);

	loopi(0, n)
	{
		cin >> ht[i];
	}
	cost[0] = 0;
	loopi(1, n)
	{
		int mincost = INT_MAX;
		loopj(1, k + 1)
		{

			if (i - j >= 0)
			{
				mincost = min(mincost, abs(ht[i - j] - ht[i]) + cost[i - j]);
			}

		}
		cost[i] = mincost;
	}

	cout << cost[n - 1];

	return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	K = min(K, (int)100);
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	// vector<int> A(N, 0);
	// vector<int> B;
	for (int i = 0; i < K; i++) {
		vector<int> nA(N + 1, 0);
		for (int j = 0; j < N; j++) {
			nA[max((int)0, j - A[j])]++;
			nA[min(N, j + A[j] + 1)]--;
		}
		A[0] = nA[0];
		for (int j = 1; j < N; j++) {
			A[j] = nA[j] + A[j - 1];
		}
	}
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;

	// for (int i = 0; i < N; i++) {
	// 	if (A[i] != B[i]) {
	// 		cout << "A" << endl;
	// 		return 0;
	// 	}
	// }
	return 0;
}

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

using namespace std;

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

  int ret = 0, ptr = 0;
  while(ptr < S.size()) {
    int latte = 0, malta = 0, beet = 0;
    while(ptr < S.size() && S[ptr] == 'J') ++ptr, ++latte;
    while(ptr < S.size() && S[ptr] == 'O') ++ptr, ++malta;
    while(ptr < S.size() && S[ptr] == 'I') ++ptr, ++beet;
    if(latte >= malta && malta <= beet) ret = max(ret, malta);
  }
  cout << ret << endl;
}

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

int main() {
  vector<int> vec(3);
  rep(i,3)cin>>vec[i];
  int k;cin>>k;
  sort(all(vec));
  reverse(all(vec));
  rep(i,k)vec[0]*=2;
  int cnt=0;
  rep(i,3)cnt+=vec[i];
  cout<<cnt<<endl;
}

Measured memory_bytes: 3576
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   string s;
  
   cin >> n >> s;
  
   for(int i=0;i<s.size();i++){
    
    char ss=s[i];
    if(ss+n>=91){
      
      printf("%c", (s[i]+n-26)); 
    }else{
      
     printf("%c", (s[i]+n)); 
    }
     
   }
  
   
   
  return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

invert = lambda T:(''.join(map(lambda x:dict([('R','L'),('L','R'),('U','D'),('D','U')])[x],list(T))))[::-1]
dist = lambda a,b:abs(a-b)
O = ""

O +=        "L" +  "U"*dist(sy  ,ty+1) + "R"*dist(sx-1,tx  )        + "D"
O += invert("U" +  "U"*dist(sy+1,ty  ) + "R"*dist(sx  ,tx-1)        + "R")
O +=        "R" + ("U"*dist(sy  ,ty-1) + "R"*dist(sx+1,tx  ))[::-1] + "U"
O += invert("D" + ("U"*dist(sy-1,ty  ) + "R"*dist(sx  ,tx+1))[::-1] + "L")

print(O)

Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        #親の添字、親自身は木の要素数*-1をもつ
        self.root = [-1]*(n)
        #枝の最大長さ
        self.rank = [0]*(n)

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    #高さによる合併    
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]    
    
    def members(self, x):
        root = self.find_root(x)
        return [i for i in range(self.n) if self.find_root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

N, M, K = map(int,input().rstrip().split())
AB=[list(map(int,input().rstrip().split()))for _ in range(M)]
CD=[list(map(int,input().rstrip().split()))for _ in range(K)]

u = UnionFind(N)
for a,b in AB:
    u.unite(a-1,b-1)

ans=[u.count(i)-1 for i in range(N)] #木の要素数から自分を引く
ans

for a,b in AB:
    if u.same(a-1,b-1):
        ans[a-1]-=1
        ans[b-1]-=1

for c,d in CD:
    if u.same(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
print(*ans)

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

int C = 0;

void binary_search(int *s, int size, int t){
  int l, m, r;

  l = 0;
  r = size - 1;

  while(l <= r){
    m = (r + l)/2;

    if(s[m] == t){
      C++;
      break;
    }
    else if(s[m] < t){
      l = m +1;
    }
    else{
      r = m -1;
    }
  }
};

int main(){

  int *S, *T,n,N,i,j;

  scanf("%d",&n);
  S = (int *)malloc(sizeof(int)*n);

  for(i=0; i<=n-1; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&N);
  T = (int *)malloc(sizeof(int)*N);
  for(i=0; i<=N-1; i++){
    scanf("%d",&T[i]);
  }

  //二分探査
  for(i=0;i<=N-1; i++){
    binary_search(S, n, T[i]);
  }


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

  return 0;
}


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

int main(){
    int N; cin >> N;
    map<string, bool> m;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        if (m[s])continue;
        else {
            m[s] = true;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19156
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    n = len(s)

    for i in range(0,n,2):
        if s[i:i+2] == 'hi':
            continue
        else:
            print('No')
            return
    print('Yes')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5584
#include <stdio.h>
int main (){
int k,a,b;
  scanf ("%d",&k);
  b=k%100;
a=(k-b)/100;
if (a>0 && a<13){
if (b>0 && b<13){
printf ("AMBIGUOUS");
}
else{
printf ("MMYY");
}
}
  else{
  if (b>0 && b<13){
  printf ("YYMM");
  }
    else {
    printf ("NA");
    }
  }
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;

int fact[200];
int dp[270005];

int memo[52][52];
int preS[52][52];
int choose(int N, int C){
	if(C == -1) return 0;
	if(C > N) return 0;
	if(C == 0) return 1;
	if(memo[N][C] != 0) return memo[N][C];
	return memo[N][C] = choose(N-1,C) + choose(N-1,C-1);
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	fact[0] = 1;
	
	int n,K,A,O; cin >> n >> K >> A >> O;
	
	int arr[n];
	for(int i = 0;i < n;i++) cin >> arr[i];
	
	int X = A ^ O;
	
	if((X & A) != 0){
		cout << 0; return 0;
	}
	vector<int> v;
	for(int i = 0;i < n;i++){
		bool can = true;
		for(int b = 0;b < 18;b++){
			if(X & (1<<b)) continue;
			
			if((O & (1<<b)) == (arr[i] & (1<<b))) continue;
			else can = false;
		}
		
		if(can) v.push_back(arr[i]);
	}	
	
	for(int i = 0;i <= 50;i++){
		for(int k = 1;k <= 50;k++){
			preS[i][k] = choose(i,k);
			if(k != 0) preS[i][k] += preS[i][k-1];
		}
	}
	
	//count complement
	int OV = 0;
	int ans = 0;
	
	for(int mask = 1;mask < 1<<18;mask++){
		int val = 0;
		if((mask & X) != mask) continue;
		
		unordered_map<int,int> M;
		for(int x : v){
			M[mask & x]++;
		}
		
		for(ii x : M){
			val += preS[x.second][K];
		}
		
		int par = __builtin_popcountll(mask);
		
		//cout << mask << " " << k << " " << val << " " << "\n";
		if(par & 1) ans += val;
		else ans -= val;
	}
	
	
	//cout << k << " " << ans << "\n";
	
	OV += preS[v.size()][K] - ans;
	
	
	cout << OV;
	
}



Measured memory_bytes: 3708
import math
import sys
A,V = map(int, input().split())
B,W = map(int, input().split())
T=int(input())
kyo=abs(A-B)
hay=V-W
if hay<=0 :
    print("NO")
    sys.exit()
if T>=math.ceil(kyo/hay) :
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#define ll long long
#define INF 100000000000000000
#define MAX 100010
using namespace std;

struct edge{
  int to;
  ll cost;
};

typedef pair<ll, int> p;
vector<edge> graph[MAX];
vector<ll> dist;

bool bellman_ford(int n){ //nは頂点数
  for(int i = 0; i < n; i++){
    for(int v = 0; v < n; v++){
      for(int k = 0; k < graph[v].size(); k++){
        edge e = graph[v][k];
        if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
          dist[e.to] = dist[v] + e.cost;
          if(i == n) return true; // 負の回路が存在
        }
      }
    }
  }
  return false;
}

int main(){
  int v, e, s, t;
  ll d;
  cin >> v >> e;
  for(int i = 0; i < e; i++){
    cin >> s >> t >> d;
    s--; t--;
    graph[s].push_back((edge){t, -d});
  }
  dist = vector<ll>(v, INF); //distをINFで初期化
  dist[0] = 0;
  bellman_ford(v);
  ll tmp = -dist[v-1];
  bellman_ford(v);
  if(tmp < -dist[v-1]){
    cout << "inf" << endl;
  }else{
    cout << -dist[v-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>

int result(int input)
{
  for (int i = 1; i <= 9; i++)
  {
    if (input % i == 0 && input / i <= 9)
    {
      return 1;
    }
  }

  return 0;
}

int main()
{
  int a;
  scanf("%d", &a);
  if (result(a) == 1) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}


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

kuro=[]
for i in range(x-n+1,x):
    kuro.append(i)
for i in range(x,n+x):
    kuro.append(i)
for i in range(len(kuro)):
    kuro[i]=str(kuro[i])
kuro=" ".join(kuro)
print(kuro)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k, s;
	std::cin >> n >> k >> s;
	if(s < (int) 1e9) {
		for(int i = 0; i < n; i++) {
			std::cout << (i < k ? s : s + 1) << (i + 1 == n ? '\n' : ' ');
		}
	} else {
		for(int i = 0; i < n; i++) {
			std::cout << (i < k ? s : s - 1) << (i + 1 == n ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 1, N + 1) cin >> A[i];

	rrep(i, N, 1) {
		int other = 0;
		for (int x = i * 2; x <= N; x += i) if (B[x]) other++;
		if (other % 2 != A[i]) B[i] = 1;
	}

	vector<int> ans;
	rep(i, 1, N + 1) if (B[i]) ans.push_back(i);

	int M = ans.size();
	printf("%d\n", M);
	rep(i, 0, M) {
		if(i) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}







Measured memory_bytes: 2936
L = [int(input()) for _ in range(5)]
k = int(input())

import itertools
flag = True
for i in itertools.permutations(range(5), 2):
    if i[0] < i[1]:
        if L[i[1]] - L[i[0]] > k:
            flag = False
if flag:
    print('Yay!')
else:
    print(':(')

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

void b_traveling_atcoder_problem(void) {
	int n;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}


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

Measured memory_bytes: 3564
#include <stdio.h>
int main(void) {
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(m>=b){
		printf("%d\n",0);
	}
	else if(m+f>=b){
		printf("%d\n",b-m);
	}
	else{
		printf("NA\n");
	}
	return 0;
}


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

int n, m, b;
int a[1000], d[1000];
int dp[1001][4096];
const int INF = (1 << 30) - 1;

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

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

		d[i] = 0;

		for (int j = 0; j < b; j++) {
			int c;

			cin >> c;
			d[i] += (1 << (c - 1));
		}
	}

	for(int i = 0; i < m; i++)
		dp[i][0] = 0;

	int w = 1 << n;

	for (int j = 1; j < w; j++)
			dp[0][j] = INF;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j < w; j++) {
			int jd = j - (j & d[i - 1]);
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][jd] + a[i - 1]);
		}
	}

	if (dp[m][w - 1] == INF)
		cout << -1 << endl;
	else
		cout << dp[m][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 16256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);

        System.out.println(arr[arr.length - 1] - arr[0]);
    }
}


Measured memory_bytes: 21844
n, k = map(int, input().split())
a = list(map(int , input().split()))
#ba = []
#for i in range(n):
#    ba.append('{:0=45b}'.format(a[i]))
#print(ba)
#print('{:0=45b}'.format(k))
x = 0
for i in range(k.bit_length()-1, -1, -1):
    cnt = 0
    for j in range(n):
        if a[j] >> i & 1 == 1:
            cnt += 1
    if cnt < (n + 1) // 2:
        t = x + (1 << i)
        if t <= k:
            x = t
ans = 0
for ai in a:
    ans += ai ^ x
print(ans)



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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,m,a;
	cin >> n >> m;
	map<ll,int>mp;
	ll sum = 0LL;
	mp[sum]++;
	ll ans = 0LL;
	for(int i=0; i<n; i++){
		cin >> a;
		(sum += a)%=m;
		ans += mp[sum];
		mp[sum]++;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 4224
import java.util.*;

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

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

        int[][] a = new int[n][m];

        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                a[i][j] = sc.nextInt();
        
        int[] b = new int[m];

        for (int j = 0; j < m; j++)
            b[j] = sc.nextInt();

        int[] c = new int[n];

        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                c[i] += a[i][j]*b[j];

        for (int i = 0; i < n; i++)
            System.out.println(c[i]);
    }
}



Measured memory_bytes: 40940
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N;
long[] A, B;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      B = new long[N];
      foreach (i; 0 .. N) {
        B[i] = readLong();
      }
      
      long ans;
      alias Node = Tuple!(long, "val", int, "pos");
      BinaryHeap!(Array!Node) q;
      auto b = B.dup;
      foreach (i; 0 .. N) {
        if (b[i] > A[i]) {
          q.insert(Node(b[i], i));
        }
      }
      for (; !q.empty; ) {
        const i = q.front.pos;
        q.removeFront;
        const c = b[(i - 1 + N) % N] + b[(i + 1) % N];
        const k = (b[i] - A[i]) / c;
        ans += k;
        b[i] -= c * k;
        if (k > 0) {
          q.insert(Node(b[i], i));
        }
      }
      
      writeln((b == A) ? ans : -1);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 23968
#include<iostream>

int main(void){
    int n,x;
    while(1){
        std::cin>>n>>x;
        if(n==0 && x==0) break;
        int count=0;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x) ++count;
                }
            }
        }
        std::cout<<count<<std::endl;
    }    
    return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <typename T>
struct RMQ {
  using F = function<T(T, T)>;
  T dat[kMax5][20];
  F f;

  RMQ() {}
  RMQ(F f): f(f) {}

  void init(const vector<T> & a) {
    auto n = a.size();
    rep(i, 0, n - 1) { dat[i][0] = a[i]; }
    for (auto j = 1; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = f(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
      }
    }
  }

  T query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    return f(dat[l][k], dat[r - (1 << k) + 1][k]);
  }
};

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n - 1) { cin >> a[i]; }

  auto f = [&](int x, int y) { return __gcd(x, y); };
  RMQ<int> solver(f);
  solver.init(a);
  ll ans = 0;
  rep(i, 0, n - 1) {
    chmax(ans, f(solver.query(0, i - 1), solver.query(i + 1, n - 1)));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8448
N = int(input())
S = {}
for i in range(N):
    j = "".join(sorted(input()))
    if j in S:
        S[j] += 1
    else:
        S[j] = 0

res = 0
for x in S.values():
  for y in range(1,x+1):
    res+=y
print(res)

Measured memory_bytes: 17852
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char letter = sc.next().charAt(0);

        if(letter>='A' && letter <= 'Z'){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }



    }
}

Measured memory_bytes: 35532
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  ans = a[n - 1];
  if(ans == 0) {
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < n - 1; i++) {
    if(a[i] > (double)1e18 / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
    if(ans > (ll)1e18){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) long long(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if (a==1 || b==1){
		cout<<1;
		re 0;
	}
	long long ans=a*b/2;
	if ((a*b)%2==1)  ans++;
	cout<<ans;
	re 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)(n); i++)
#define reps(i,s,e) for(int i=s; i<(int)(e); i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    cin >> N;
    vll As(N);
    rep(i, N) {
        cin >> As[i];
    }
    ll ans = 0;
    rep(i, N) {
        if (i == 0) {
            continue;
        }
        if (As[i] < As[i-1]) {
            ans += As[i-1] - As[i];
            As[i] = As[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <unordered_map>

using namespace std;

typedef long long ll;

ll N,M;
unordered_map<ll,ll> um;
ll a[100000];

int main(){
    cin >> N >> M;
    ll n,m;
    m = 0;
    for(int i=0;i<N;i++){
        cin >> n;
        n += m;
        n %= M;
        a[i] = n;
        m = n;
    }
    ll count = 0;
    um.emplace(0,1);
    for(int i=0;i<N;i++){
        if(um.find(a[i]) == um.end()){
            um[a[i]] = 1;
            continue;
        }
        ll c = um[a[i]];
        count += c;
        um[a[i]] = c+1;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	int n, strk=0, u, v;
	bool ans = 0;
	cin >> n;
	while(n--){
		cin >> u >> v;
		if(u == v) strk++;
		else strk = 0;
		if(strk == 3) ans = 1;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
using namespace std;
using ll = long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;







int main(){
    set<string> s;
    int n;
    cin >> n;
    rep(i,n){
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size();
    

}









Measured memory_bytes: 19204
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(100001,0);
  long long ans = 0;
  rep(i,n) {
    cin >> a[i];
    ans += a[i];
    cnt[a[i]]++;
  }
  int q;
  cin >> q;
  vector<int> b(q);
  vector<int> c(q);
  rep(i,q) cin >> b[i] >> c[i];
  rep(i,q){
    int d = c[i] - b[i];
    ans += d * cnt[b[i]];
    cout << ans << endl;
    cnt[c[i]] += cnt[b[i]];
    cnt[b[i]] = 0;
  }
  return 0;
}


Measured memory_bytes: 4788
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final String input = stdin.nextLine();
	    if ( "0".equals( input ) ){
		break;
	    }

	    final int ans =  solve( input );
	    if ( ans >= 0 ) { 
		System.out.println( ans );
	    } else {
		System.out.println( "NA" );
	    }
	}
    }

    static int solve( final String input ){
	final ArrayList<String> before = new ArrayList<String>();
	before.add( input );
	final ArrayList<String> after = new ArrayList<String>();
	
	final Set<String> visited = new HashSet<String>();

	int count = 0;
	
	while ( !before.isEmpty() ) {
	    for ( final String str : before ) {
		if ( allSame( str ) ) {
		    return count;
		} else {
		    for ( int i = 0; i < str.length() - 1; i++ ) {
			if ( str.charAt( i ) != str.charAt( i + 1 ) ) {
			    final char[] array = str.toCharArray();
			    final char dif = getDiffColor( str.charAt( i ), str.charAt( i + 1 ) );
			    array[ i ] = array[ i + 1 ] = dif;
			    final String next = new String( array );
			    if ( !visited.contains( next ) ){
				after.add( next );
				visited.add( next );
			    }
			}
		    }
		}
	    }
	    before.clear();
	    before.addAll( after );
	    after.clear();		    
	    count++;
	}
	return -1;
    }

    static boolean allSame( final String str ) {
	final char ch = str.charAt( 0 );
	for( final char c : str.toCharArray() ) {
	    if ( c != ch ) {
		return false;
	    }
	}
	return true;
    }

    static char getDiffColor( final char ch1, final char ch2 ) {
	if ( ch1 > ch2 ) {
	    return getDiffColor( ch2, ch1 );
	}

	if ( ch1 == 'b' && ch2 == 'g' ) {
	    return 'r';
	} else if ( ch1 == 'b' && ch2 == 'r' ) {
	    return 'g';
	} else {
	    return 'b';
	}
    }    
}

Measured memory_bytes: 60816
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int n = c.length;
        
        // ans:
        // ???C?AB?C?CBAAB??のような文字列について、
        // ?をA,B,Cに置き換えた全パターンについて、
        // c[i]=A,c[j]=B,c[k]=Cである(i<j<k)のパターン数
        
        // dp[i][j]: i文字目まで見てアルファベットjまで行けてるパターン数
        long[][] dp = new long[n+1][4];
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            char chr = c[i];
            
            // 'A'
            if (chr == 'A' || chr == '?') {
                // 選択する
                dp[i+1][1] += dp[i][0];
                dp[i+1][1] %= MOD;
                // 選択しない
                for (int j = 0; j < 4; j++) {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= MOD;
                }
            }
            
            // 'B'
            if (chr == 'B' || chr == '?') {
                // 選択する
                dp[i+1][2] += dp[i][1];
                dp[i+1][1] %= MOD;
                // 選択しない
                for (int j = 0; j < 4; j++) {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= MOD;
                }
            }
            
            // 'C'
            if (chr == 'C' || chr == '?') {
                // 選択する
                dp[i+1][3] += dp[i][2];
                dp[i+1][3] %= MOD;
                // 選択しない
                for (int j = 0; j < 4; j++) {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= MOD;
                }
            }
        }
        
        System.out.println(dp[n][3]);
    }
}

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


int main(){

    string S,T;
    cin >> S >> T;

    int count =0;

    
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]) count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3820