akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 100005

//struct Node{
//	int val;
//	Node *p, *l, *r;
//};

struct Node {
	int val;
	Node *p, *l, *r;
	Node(int v) :val(v), p(NULL), l(NULL), r(NULL){}
	Node() :val(0), p(NULL), l(NULL), r(NULL){}
};

Node T[N];
int D[N], H[N];

Node *root;

void insert(int k){
	Node *y = NULL;
	Node *x = root;
	Node *z = new Node(k);

	while (x != NULL && x->val != k){
		y = x;
		if (k > x->val) x = x->r;
		else x = x->l;
	}
	z->p = y;
	if (y == NULL) root = z;
	else{
		if (k < y->val) y->l = z;
		else y->r = z;
	}
}

void ino(Node *p){
	if (p == NULL) return;
	ino(p->l);
	printf(" %d", p->val);
	ino(p->r);
}

void preo(Node *p){
	if (p == NULL) return;
	printf(" %d", p->val);
	preo(p->l);
	preo(p->r);
}


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

	int val;
	string com;
	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com[0] == 'i'){
			cin >> val;
			insert(val);
		}
		else if (com[0] == 'p'){
			ino(root); cout << "\n";
			preo(root); cout << "\n";
		}
	}

	return 0;
}

//1 12 17 20 25 30 88
//30 12 1 20 17 25 88

Measured memory_bytes: 29792
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

char buf[100010];
int cnt[26];

int main() {
    memset(buf,0,sizeof(buf));
    memset(cnt,0,sizeof(cnt));
    scanf("%s",buf);
    int n=strlen(buf);
    for (int i=0;i<n;i++) {
        cnt[buf[i]-'a']++;
    }
    vector<int> v;
    for (int i=0;i<26;i++) {
        if (cnt[i]>0) v.pb(cnt[i]);
    }
    sort(v.begin(),v.end());
    if (v.size()==2) {
        printf("Second\n");
    } else if (v.size()==3&&v[0]==1) {
        if (n==3) {
            printf("First\n");
        } else if (n==4) {
            if (buf[0]==buf[3]) printf("First\n");
            else printf("Second\n");
        } else {
            if (v[1]==v[2]) printf("First\n");
            else {
                int len=(buf[0]==buf[n-1])?(n-3):(n-2);
                if (len&1) printf("First\n");
                else printf("Second\n");
            }
        }
    } else {
        int len=(buf[0]==buf[n-1])?(n-3):(n-2);
        if (len&1) printf("First\n");
        else printf("Second\n");
    }
}

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))

typedef long long ll;


int main()
{
    FastRead
	
    string s;
  	
  	cin>>s;
  
  	if(s=="ARC")
      cout<<"ABC";
  	else
      cout<<"ARC";
}

Measured memory_bytes: 3620
mod = 998244353
N, K = map(int,input().split())
S = []
for _ in range(K):
    S.append(list(map(int,input().split())))
L = [1]
SUM = [1]
for i in range(1, N):
    tmp = 0
    for j in range(K):
        if i - S[j][0] >= 0:
            tmp += SUM[i - S[j][0]]
        if i - S[j][1] - 1 >= 0:
            tmp -= SUM[i - S[j][1] - 1]
    L.append(tmp % mod)
    SUM.append((L[-1] + SUM[-1]) % mod)

print(L[-1])

Measured memory_bytes: 24816
word = input()

while True:
    if len(word)<6:
        print('INVALID')
        break
    
    if word.find('0')==-1 and\
       word.find('1')==-1 and\
       word.find('2')==-1 and\
       word.find('3')==-1 and\
       word.find('4')==-1 and\
       word.find('5')==-1 and\
       word.find('6')==-1 and\
       word.find('7')==-1 and\
       word.find('8')==-1 and\
       word.find('9')==-1 :
        print('INVALID')
        break
    
    if word.find('A')==-1 and\
       word.find('B')==-1 and\
       word.find('C')==-1 and\
       word.find('D')==-1 and\
       word.find('E')==-1 and\
       word.find('F')==-1 and\
       word.find('G')==-1 and\
       word.find('H')==-1 and\
       word.find('I')==-1 and\
       word.find('J')==-1 and\
       word.find('K')==-1 and\
       word.find('L')==-1 and\
       word.find('M')==-1 and\
       word.find('N')==-1 and\
       word.find('O')==-1 and\
       word.find('P')==-1 and\
       word.find('Q')==-1 and\
       word.find('R')==-1 and\
       word.find('S')==-1 and\
       word.find('T')==-1 and\
       word.find('U')==-1 and\
       word.find('V')==-1 and\
       word.find('W')==-1 and\
       word.find('X')==-1 and\
       word.find('Y')==-1 and\
       word.find('Z')==-1 :
        print('INVALID')
        break
    
    if word.find('a')==-1 and\
       word.find('b')==-1 and\
       word.find('c')==-1 and\
       word.find('d')==-1 and\
       word.find('e')==-1 and\
       word.find('f')==-1 and\
       word.find('g')==-1 and\
       word.find('h')==-1 and\
       word.find('i')==-1 and\
       word.find('j')==-1 and\
       word.find('k')==-1 and\
       word.find('l')==-1 and\
       word.find('m')==-1 and\
       word.find('n')==-1 and\
       word.find('o')==-1 and\
       word.find('p')==-1 and\
       word.find('q')==-1 and\
       word.find('r')==-1 and\
       word.find('s')==-1 and\
       word.find('t')==-1 and\
       word.find('u')==-1 and\
       word.find('v')==-1 and\
       word.find('w')==-1 and\
       word.find('x')==-1 and\
       word.find('y')==-1 and\
       word.find('z')==-1 :
        print('INVALID')
        break
    
    print('VALID')
    break


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  vector <ll> v(n);
  rep(i, n) {
    cin >> v.at(i);
    sum += v.at(i);
  }
  ll res1 = 0, res2 = 0;
  ll m1 = sum/n, m2 = sum/n+1;
  rep(i, n) {
    res1 += (ll)pow(v.at(i)-m1, 2);
    res2 += (ll)pow(v.at(i)-m2, 2);
  }
  cout << min(res1, res2) << endl;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
data = {}

for s in S:
    count = data.get(s, 0)
    data[s] = count + 1

for s in ['AC', 'WA', 'TLE', 'RE']:
    print(f"{s} x {data.get(s, 0)}")

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

def main():
    N, W = map(int, input().split())
    w = [0]
    v = [0]
    for _ in range(N):
        w_, v_ = map(int, input().split())
        w.append(w_)
        v.append(v_)
    dp = [[0] * (W+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, W+1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[N][W])

if __name__ == '__main__':
    main()

Measured memory_bytes: 118512
import java.util.*;
public class Main
{
  	public static void main(String args[])
    {
      Scanner in=new Scanner(System.in);
      int n,m;
      n=in.nextInt();
      m=in.nextInt();
      if(n==m)
      {
        System.out.println("Yes");
      }
      else
      {
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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

int main() {
	int n, a;
	int ac = 0;
	cin >> n;
	rep(i,n){
		cin >> a;
		if(i % 2 == 0 && a % 2 == 1){
			ac++;
		} 
	}
	cout << ac;
	return 0;
}

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

const long long INF = (long long) 1e18;
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};

struct heap_node {
  long long dist;
  int x, y, dir;
};

inline bool operator>(const heap_node& a, const heap_node& b) {
  return a.dist > b.dist;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--; y1--; x2--; y2--;
  vector<string> board(h);
  for (int i = 0; i < h; i++) {
    cin >> board[i];
  }

  auto to_int = [&](int x, int y, int dir) {
    return dir * h * w + w * x + y;
  };

  vector<long long> dist(4 * h * w, INF);
  priority_queue<heap_node, vector<heap_node>, greater<heap_node> > pq;  
  for (int i = 0; i < 4; i++) {
    pq.push({0, x1, y1, i});
    dist[to_int(x1, y1, i)] = 0;
  }
  while (!pq.empty()) {
    long long d = pq.top().dist;
    int x = pq.top().x, y = pq.top().y, dir = pq.top().dir;
    pq.pop();
    if (d > dist[to_int(x, y, dir)]) {
      continue;
    }
    for (int i = 0; i < 4; i++) {
      if (dir == i) {
        int nx = x + dx[dir], ny = y + dy[dir];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w || board[nx][ny] == '@') {
          continue;
        }
        if (d + 1 < dist[to_int(nx, ny, dir)]) {
          dist[to_int(nx, ny, dir)] = d + 1;
          pq.push({dist[to_int(nx, ny, dir)], nx, ny, dir});
        }
      } else {
        if ((d + k - 1) / k * k < dist[to_int(x, y, i)]) {
          dist[to_int(x, y, i)] = (d + k - 1) / k * k;
          pq.push({dist[to_int(x, y, i)], x, y, i});
        }
      }
    }
  }
  long long ans = INF;
  for (int i = 0; i < 4; i++) {
    if (dist[to_int(x2, y2, i)] != INF) {
      ans = min(ans, (dist[to_int(x2, y2, i)] + k - 1) / k);
    }
  }
  if (ans == INF) {
    cout << -1 << '\n';
    return 0;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 48024
from collections import defaultdict
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parents=[-1]*n
  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]
  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
  def size(self,x):
    return -size.parents[self.find(x)]
  def same(self,x,y):
    return self.find(x)==self.find(y)
  def members(self,x):
    root=self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]
  def roots(self):
    return [i for i,x in enumerate(self.parents) 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,k,l=map(int,input().split())
uf1=UnionFind(n)
for _ in range(k):
  u,v=map(int,input().split())
  uf1.unite(u-1,v-1)
uf2=UnionFind(n)
for _ in range(l):
  u,v=map(int,input().split())
  uf2.unite(u-1,v-1)
d=defaultdict(int)
for i in range(n):
  d[(uf1.find(i),uf2.find(i))]+=1
ans=[d[(uf1.find(i),uf2.find(i))] for i in range(n)]
print(*ans)

Measured memory_bytes: 41696
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

ll n, m, v, p;
int a[100000];

bool isok(int s) {
    ll sum = 0;
    for (int i = n - 1, j = 0; i >= 0; --i) {
        if (i == s)
            continue;
        if (j < p - 1 || i < s) {
            sum += m;
        }
        else {
            if (a[s] + m < a[i])
                return false;
            sum += (a[s] + m - a[i]);
        }
        j++;
    }
    if (sum >= m * (v - 1))
        return true;
    return false;
}

int main() {
    cin >> n >> m >> v >> p;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);

    int l = 0, r = n - 1, mid, ans;
    while (l <= r) {
        mid = (l + r) / 2;
        if (isok(mid)) {
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
            ans = l;
        }
    }
    cout << n - ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

ll C[233];

char ch[200010];

int main() {
    scanf("%s", ch + 1);
    ll n = strlen(ch + 1);
    for(int i = n; i >= 1; i--) C[ch[i]]++;
    ll ans = n * (n - 1) / 2 + 1;
    for(int i = 1; i < 233; i++) ans -= C[i] * (C[i] - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 100010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,m;
int vis[N],num[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();
	vis[1]=1;
	for(register int i=1;i<=n;i++)num[i]=1;
	for(register int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		if(vis[x])
		{
			vis[y]=1;
			if(num[x]==1)vis[x]=0;
		}
		num[x]--;num[y]++;
	}
	int siz=0;
	for(register int i=1;i<=n;i++)if(vis[i]){siz++;}printf("%d\n",siz);
	return 0;
}


Measured memory_bytes: 4504
#include<iostream>
#include<queue>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

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

struct edge{int to; double cost; };
typedef pair<int, int> pii;

ll INF = 10e17;
ll n;
vector<edge> g[1002];
double d[1002];
double x[1002], y[1002], r[1002];

double dis(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

void dijkstra(int s){
    priority_queue<pii, vector<pii>, greater<pii> > que;
    fill(d, d+n+2, INF);
    d[s] = 0;
    que.push(pii(0, 0));

    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        REP(i, g[v].size()){
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    r[0] = 0; r[1] = 0;

    cin >> n;
    REP(i, n){
        cin >> x[i+2] >> y[i+2] >> r[i+2];
    }

    REP(i, n+2){
        REP(j, n+2){
            edge e;
            e.to = j;
            e.cost = max((double)0, dis(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
            g[i].push_back(e);
        }
    }

    dijkstra(0);
    cout << fixed << setprecision(10) << d[1] << endl;
}


Measured memory_bytes: 18584
import sys
input = sys.stdin.readline
from collections import deque
import heapq

def solve(K: int):
    first = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    heapq.heapify(first)
    res = 1
    while K > 0:
        res = heapq.heappop(first)
        if res % 10 != 0:
            heapq.heappush(first, res * 10 + res % 10 - 1)
        heapq.heappush(first, res * 10 + res % 10)
        if res % 10 != 9:
            heapq.heappush(first, res * 10 + res % 10 + 1)
        K -= 1
    return res


def main():
    K = int(input().rstrip())
    res = solve(K)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54980
using System;

public class foo {
    public static void Main() {
        string[] data = Console.ReadLine().Split(' ');
        int a = int.Parse(data[0]),
            b = int.Parse(data[1]);

        if (a < b) {
            Console.WriteLine("a < b");
        } else if (a > b) {
            Console.WriteLine("a > b");
        } else {
            Console.WriteLine("a == b");
        }
    }
}


Measured memory_bytes: 15944
import java.util.*;

public class Main {

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

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

    for (int i = 1; i < n-1; i++) {
      if(p[i-1] < p[i] && p[i] < p[i+1] || p[i-1] > p[i] && p[i] > p[i+1]) count++;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 21972
import sys

def main():
	n = map(int, input())
	monsters = list(map(int, input().split()))
	monsters.sort()
	minimum = sys.maxsize
	while len(monsters) > 1:
		new_monsters = [monsters[0]]
		for i, m in enumerate(monsters):
			if i == 0:
				continue
			new_m = m%monsters[0]
			if new_m != 0:
				new_monsters.append(new_m)
		new_monsters.sort()
		if new_monsters[0] < minimum:
			minimum = new_monsters[0]
		monsters = new_monsters
	print(minimum)


if __name__ == '__main__':
	main()

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i<(n); i++)
using namespace std;
using vec2div = vector<vector<long long>>;
using vec = vector<long long>;
using ll = long long;


int main(){
	ll x,y;
	cin >> x >> y;
	ll i,j,kame,turu,sum;
	ll b=0;
	for(i=0;i<=x;i++){
		kame=i;
		turu=x-i;
		sum = 4*kame + 2*turu;
		if(sum == y){
			cout << "Yes" << endl;
			b = 1;
			break;
		}
	}
	if(b==0)cout << "No" << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    
    int T,D,L;
    while(cin >> T >> D >> L,T){
        vector<int> x(T); for(auto& in:x) cin >> in;
        
        int ans = 0;
        int nure = -1;
        for(int i = 0; i < T; i++){
            if(nure >= i) ans++;
            if(x[i] >= L){
                nure = i+D;
            }
        }
        cout << ans << endl;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

signed main(void) {
  int A, B;
  cin >> A >> B;
  if (A <= 9 && B <= 9) {
    cout << A*B << endl;
  } else {
    cout << -1 << endl;
  }
}


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

int keta(int n) {
	int i = 1;
	while (n / 10 > 0) {
		i++;
		n /= 10;
	}
	return i;
}

int S(int n) {
	int i;
	int sum = 0;
	for (i = 0;i < keta(n);i++) {
		sum += (n / (int)pow((double)10, (double)i)) % 10;
	}
	return sum;
}

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


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

int N;
int ans=0;

int main(){
    cin>>N;
    int cnt=0;
    for(int i=0; i<N; i++){
        char c;
        cin>>c;
        if(c=='I')cnt++;
        else cnt--;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 202
#define HMAX 202
#define INF (int)1e9

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

struct edge{
  int to,cost;
};

int A[HMAX][WMAX],B,C[10][10],D,N,W,H,ans = 0,L[10] = {};
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};


void solve(){
	Fill(L,INF);
	L[1] = 0;
	for (int k = 0; k < 10; ++k)
	{
		for (int i = 0; i < 10; ++i)
		{
			for (int j = 0; j < 10; ++j)
			{
				if(C[i][j] > C[i][k] + C[k][j]) C[i][j] = C[i][k] + C[k][j];
			}
		}
	}
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if(A[i][j] != -1){
				ans += C[A[i][j]][1];
			}
		}
	}
}

void debug(){

}

void answer(){
	// for (int i = 0; i < 10; ++i)
	// {
	// 	cout << L[i] << " ";
	// }
	// cout << "\n";
	cout << ans << "\n";
}

int main(){
	cin >> H >> W;
	for (int i = 0; i < 10; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			cin >> C[i][j];
		}
	}
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> A[i][j];
		}
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 384
import math

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0

for i in reversed(range(n)):
	if a[i+1] - b[i] <= 0:
		ans += a[i+1]
		b[i] -= a[i+1]
		a[i+1] = 0
		if a[i] - b[i] <= 0:
			ans += a[i]
			b[i] -= a[i]
			a[i] = 0
		else:
			ans += b[i]
			a[i] -= b[i]
			b[i] = 0
	else:
		ans += b[i]
		a[i+1] -= b[i]
		b[i] = 0

print(ans)

Measured memory_bytes: 19244
fn input_line() -> Vec<String> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  return buf
    .split_whitespace()
    .map(|word| String::from(word))
    .collect();
}

fn main() {
  let inputs = input_line();
  let x: i64 = inputs[0].parse().unwrap();
  let ans = if x < 600 {
    8
  } else if x < 800 {
    7
  } else if x < 1000 {
    6
  } else if x < 1200 {
    5
  } else if x < 1400 {
    4
  } else if x < 1600 {
    3
  } else if x < 1800 {
    2
  } else {
    1
  };
  println!("{}", ans);
}

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

int insertionSort(int *A, int n, int g) {
  int i, j, v;
  int cnt = 0;

  for(i = g; i < n; i++) {
    v = A[i];
    j = i-g;
    while(j >=0 && A[j] > v) {
      A[j+g] = A[j];
      j = j-g;
      cnt++;
    }
    A[j+g] = v;
  }
  return cnt;
}

int shellSort(int *A, int n, int m, int *G) {
  int i;
  int cnt = 0;

  for(i = 0; i < m; i++) {
    cnt += insertionSort(A, n, G[i]);
  }
  return cnt;
}

int main() {
  int n, m, i;
  int cnt = 0;
  int *A;
  int G[100], *H;

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

  G[0] = 1;
  for(i = 1; i < 100; i++) {
    G[i] = 3*G[i-1]+1;
  }

  m = 1;
  while(G[m] < n && m < 100) {
    m++;
  }

  H = malloc(m*sizeof(int));
  for(i = m; i >= 0; i--) {
    H[m-i] = G[i-1];
  }

  cnt = shellSort(A, n, m, H);

  printf("%d\n", m);
  for(i = 0; i < m; i++) {
    printf("%d", H[i]);
    if(i != m-1) {
      printf(" ");
    }
  }
  printf("\n");

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

  for(i = 0; i < n; i++) {
    printf("%d\n", A[i]);
  }

  return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <vector>
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];

    bool can = true;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (s[i][j] == '#') {
                can = false;
                for (int dy=-1; dy<2; ++dy) {
                    for (int dx=-1; dx<2; ++dx) {
                        if ((i+dy>=0) && (i+dy<H) &&
                            (j+dx>=0) && (j+dx<W) &&
                            (dx+dy!=0) && (dx+dy!=2) && (dx+dy!=-2)) {
                                if (s[i+dy][j+dx] == '#') {
                                    can = true;
                                }
                            }
                    }
                }
            }
            if (! can) break;
        }
        if (! can) break;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s, t;
  cin >> s >> t;

  REP(i, s.size()){
    if(i < t.size()) cout << s[i] << t[i];
    else cout << s[i];
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a, b[4]{};
	cin >> a;
	for (int i = 3; i >= 0; i--) {
		b[i] = a % 10;
		a /= 10;
	}
	for (int i = (1 << 3) - 1; i >= 0; i--) {
		int sum = b[0];
		for(int j=0;j<3;j++){
			if (i & 1 << j)sum += b[j + 1];
			else sum -= b[j + 1];
		}
		if (sum == 7) {
			cout << b[0] << (i & 1 ? "+" : "-") << b[1] << (i & 2 ? "+" : "-") << b[2] << (i & 4 ? "+" : "-") << b[3] << "=7" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
cd = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    ans = []
    for j in range(M):
        ans.append(abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]))
    minans = min(ans)
    print(ans.index(minans)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n-1) {
    string x = s.substr(0, i+1);
    string y = s.substr(i+1);
    vector<int> a(26), b(26);
    rep(j,x.size()) {
      a[x[j] - 'a']++;
    }
    rep(j,y.size()) {
      b[y[j] - 'a']++;
    }
    int temp = 0;
    rep(i,26) {
      if (a[i] && b[i]) temp++;
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
}

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

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

int n,b[2][100100],f[2][100100],maxi,num;
bool v[100100];

int dfs(int s, int now){
  v[now] = true;
  
  for(int i=0;i<2;i++){
    if(!v[b[i][now]]){
      if(maxi == f[i][now])num++;
      else if(maxi < f[i][now]){
	maxi = f[i][now];
	num = 1;
      }
      return dfs(s,b[i][now]);
    }
  }
  if(maxi == f[1][s])return num+1;
  else if(maxi < f[1][s])return 1;
  else return num;
}

int main(){
  while(scanf("%d",&n),n){
    for(int i=0;i<n;i++){
      scanf("%d%d%d%d",&b[0][i],&f[0][i],&b[1][i],&f[1][i]);
      v[i] = false;
    }

    int ans = 1;
    for(int i=0;i<n;i++){
      if(!v[i]){
	v[i] = true;
	maxi = f[0][i]; num = 1;
	ans = (ans * dfs(i,b[0][i]) ) % 10007;
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include<set>
#include<vector>
using namespace std;

int main(void)
{
  int N;
  cin >> N;

  set<string> S;
  string tmp;
  vector<string> ans;
  for (int i = 0; i < N; i++)
  {
    cin >> tmp;
    if(tmp=="insert"){
      string cap;
      cin >> cap;
      S.insert(cap);
    }else{
      string cap;
      cin >> cap;
      if(S.count(cap)){
        ans.push_back("yes");
      }
      else
      {
        ans.push_back("no");
      }
    }
  }

  for (int i = 0; i < ans.size();i++){
    cout << ans.at(i) << endl;
  }

  return 0;

}


Measured memory_bytes: 55344
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,i,j,k,s;
    scanf("%d%d",&n,&k);
    s=1;
    for(i=1;i<=n;i++)
    {
        if(s<k)
        s=s*2;
        else
        s=s+k;
    }
    printf("%d\n",s);
    return 0;
}


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

using namespace std ;
using ll = long long;
using p = pair <int , int >;
using V = vector <int> ;
using S = vector <string>;


int main (){
	int k ,count = 0 ;
	int a,b;
	cin >> k;
	cin >> a >> b ;
	if (k >= 1 && (a >= 1 && b >= a)){
		for (int i = a ; i <= b ; i++){
		if (i % k == 0 ){count +=1;}
		} 
		if (count >0 ){cout << "OK"<< endl;}
		else {cout << "NG"<< endl;}
	}
	return 0 ;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    int a,x=0;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    sort(b,b+a,greater<int>());
    for(int i=0;i<a;i++){
        if(i%2==0){
            x+=b[i];
        }else{
            x=x-b[i];
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem069c(n, a))
}
 
fun problem069c(n: Int, a: List<Long>): String {
    val fours = a.filter { it % 4 == 0L }
    val twos = a.filter { it % 4 == 2L }
    val ones = a.filter { it % 2 == 1L }
    return if (ones.size <= fours.size || twos.isEmpty() && ones.size == fours.size + 1) "Yes" else "No"
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1 ; i <= n ; i++)
    {
        int ta;
        cin >> ta;
        if (i & 1)
            ans += (ta & 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
a=str(input())
count=0
ans=0
for i in range(len(a)):
    if a[i]== 'A' or a[i]== 'C' or a[i]== 'G' or a[i]== 'T' :
        count+=1
    else:
        ans=max(ans,count)
        count=0
ans=max(ans,count)  
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

template <typename Monoid> struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

  private:
    int n;
    vector<Monoid> node;
    Monoid E;
    F f;

  public:
    SegmentTree(vector<Monoid> &v, Monoid e, const F func) : f(func), E(e) {
        int sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, E);
        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, Monoid val) {
        i += (n - 1);
        node[i] = val;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    Monoid query(int a, int b, int i = 0, int l = 0, int r = -1) {
        if(r < 0) {
            r = n;
        }
        if(r <= a || b <= l) {
            return E;
        }
        if(a <= l && r <= b) {
            return node[i];
        }
        Monoid vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
        return f(vl, vr);
    }

    Monoid operator[](const int &i) const { return node[i + n - 1]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> LR(n);
    for(int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        LR[i] = P(l, r + 1);
    }
    sort(ALL(LR));
    vector<int> lmax(n), rmin(n);
    SegmentTree<int> Lmax(lmax, -INF, [](int a, int b) { return max(a, b); });
    SegmentTree<int> Rmin(rmin, INF, [](int a, int b) { return min(a, b); });
    for(int i = 0; i < n; i++) {
        Lmax.update(i, LR[i].first);
        Rmin.update(i, LR[i].second);
    }

    int ans = 0;
    // 集合1に含まれるもののうち、最も大きい番号をxとする
    for(int x = 0; x < n - 1; x++) {
        int l1 = LR[x].first;
        int r1 = Rmin.query(0, x + 1);
        int l2 = LR[n - 1].first;
        int r2 = Rmin.query(x + 1, n);
        chmax(ans, max((r1 - l1), 0) + max((r2 - l2), 0));
    }
    for(int x = 0; x < n - 1; x++) {
        int l1 = LR[x].first;
        int r1 = LR[x].second;
        int l2 = max(Lmax.query(0, x + 1), Lmax.query(x + 1, n));
        int r2 = min(Rmin.query(0, x + 1), Rmin.query(x + 1, n));
        chmax(ans, max(r1 - l1, 0) + max(r2 - l2, 0));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
long mod=1e9+7,dp[1<<21];
int n,a[21][21],I;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
	dp[0]=1;
	for(I=0;I<1<<n;I++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[__builtin_popcount(I)][j]&&!(I&1<<j))dp[I|1<<j]=(dp[I]+dp[I|1<<j])%mod;
		}
	}
	cout<<dp[I-1]<<endl;
}


Measured memory_bytes: 16640
n=int(input())
a=[int(i) for i in input().split()]
amax=max(a)
m=len( bin(amax)[2:] )
bin_a = [bin(aa)[2:].zfill(m) for aa in a]

ans=0
mod=10**9+7
for i in range(m):
    sum0 = sum( bi[-1-i]=="0" for bi in bin_a )
    sum1 = n-sum0
    ans += sum0*sum1*2**i % mod
print(ans%mod)


Measured memory_bytes: 127944
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<map>
#include<queue>
#include<iostream>
#include<cmath>
//#define int long long 
using namespace std;
inline int gi(){char tmp=getchar();int flag=1;while(tmp<'0'||tmp>'9'){if(tmp=='-'){flag=-1;tmp=getchar();break;}tmp=getchar();}int ans=0;while(tmp<='9' and tmp>='0') {ans=ans*10+tmp-'0';tmp=getchar();}return ans*flag;}
inline void write(int x){static int stk[100], top = 0;if (x == 0) { putchar('0'); putchar(' ');return; }if (x < 0) { x = -x; putchar('-'); }while (x) { stk[++top] = x % 10; x /= 10; }while (top) { putchar(stk[top--] + '0'); }putchar(' ');}
#define line() putchar('\n');
#define Mem(Arr,V) memset(Arr,V,sizeof Arr);
#define Mcpy(Arr,qwq) memcpy(Arr,qwq,sizeof qwq);
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max4(max3(a,b,c),d);
#define in(a) a=gi()
#define in2(a,b) in(a),in(b)
#define in3(a,b,c) in2(a,b),in(c)
#define in4(a,b,c,d) in3(a,b,c),in(d)
#define write2(a,b) write(a),write(b)
#define write3(a,b,c) write2(a,b),write(c)
#define write4(a,b,c,d) write3(a,b,c),write(d)
#define smin(a,b) a=min(a,b)
#define smax(a,b) a=max(a,b)
int Single[1002001];
signed main()
{
	int n,k,m;
	in3(n,k,m);
	for(int i=1;i<=m;++i)
	{
		int tmp=gi();
		Single[tmp]++;
	}
	for(int i=1;i<=n;++i)
	{
		if(Single[i]+k-m<=0)
			puts("No");
		else
			puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

def check(num1,num2):
    return (num1+num2) == (num1^num2)

ans=0
l,r=0,0
now=0
while l < len(a):
    while r < len(a) and check(now,a[r]):
        now+=a[r]
        r+=1

    ans+=r-l
    if l==r:
        r+=1
    else:
        now-=a[l]
    l+=1
print(ans)

Measured memory_bytes: 77900
S = input()
flg = True
if len(S)%2 == 1:
  print('No')
else:
  for i in range(0, len(S), 2):
    if S[i:i+2] != 'hi':
      print('No')
      flg = False
      break
  if flg:
    print('Yes')
  


Measured memory_bytes: 2940
def main(n,a):
    for i in range(len(a)):
        if a[i] % 2 != 0:
            continue
        else:
            if (a[i] % 3 == 0) or (a[i] % 5 == 0):
                continue
        return False
    return True

n = int(input())
a = list(map(int, input().split()))
print("APPROVED" if main(n,a) else "DENIED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 2e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();ans.resize(n);
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    for (int i = 0; i < n; i++) {
        ans[i]=0;
    }
}


void solve(){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    
    
}

int main(){
   
   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
        
        
    return 0;
}

Measured memory_bytes: 12988
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll A,B,ans;
long long self_xor(long long  val) {
	long long ret=((val+1)/2)%2;
	for (int i=0;i<=59;i++) if ((val>>i)%2)ret|=(1^(val%2))<<i;
	return ret;
}
 
int main() {
	cin>>A>>B;
	ans=self_xor(B);
	if (A>0) ans^=self_xor(A-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
S= list(stdin.readline().strip())
N=len(S)
left=0
right=N-1
midle_right=(N-2)//2
midle_left=(N+2)//2
while(right!=left):
    if S[left]!=S[right]:
        print("No")
        exit()
    if S[left]!=S[midle_right]:
        print("No")
        exit()
    if S[right]!=S[midle_right]:
        print("No")
        exit()
    midle_right-=1
    midle_left+=1
    if right==midle_right:
        midle_right=right-1
    if left==midle_left:
        midle_left=left+1
    left += 1
    right -= 1
print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=3e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

struct node
{
    ll x;
    ll y;
    double dis;
}a[maxn];

int main()
{
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].dis=sqrt(a[i].x*a[i].x+a[i].y*a[i].y);
        if(a[i].dis<=d) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8404
a,b,c=map(int,input().split())

if b-a+1>2*c:
	x=[i for i in range(a,a+c)]
	y=[i for i in range(b-c+1,b+1)]
	e=x+y
else:
	e=[i for i in range(a,b+1)]
#print(e)
for i in e:
	print(i)


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

int m;
int sx[200], sy[200];
int n;
int hx[1000], hy[1000];

int find(int tx, int ty) {
	for (int i = 0; i < m; i++) {
		bool flag = false;
		for (int j = 0; j < n; j++) {
			if (sx[i] + tx == hx[j] && sy[i] + ty == hy[j]) {
				flag = true;
				break;
			}
		}
		if (!flag) return false;
	}
	return true;
}

int main() {
	while (cin >> m) {
		if (!m) return 0;
		for (int i = 0; i < m; i++) cin >> sx[i] >> sy[i];
		cin >> n;
		for (int i = 0; i < n; i++) cin >> hx[i] >> hy[i];
		
		for (int i = 0; i < n; i++) {
			int tx = hx[i] - sx[0];
			int ty = hy[i] - sy[0];
			if (find(tx, ty)) {
				cout << tx << " " << ty << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3088
from collections import Counter

a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+1)]
cc = [0 for i in range(pow(10,5)+1)]
for i in range(len(b)):
    if i % 2 == 0:
        c[b[i]] += 1
    else:
        cc[b[i]] += 1
first = Counter(b[::2]).most_common(2) + [(0, 0)]
latter = Counter(b[1::2]).most_common(2) + [(0, 0)]
one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(d+1):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    elif onee <= c[i]:
        onee = c[i]
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i
    elif twoo <= cc[i]:
        twoo = cc[i]
t = max(one+twoo,onee+two)

if k != kk:
    print(a-one-two)
else:
    print(a-t)

Measured memory_bytes: 17116
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
	//cout<<f(w,n);
	
}


Measured memory_bytes: 3596
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int maX = 1e5+10;
ll dp[3005][3005];
int main(){
  ll a,b,c,d;
  sffff(a,b,c,d);
  cout<<max({a*c,b*d,a*d,b*c})<<endl;
return 0;
}
//4 3
//7 -1 3
//8 2 5
//3 -1 9
//1 7 4


Measured memory_bytes: 3684