akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
    cin>>a;
    if(a%2==1){cout<<a*2<<endl;}
    else{cout<<a<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);}
#define ll long long int
#define vi vector<ll>
#define vpii vector<pair<ll,ll>>
#define mp make_pair
#define pb emplace_back
#define INF 1000000000000
#define mi map<int>
#define mii unordered_map<ll,ll>
#define line '\n'
#define F first
#define S second
 
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
	if (n & 1)
	  res = (res * x) % mod;
	x = (x * x) % mod;
	n >>= 1;
  }
  return res;
  }
  
  const int N=1e5;
  int parent[N];
  int find_parent(int node)
  {
    if(parent[node]<0)
       return node;

    return parent[node]= find_parent(parent[node]);
  }
   


  void join_them(int x,int y)
  {
    int k1=find_parent(x);
    int k2=find_parent(y);

   if(k1!=k2)
   {
      parent[k1]+=parent[k2];
      parent[k2]=k1;
   }
   else
     return;
  }
  int main()
  {
    //okay This is #665 Div 2 ..i learned how to solve this using DSU 
    //to solve it with DSU we want all to be in a single connected 
    //component and later we will simply check if they belong to same parent or not
    FIO;
    string s="";
    cin>>s;
    ll digitsum=0;
    for(int i=0;i<s.length();i++)
    {
        digitsum+= (s[i] - '0');
    }

    if(digitsum % 9 ==0)
      cout<<"Yes";
    else
      cout<<"No";


  }

Measured memory_bytes: 3780
#include<stdio.h>

int main()
{
    int judge(int);
	int a[100100];
	int i;
	int k=0;
	for(i=3;i<=110000;i+=2)
    {
        if(judge(i)&&judge((i+1)/2))
        {
            a[k]=i;
            k++;
        }
    }

	int t,m,n,j;
	scanf("%d",&t);
	while(t--)
    {
        int sum=0;
        scanf("%d%d",&m,&n);
        for(j=0;a[j]<=n;j++)
        {
            if(a[j]>=m)
            {
                sum++;
            }
        }
        printf("%d\n",sum);
    }
	return 0;
}
int judge(int x)
{
    int i;
    for(i=2;i*i<=x;i++)
        if(x%i==0) return 0;
    return 1;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>

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

using namespace std;

int main()
{
    string c[2];
    rep(i, 2){
        cin >> c[i];
    }

    rep(i, 3){
        char tmp = c[0][0];
        c[0][0] = c[0][2];
        c[0][2] = tmp;
    }

    if(c[0].compare(c[1]) == 0){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    cout << endl;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

const int maxH = 510;

int n, H;

int fa[maxH + 5];

int deg[maxH + 5];

bool vis[maxH + 5];

int get(int x) { return fa[x] == x ? x : fa[x] = get(fa[x]); }

inline void adde(int C, int D)
{
	vis[C] = vis[D] = 1;
	++deg[C];
	--deg[D];
	fa[get(C)] = get(D);
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &H);
	++H;
	REP(i, 0, H << 1) fa[i] = i;
	REP(i, 0, n)
	{
		int A, B, C, D;
		scanf("%d%d%d%d", &A, &B, &C, &D);
		int x = -1, y = -1;
		if (!C) x = A << 1;
		else x = C << 1 | 1;
		if (!D) y = B << 1 | 1;
		else y = D << 1; 
		adde(x, y);
	}
	bool failed = 0;
	REP(i, 0, H << 1) if (vis[i])
	{
		int sum = 0;
		int abssum = 0;
		REP(j, 0, H << 1) if (get(j) == get(i))
		{
			vis[j] = 0;
			sum += deg[j];
			abssum += abs(deg[j]);
			if (deg[j] > 0)
			{
				if (j & 1) { failed = 1; break; }
			}
			if (deg[j] < 0)
			{
				if (!(j & 1)) { failed = 1; break; }
			}
		}
		if (sum || !abssum) { failed = 1; break; }
	}
	puts(failed ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 256
import math

nd = list(map(int,input().split(" ")))
n = nd[0]
d = nd[1]
cnt = 0


xy=[]
for i in range(n):
    xy.append(list(map(int,input().split(" "))))
    result = math.sqrt((xy[i][0]**2)+(xy[i][1]**2))
    if result <= d:
        cnt += 1

print(cnt)

Measured memory_bytes: 45396
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int k=Integer.parseInt(sc.next());
//String s=sc.next();
//int[] a=new int[n];
//for(int i=0;i<n;i++){}
int ans;
if(n%k==0){ans=0;}else{ans=1;}
System.out.println(ans);
}}


Measured memory_bytes: 21844
n, m = map(int, input().split())
mat = [[0] * n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    mat[a][b] += 1
    mat[b][a] += 1
for i in range(n):
    print(sum(mat[i]))


Measured memory_bytes: 38512
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
char buf[20000];sz;
inline int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001],d2[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		int A=rd();
		for(int j=0;j<=S-A;j++)d2[j]=d[j+A];
		for(int j=0;j<=S-A;j++)
		{
			d[j]+=d2[j];
			d[j]-=mod*(d[j]>=mod);
		}
		ans+=d[0];
		ans-=mod*(ans>=mod);
	}
	printf("%d",ans);
}

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

using namespace std;

int main(){
 int i,j,N,temp,c=0,minj;
 cin >> N;
 int A[N];
 for (j=0;j<N;++j){
   cin >> A[j];
 }
 for (i=0;i<N;++i) {
   minj=i;
   for (j=i;j<N;++j) {
     if (A[j] < A[minj]) {
       minj=j;
     }
   }
   temp=A[i];
   A[i]=A[minj];
   A[minj]=temp;
   if (i!=minj) c++;
 }
 for (j=0;j<N;++j){
   cout << A[j];
   if (j<N-1) {
     cout << " ";
   } else {
     cout << endl;
   }
 }
 cout << c << endl;
 return 0;
}



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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

const char* table="#.";

int main(){
	int n=read();
	string u,b;
	while(1){
		bool found=false;
		REP(i,2)REP(j,2){
			string p=u+table[i],q=b+table[j];
			cout<<p<<endl<<q<<endl;
			string res;
			cin>>res;
			if(res=="end")
				return 0;
			if(res=="T"){
				u+=table[i];
				b+=table[j];
				found=true;
				goto END;
			}
		}
		END:;
		if(!found)
			break;
	}
	while(1){
		bool found=false;
		REP(i,2)REP(j,2){
			string p=string()+table[i]+u,q=string()+table[j]+b;
			cout<<p<<endl<<q<<endl;
			string res;
			cin>>res;
			if(res=="end")
				return 0;
			if(res=="T"){
				u=string()+table[i]+u;
				b=string()+table[j]+b;
				found=true;
				goto END2;
			}
		}
		END2:;
		if(!found)
			break;
	}
	return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
  bool operator==(const mint rhs) const { return x == rhs.x; }
  bool operator!=(const mint rhs) const { return x != rhs.x; }
  bool operator<(const mint &a) const{ return x<a.x;};
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


void f(vector<mint> &a) {
  int n = a.size();
  for (int k = 1; k < n; ++k) {
    for (int i = k * 2; i < n; i += k) {
      a[k] += a[i];
    }
  }
}

void inv_f(vector<mint> &a) {
  int n = a.size();
  for (int k = n - 1; k >= 1; --k) {
    for (int i = k * 2; i < n; i += k) {
      a[k] -= a[i];
    }
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, k;
  cin >> n >> k;
  vector<mint> a(k+1,1);
  a[0] = 0;
  f(a);
  for (int i = 1; i <= k; ++i) {
    a[i] = a[i].pow(n);
  }
  inv_f(a);
  mint ans = 0;
  for (int i = 1; i <= k; ++i) {
    ans += a[i]*i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, X, M = map(int, readline().split())
ans = X
x = X
data = [0]*M
data[x] = 0
t = [x]
for i in range(1,N):
    nx = x ** 2 % M     
    if nx == 0:
        break
    if data[nx] != 0:
        res = N-i
        s = i-data[nx]
        syuki_cnt = res // s
        rem_cnt = res % s
        nt = t[data[nx]:i]
        ans += sum(nt)*syuki_cnt+sum(nt[:rem_cnt])
        break
    ans += nx
    x = nx
    data[nx] = i
    t.append(nx)
print(ans)

Measured memory_bytes: 69732
S = input()
N = len(S)
num1 = int((N-1)/2)
num2 = int((N+3)/2)
mae = S[:num1]
ushiro = S[num2-1:]
if mae == mae[::-1] and ushiro == ushiro[::-1] and S == S[::-1]:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> as(n);
    for (long long& a : as) {
        cin >> a;
    }
    vector<long long> xs(n, 0LL);
    for (int i = 0; i < n; ++i) {
        xs[0] += i % 2 == 0 ? as[i] : -as[i];
    }
    xs[0] /= 2;
    for (int i = 0; i < n-1; ++i) {
        // xs[i] + xs[i+1] == a[i]
        xs[i+1] = as[i] - xs[i];
    }
    for (int x : xs) {
        cout << 2*x << " ";
    }
    cout << endl;
    return 0;
}



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

struct Node{
    int townNum, fare, ticketNum;
    bool operator<(const Node &obj)const{
        if(fare != obj.fare)return fare > obj.fare;
        return false;
    }
};

int mini[100][11];

int main(){
    while(1){
        int c,n,m,s,d;
        scanf("%d %d %d %d %d",&c,&n,&m,&s,&d);
        if(c == 0 && n == 0 && m == 0 && s == 0 && d == 0)break;
        vector< vector<Node> > graph;
        graph.resize(n+1);

        for(int i=0;i<m;++i){
            int a,b,f;
            scanf("%d %d %d",&a,&b,&f);
            graph[a].push_back((Node){b,f,0});
            graph[b].push_back((Node){a,f,0});
        }

        for(int i=0;i<n;++i){
            for(int j=0;j<=c;++j){
                mini[i][j] = INT_MAX;
            }
        }
        mini[s-1][c] = 0;

        priority_queue<Node> Q;
        Q.push((Node){s,0,c});
        while(!Q.empty()){
            Node now = Q.top();
            Q.pop();
            if(now.townNum == d){
                cout << now.fare << endl;
                break;
            }
            for(int i=0;i<graph[now.townNum].size();++i){
                Node nextTown = graph[now.townNum][i];
                int newfare=now.fare+nextTown.fare;
                if(newfare < mini[nextTown.townNum-1][now.ticketNum]){
                    Q.push((Node){nextTown.townNum,newfare,now.ticketNum});
                    mini[nextTown.townNum-1][now.ticketNum] = newfare;
                }
                if(now.ticketNum > 0){
                    newfare = now.fare + nextTown.fare / 2;
                    if(newfare < mini[nextTown.townNum-1][now.ticketNum-1]){
                        Q.push((Node){nextTown.townNum,newfare,now.ticketNum-1});
                        mini[nextTown.townNum-1][now.ticketNum-1] = newfare;
                    }
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
const int m = 998244353;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	fr(i,n)cin>>a[i];
	vector<bool> dp(k+1);
	for(int stones = 0;stones<=k;++stones){
		  for(auto x:a){
		  	if(stones>=x && !dp[stones-x]){
		  		 dp[stones] = true;
			  }
		  }
	}
	puts(dp[k] ? "First" : "Second");
}

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

int main() {
        int N,M,X;
        int A[110];
        int low=0,high=0;

        cin >> N >> M >> X;

        for(int i=0; i<M; i++){
                cin >> A[i];
                if(A[i]<X)low++;
                else high++;
        }
        cout << min(low, high) <<endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		for (int i = 0; i < N; i++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 52528
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, m = map(int, raw_input().split())
            if n == 0 and m == 0:
                break
            vegi = map(int, raw_input().split())
            vegi.sort(reverse=True)
            ans = 0
            for i in range(len(vegi)):
                if i % m != m - 1:
                    ans += vegi[i]
            print ans
                    
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = 10000000;
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> subject(m);
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                sum += c[i];
            }
            else continue;
            for (int j = 0; j< m; j++) {
                 subject[j] += a[i][j];
            }
        }
        if (sum == 0) continue;
        int i = 0;
        for (i = 0; i < m; i++) {
            //printf("subject[%d] = %d\n", i, subject[i]);
            if (subject[i] <x) break;
        }
        if (i == m) {
            //printf("sum=%d ", sum);
            ans = min(ans, sum);
            //printf("ans=%d\n", ans);
        }
    }
    if (ans == 10000000) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	ll ans=0;
	rep(i,0,n-1){
		if(s[i]==s[i+1]){
			ans++;
			if(s[i+1]=='0')s[i+1]='1';
			else s[i+1]='0';
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3720
x, y = map(int, input().split())
ans = 0
if y <= 0:
    if x < y:
        ans = y - x
    elif y < x < 0:
        ans = 1 + (-y + x) + 1
    elif 0 <= x <= -y:
        ans = (-y - x) + 1
    else:
        ans = 1 + (y + x)
else:
    if y < x:
        ans = 1 + (-y + x) + 1
    elif 0 <= x < y:
        ans = y - x
    elif -y <= x < 0:
        ans = 1 + (y + x)
    else:
        ans = (-y - x) + 1
print(ans)

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << !(n % k == 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
using namespace __gnu_pbds;
 
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define pb push_back
#define ll long long
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main() {
    fast_io();
    int count[3] = {0};
    int n; cin >> n;
    ll ans = 1, mod = 1e9 + 7;
    for (int i = 0; i < n; ++i){
        int a; cin >> a;
        int possible = 0;
        for (int j = 0; j < 3; ++j){
            if (count[j] == a)
                ++possible;
        }
        ans = (ans * possible)%mod;
        if (possible == 0) {
            cout << 0 << endl;
            return 0;
        }
        for (int j = 0; j < 3; ++j){
            if (count[j] == a){
                ++count[j];
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ DPL_2_B Chinese Postman Problem
// 2018.5.12 bal4u
  
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
  
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF  0x10101010

int V;
int dist[17][17];
int hi[17], to[17][1005], d[17][1005]; 
int dp[1<<17];

int chinesePostman(int sum)
{
	int i, j, k, S, t, s, lim;
	int odd[17], sz;

	sz = 0;
	for (i = 0; i < V; i++) {
		if (hi[i] & 1) odd[sz++] = i;
	}

	for (k = 0; k < V; k++) {
		for (i = 0; i < V; i++) if (dist[i][k] < INF) {
			for (j = 0; j < V; ++j) if (dist[k][j] < INF) {
				t = dist[i][k] + dist[k][j];
				if (t < dist[i][j]) dist[i][j] = t;
			}
		}
	}

	memset(dp, INF, sizeof(dp));
	dp[0] = 0, lim = (1<<sz)-1;
	for (S = 0; S <= lim; S++) {
		for (i = 0; i < sz; i++) if ((~S >> i) & 1) {
			for (j = 0; j < i; j++) if ((~S >> j) & 1) {
				t = dp[S] + dist[odd[i]][odd[j]];
				s = S | (1<<i) | (1<<j);
				if (t < dp[s]) dp[s] = t;
			}
		}
	}
	return sum + dp[lim];
}
 
int main()
{
	int k, E, s, t, a, sum;
 
	memset(dist, INF, sizeof(dist));
	V = in(), E = in();
	sum = 0;
	while (E--) {
		s = in(), t = in(), a = in();
		sum += a;
		if (a < dist[s][t]) dist[s][t] = dist[t][s] = a;
		k = hi[s]++, to[s][k] = t, d[s][k] = a;
		k = hi[t]++, to[t][k] = s, d[t][k] = a;
	}
	printf("%d\n", chinesePostman(sum));
	return 0;
}



Measured memory_bytes: 2456
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        if(U.equalsIgnoreCase(S))
            A--;
        else
            B--;
        System.out.println(A+" "+B);
        }
    }

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define INF 1000000000
#define EPS 1.0e-6

using namespace std;

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

int n, a, b;
int h[105000];


ll f(ll x,ll y)
{
	if (x%y == 0)return x / y;
	else return x / y + 1;
}


ll binary_s(ll k)
{
	ll low = 0, high = k;
	while (high-low>1) {
		//cout << "a" << endl;
		ll mid = (low + high) / 2;

		//cout << low << " " << mid << " " << high << endl;
		ll sum = 0;
		for (int i = 0; i < n; i++) {
			if (h[i] - b*mid > 0)sum += f(h[i] - b * mid, (a - b));
		}
		//cout << "sum" << sum << " mid:" << mid << endl;
		if (sum > mid) {
			low = mid;
		}
		else {
			high = mid;
		}
	}
	return high;
}

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

		for (int i = 0; i < n; i++) {
			cin >> h[i];
		}
		sort(h, h + n);

		int k = h[n - 1] / b + 1;

		ll cnt = binary_s(INF);

		cout << cnt << endl;
	
	return 0;

}

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

// 回文ならばtrueを返す関数
bool Get_is_palindrome(string s) {
	bool result = true;
	for (int i = 0; i < s.size() / 2; i++) {
		if (s[i] != s[s.size() - i - 1]) {
			result = false;
		}
	}
	return result;
}

int main() {
	
	int a, b; cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		if (Get_is_palindrome(to_string(i))) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#define ll long long
#define mod 1000000007
using namespace std;

ll n, arr[10004];
map<ll, ll>mp;

ll fp(ll base, ll power)
{
    if (power == 0) return 1;
    ll ans = fp(base, power / 2);
    ans = (ans * ans) % mod;
    if (power % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void get_max(ll key, ll val)
{
    map<ll, ll>::iterator it = mp.find(key);
    if (it == mp.end())
        mp.insert({ key,val });
    else
        it->second = max(it->second, val);
}

void get_factors(ll x)
{
    ll xx = x;
    bool prime = 1;
    for (int i = 2; i <= sqrt(x); i++)
    {
        if (xx % i == 0)
        {
            prime = 0;
            ll power = 0;
            while (xx % i == 0)
            {
                power++;
                xx /= i;
            }
            get_max(i, power);
        }
    }
    if (xx > 1)
        get_max(xx, 1);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        get_factors(arr[i]);
    }
    ll lcm = 1, ans = 0;
    for (auto i : mp)
        lcm = ((lcm % mod) * fp(i.first, i.second)) % mod;
    for (int i = 0; i < n; i++)
        ans = (ans + ((lcm * fp(arr[i], mod - 2)) % mod)) % mod;
    cout << ans % mod << '\n';
    return 0;
}


Measured memory_bytes: 896
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	K *= K;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		M += L * L + R * R <= K;
	}
	cout << M << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_in(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef int64_t ll;

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

  rep(i, s.length()) {
    if(i%2==0){ //奇数文字目
      switch (s[i]) {
        case 'R':
        case 'U':
        case 'D':
          continue;
        default:
          cout<<"No"<<endl;
          return 0;
      }
    }else{
      switch (s[i]) {
        case 'L':
        case 'U':
        case 'D':
          continue;
        default:
          cout<<"No"<<endl;
          return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n;
    int a[100100];
    cin>>n;
    REP(i,n)cin>>a[i];
    long long ans=1;
    int c[3];
    const long long mod=1000000007L;
    REP(i,3)c[i]=-1;
    REP(i,n){
        // cout<<i<<endl;
        // REP(j,3)cout<<c[i]<<" ";cout<<endl;
        vector<int>v;
        long long cnt=0;
        REP(j,3)if(c[j]==a[i]-1)cnt++;
        ans=(ans*cnt)%mod;
        // cout<<1e7<<endl;
        REP(j,3)if(c[j]==a[i]-1){
            c[j]=a[i];
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env pypy3

from sys import stdin, stdout
 
def input():
    return stdin.readline().strip()

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

yen = 1000
stocks = 0

for i in range(len(A)):
    if i < len(A)-1 and A[i+1] > A[i]:
        # buy
        new_stocks = yen // A[i]
        stocks += new_stocks
        yen -= new_stocks*A[i]
    if i == len(A)-1 or A[i+1] < A[i]:
        # sell
        yen += stocks*A[i]
        stocks = 0

print(yen)

Measured memory_bytes: 61932
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{	int a,b;
	cin >> a>>b;
  	cout << ((a*b)/(__gcd(a,b)));
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    string s;
    cin>>s;
    int cnt[N]={};
    for(char c:s){
        cnt[c]=1;
    }
    puts(cnt['N']==cnt['S']&&cnt['W']==cnt['E'] ? "Yes":"No");
    
}

Measured memory_bytes: 1280
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strlen(), strncmp()

int
main(int argc, char** argv)
{
	char t[1001];
	char p[1001];
	int m, n;
	int i;

	scanf("%s %s", t, p);
	m = strlen(t);
	n = strlen(p);
	for (i = 0; i <= m - n; ++i)
	{
		if (strncmp(&t[i], p, n) == 0)
			printf("%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 560
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

/*
const int MAX_E=2*(100-1);
const int MAX_V=100;
const long long int INF=100000000;
struct edge { int from,to,cost;};
edge es[MAX_E];
//int d[MAX_V];
int V,E;
void shortest_path(int s,int e,vector<int>& d);
int main(){
	int n,k;
	while(cin >> n >> k&&n!=0&&k!=0){
		int V=n;
		int E=2*(n-1);
		vector<int> land(V);
		int l=0;
		for(int i=0; i<E; ++i){
			es[i].cost=-1;
			es[i].from=-1;
			es[i].to=-1;
		}
		for(int i=0; i<k; ++k){
			int m;
			cin >> m;
			if(m==0){
				int a,b;
				cin >> a >> b;
				shortest_path(a,b,land);
				cout << land[b] << "\n";
			} else if(m==1){
				int c,d,e;
				cin >> c >> d >> e;
				es[l].from=c;
				es[l].to=d;
				es[l].cost=e;
				es[l+1].from=d;
				es[l+1].to=c;
				es[l+1].cost=e;
				l+=2;
			}
		}
	}
	return 0;
}

void shortest_path(int s,int e,vector<int>& d){
	cout << "ok1\n";
	for(int i=0; i<V; ++i) {
		cout << "ok\n";
		d[i]=INF;
	}
	d[s]=0;
	while(true){
		cout << "ok2\n";
		bool update=false;
		for(int i=0; i<E; ++i){
			edge e=es[i];
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update) break;
	}
}
*/
/*
const int INF=100000000;
int main(){
	int n;
	while(cin >> n&&n!=0){
		vector<int> color;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			color.push_back(t);
		}
		int maxDel=INF;
		for(int i=0; i<n; ++i){
			for(int j=1; j<=3; ++j){
				if(color[i]==j) continue;
				int up=i-1;
				int down=i+1;
				int sum=0;
				int c=1;
				int col=j;
				while(1){
					int nCal=-1;
					while(1){
						if(up<0) break;
						if(color[up]!=col){
							nCal=color[up];
							break;
						}
						up--;
						c++;
					}
					while(1){
						if(down>=n) break;
						if(color[down]!=col){
							if(nCal==-1) nCal=color[down];
							break;
						}
						++down;
						++c;
					}
					if(c>=4){
						sum+=c;
					} else{
						break;
					}
					c=0;
					if(nCal==-1){
						break;
					}else{
						col=nCal;
					}
				}
				maxDel=min(maxDel,n-sum);
			}
		}
		cout << maxDel << "\n";
	}
	return 0;
}
*/

int main(){
	int n=0;
	for(int i=0; i<4; ++i){
		int tmp;
		cin >> tmp;
		n+=tmp;
	}
	vector<int> ans(2);
	while(n>=60){
		n-=60;
		++ans[1];
	}
	ans[0]=n;
	cout << ans[1] << "\n" << ans[0] << "\n";
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int A, B;
	cin >> A >> B;

	int diff = B - A;
	int h_a = diff*(diff-1)/2;
	cout << h_a - A << endl;
}

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

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

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int tmp = 0;
            if(s[i][j] == '.'){
                for(int x = -1; x < 2; x++){
                    for(int y = -1; y < 2; y++){
                        int nx = x + i, ny = y + j;
                        if(nx >= 0 && nx < h && ny >= 0 && ny < w){
                            if(s[nx][ny] == '#') tmp++;
                        }
                    }
                }
                s[i][j] = char(tmp + '0');
            }
        }
    }
    for(string a : s) cout << a << endl;
}

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

int main()
{
  long long k, a, b, ans;
  cin >> k >> a >> b;
  if(k - 1 < a || b - a <= 2)
  {
    ans = k + 1;
  }
  else
  {
    if((k-a+1)%2 == 0)
    {
      ans = a + (b-a) * ((k-a+1)/2);
    }
    else
    {
      ans = a + (b-a) * ((k-a+1)/2) + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int modpow(Int a, Int n, Int mod) {
    Int ret = 1;
    while (n > 0) {
        if (n & 1) {
            ret = ret * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }

    return ret;
}

vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
    is_ncr_table = true;

    // 1! ~ n! の計算
    Int f = 1;
    factorials.push_back(f);
    for (Int i = 1; i < n + 1; i++) {
        f *= i;
        f %= mod;
        factorials.push_back(f);
    }
    // n!^-1 の計算
    Int inv = modpow(factorials[n], mod - 2, mod);
    // (n-1)!^-1 ~ 1!^-1 の計算
    invs.assign(n, 1);
    invs[n] = inv;
    for (Int i = n; i >= 1; i--) {
        inv *= i;
        inv %= mod;
        invs[i - 1] = inv;
    }
}

Int factorial(Int n, Int mod = 1) {
    Int ret = 1;
    if (mod == 1) {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
        }

        return ret;
    } else {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
            ret %= mod;
        }

        return ret;
    }
}

Int ncr(Int n, Int r, Int mod, bool use_table = false) {
    if (use_table) {
        // modが素数の場合のみ
        if (!is_ncr_table) {
            calc_ncr_table(n, mod);
        }
        return factorials[n] * invs[r] * invs[n - r] % mod;
    } else {
        Int x = 1;
        for (Int i = n - r + 1; i < n + 1; i++) {
            x *= i;
            x %= MOD;
        }
        return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
    }
}

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

    cout << t + s << endl;

    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> a(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        if (S[i] == '<') a[i+1] = max(a[i+1], a[i] + 1);
    }
    for (int i = N-1; i >= 0; --i) {
        if (S[i] == '>') a[i] = max(a[i], a[i+1] + 1);
    }
    long long res = 0;
    for (int i = 0; i < N+1; ++i) res += a[i];
    cout << res << endl;
}

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

using namespace std;

int act0[100005],act1[100005],act2[100005];
int dp[100005][3];

int main()
{
  int n;

  scanf("%d",&n);
  scanf("%d%d%d",&act0[0],&act1[0],&act2[0]);
  dp[0][0]=act0[0];
  dp[0][1]=act1[0];
  dp[0][2]=act2[0];
  for(int c=1;c<n;c++)
  {
    scanf("%d%d%d",&act0[c],&act1[c],&act2[c]);
    dp[c][0]=act0[c]+max(dp[c-1][1],dp[c-1][2]);
    dp[c][1]=act1[c]+max(dp[c-1][0],dp[c-1][2]);
    dp[c][2]=act2[c]+max(dp[c-1][0],dp[c-1][1]);
  }
  printf("%d\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>

#define LLI long long int

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];

	multiset<int>B;
	for(int i=N-1;i>=0;i--){
		if(B.upper_bound(A[i])==B.end()){
			B.insert(A[i]);
		}else{
			B.erase(B.upper_bound(A[i]));
			B.insert(A[i]);
		}
	}
	
	cout<<B.size()<<endl;

	return 0;
}



Measured memory_bytes: 5376
gets
x = gets.split(" ").map(&:to_f)
y = gets.split(" ").map(&:to_f)
d = [x,y].transpose.map{|c| c.inject(:-).abs}
(1..4).each do |i|
  puts ((i == 4) ? d.max : d.map{|c| c**(i)}.inject(:+)**(1.0/i)).round(6)
end

Measured memory_bytes: 8780
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_a solver = new ABC135_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();

            int Max = Math.max(A, B);

            for (int i = 0; i < Max; i++) {
                if (Math.abs(A - i) == Math.abs(B - i)) {
                    out.println(i);
                    return;
                }

            }
            out.println("IMPOSSIBLE");
        }

    }
}



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


using namespace std;


int main(){
  vector<string > present;
  int N;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    string tmp;
    cin >> tmp;
    present.push_back(tmp);
  }
  
  sort(present.begin(), present.end());
  int ans = 0;
  for (vector<string >::iterator itr = present.begin(); itr != present.end(); ++itr)
  {
    if(*itr != *(itr + 1))
      ans++;
  }
  
  cout << ans << endl;
  
  

  return 0;
}

Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt();
		char a[][] = new char[n][m];
		for (int i = 0; i < n; i++) {
			String temp = sc.next();
			for (int j = 0; j < m; j++)
				a[i][j] = temp.charAt(j);
		}
		int ans = 0;
		for (int i = 0; i < 1 << n; i++) {
			for (int j = 0; j < 1 << m; j++) {
				int totalBlacks = 0;
				for (int k = 0; k < n; k++)
					for (int l = 0; l < m; l++)
						if ((((1 << k) & i) > 0) && (((1 << l) & j) > 0))
							if (a[k][l] == '#')
								totalBlacks++;
				if (totalBlacks == p)
					++ans;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35712
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			scanner.nextLine();
			Map<Integer, Integer> numberCountMap = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int number = scanner.nextInt();
				if (null == numberCountMap.get(number)) {
					numberCountMap.put(number, 1);
				} else {
					numberCountMap.put(number, numberCountMap.get(number) + 1);
				}
			});
			int size = numberCountMap.size();
			if (size <= k) {
				System.out.println(0);
			} else {
				System.out.println(
						numberCountMap.entrySet().stream().mapToInt(x -> x.getValue()).sorted().limit(size - k).sum());
			}
		}
	}
}

Measured memory_bytes: 101180
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const S = 6 ;
ld p[S] , q[S] ;

inline ld get (ld x) {
	ld res = 0 ;

	for (int i = 0 ; i < S ; i ++) res += max(p[i] * x , q[i] * (1 - x)) ;

	return res ;
}

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

	for (int i = 0 ; i < S ; i ++) cin >> p[i] , p[i] /= 100 ;
	for (int i = 0 ; i < S ; i ++) cin >> q[i] , q[i] /= 100 ;

	ld low = 0 , high = 1 ;

	for (int _ = 0 ; _ < 150 ; _ ++) {
		ld f1 = (2 * low + high) / 3 , f2 = (low + 2 * high) / 3 ;

		if (get(f1) < get(f2)) high = f2 ;
		else low = f1 ;
	}

	cout << fixed << setprecision(10) << get(low) << '\n' ;
}


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

#define N 32

static char d[ N ][ N ];
static int  w, h;

static int
solve (
  int x,
  int y
  )
{
  int res = 1;

  if ( x < 0 || x >= w
    || y < 0 || y >= h
    || d[ y ][ x ] != '.' ) return ( 0 );

  d[ y ][ x ] = '#';
  res += solve ( x - 1, y );
  res += solve ( x + 1, y );
  res += solve ( x, y - 1 );
  res += solve ( x, y + 1 );

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int sx = 0, sy = 0;

    scanf ( " %d %d", &w, &h );
    if ( !( w | h ) ) break ;

    for ( i = 0; i < h; ++i )
    {
      char * v;

      scanf ( " %s", d[ i ] );

      v = strchr ( d[ i ], '@' );
      if ( v != NULL )
      {
        sx = v - d[ i ];
        sy = i;
        *v = '.';
      }
    }

    printf ( "%d\n", solve ( sx, sy ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
// #pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const ll infll=1e18+9;
const int infint=1e9+7;
const int MAXN=1e6+7;
const double eps=1e-9;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
inline ll read()
{
    ll kr=1,xs=0;char ls;ls=getchar();
    while(!isdigit(ls)){
        if(!(ls^45)) kr=-1;ls=getchar();
    }
    while(isdigit(ls)){
        xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
    }
    return xs*kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs=0;char ls;ls=getchar();
    while(!isdigit(ls)) ls=getchar();
    while(isdigit(ls)){
        xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
    }
    return xs;
}
inline void writeull(ull x){
    if(x<0){x*=-1;putchar('-');}
    if(x>=10) writeull(x/10);
    putchar('0'+x%10);
}
inline void write(ll x){
    if(x<0){x*=-1;putchar('-');}
    if(x>=10) write(x/10);
    putchar('0'+x%10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
ll a[MAXN],sum[MAXN];
int main()
{
    int t=1;
    // t=read();
    while(t--){
        int n=read();
        ll ans=0;
        for (int i=1;i<=n;i++) a[i]=read(),sum[i]=(sum[i-1]+a[i])%mod;
        for (int i=1;i<=n;i++){
            ans=(ans+(sum[n]-sum[i])*a[i])%mod;
        }
        ans%=mod;
        ans+=mod;
        ans%=mod;
        printf("%lld\n",ans);
    }
    return 0 ;
}

/*
6
011000010010000001100001011000010000101001100001
*/


Measured memory_bytes: 6860
word = input()
chr =[s for s in word]

x=[0,0,0,0]

for i in range(4):
  for j in range(4):
    if chr[i]==chr[j]:
      x[i]=x[i]+1

if x[0]==x[1]==x[2]==x[3]==2:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 3064