akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   int n = s.size();
   vector<array<int,3>> pairs;
   int state= 0,st = 0,en,mid;
   f(i,0,n){
      if(state == 0){
         if(s[i]=='L'){
            state = 1;
            mid = i;
         }
      }else{
         if(s[i]=='R'){
            state = 0;
            pairs.pb({st,mid,i-1});
            st = i;
         }
      }
      if(i==n-1){
         pairs.pb({st,mid,i});
      }
   }
   vector<int> ans(n,0);
   for(auto &el : pairs){
      int no = el[2]-el[0]+1;
      if(no%2 == 0){
         ans[el[1]-1] = no/2;
         ans[el[1]] = no/2;
      }else{
         if(el[1]-el[0] > el[2]-el[1]+1){
            ans[el[1]] = no/2;
            ans[el[1]-1] = (no+1)/2;
         }else{
            ans[el[1]] = (no+1)/2;
            ans[el[1]-1] = no/2;
         }
         int moves = max(el[1]-el[0]-1,el[2]-el[1]);
         if(moves & 1){
            swap(ans[el[1]],ans[el[1]-1]);
         }
      }
   }
   f(i,0,n){
      cout << ans[i] << ' ';
   }
   return 0;
} 

Measured memory_bytes: 2628
#include <iostream>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f

using namespace std;

struct Edge {
  int u, v, c, w;
  Edge(int u, int v, int c, int w) : u(u), v(v), c(c), w(w) {}
};
class Graph {
  int n, s, t;
  vector<int> flow, dist, pre, last;
  vector<bool> vis;
  vector<Edge> edges;
  vector<vector<int>> adj;

public:
  Graph(int n, int s, int t) : n(n), s(s), t(t) {
    adj = vector<vector<int>>(n);
    flow.reserve(n);
    dist.reserve(n);
    pre.reserve(n);
    last.reserve(n);
    vis.reserve(n);
  }
  void add_edge(int u, int v, int c, int w) {
    int m = edges.size();
    edges.emplace_back(u, v, c, w);
    edges.emplace_back(v, u, 0, -w);
    adj[u].emplace_back(m);
    adj[v].emplace_back(m | 1);
  }

  bool spfa() {
    dist.assign(n, INF);
    flow.assign(n, INF);
    vis.assign(n, false);
    queue<int> q;
    q.push(s);
    vis[s] = true;
    dist[s] = 0;
    pre[t] = -1;

    while (!q.empty()) {
      int u = q.front();
      q.pop();
      vis[u] = false;
      for (int e : adj[u]) {
        auto [_, v, c, w] = edges[e];
        if (c > 0 && dist[v] > dist[u] + w) {
          dist[v] = dist[u] + w;
          pre[v] = u;
          last[v] = e;
          flow[v] = min(flow[u], c);
          if (!vis[v]) {
            vis[v] = true;
            q.push(v);
          }
        }
      }
    }

    return pre[t] != -1;
  }

  pair<int, int> min_cost_max_flow() {
    int mincost = 0;
    int maxflow = 0;
    while (spfa()) {
      int now = t;
      mincost += flow[t] * dist[t];
      while (now != s) {
        edges[last[now]].c -= flow[t];
        edges[last[now] ^ 1].c += flow[t];
        now = pre[now];
      }
      maxflow += flow[t];
    }
    return {maxflow, mincost};
  }
};

using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; ++i)
    cin >> s[i];
  int ball = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == 'o')
        ball++;
  int nodes = ball + n * m + 2;
  Graph g(nodes, 0, nodes - 1);
  int hi = n + m;
  for (int i = 1; i <= ball; ++i)
    g.add_edge(0, i, 1, 0);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      int idx = ball + i * m + j + 1;
      g.add_edge(idx, nodes - 1, 1, 0);
    }
  int ball_idx = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (s[i][j] != 'o')
        continue;
      vector<vector<int>> dp(n, vector<int>(m, INF));
      dp[i][j] = 0;
      for (int p = i; p < n; ++p)
        for (int q = j; q < m; ++q) {
          if (s[p][q] == '#')
            continue;
          if (p > i && dp[p - 1][q] != INF)
            dp[p][q] = dp[p - 1][q] + 1;
          if (q > j && dp[p][q - 1] != INF)
            dp[p][q] = dp[p][q - 1] + 1;
          if (dp[p][q] != INF) {
            int idx = ball + p * m + q + 1;
            g.add_edge(ball_idx, idx, 1, hi - dp[p][q]);
          }
        }
      ball_idx++;
    }
  auto [flow, cost] = g.min_cost_max_flow();
  int ans = hi * flow - cost;
  cout << ans;
}

Measured memory_bytes: 8276
#include<cstdio>
#define MAXN 100006
#include<algorithm>
using namespace std;
int n,m,id[MAXN],st[MAXN],top;
long long a[MAXN],ans[MAXN],k;
bool vis[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),id[i]=i;
	for(int i=n;i>=1;i--)
		a[i]-=a[i-1];
	scanf("%d%lld",&m,&k);
	for(int i=1,x;i<=m;i++)
		scanf("%d",&x),swap(id[x],id[x+1]);
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			top=0;
			for(int j=i;!vis[j];j=id[j])
				st[++top]=j,vis[j]=1;
			for(int j=1;j<=top;j++)
				ans[st[j]]=a[st[(k+j-1)%top+1]];
		}
	for(int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%lld\n",ans[i]);
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int C[2005][2005], f[2005][2005], g[2005][2005], F[2005], G, A, B, N;
int main()
{
	A = read(), B = read(), N = max(A,B);
	for(rint i = 0, j; i <= N; i++) for(C[i][0] = 1, j = 1; j <= i; C[i][j] = C[i-1][j]+C[i-1][j-1], C[i][j]<MOD?:C[i][j]-=MOD, j++);
	for(rint a = 0; a <= A; f[a][0] = g[a][0] = 1, a++); for(rint b = 0; b <= B; f[0][b] = g[0][b] = 1, b++); F[0] = G = 1;
	for(rint a = 1, b; a <= A; a++)
		for(b = 1; b <= B; f[a][b] = f[a-1][b]+C[b][a], f[a][b]<MOD?:f[a][b]-=MOD, b++);
	for(rint a = 1, b; a <= A; a++)
		for(b = 1; b <= B; g[a][b] = g[a-1][b]+f[a][b-1], g[a][b]<MOD?:g[a][b]-=MOD, b++);
	for(rint a = 1, j; a <= A; a++)
		for(j = 0; j <= a; F[a] = (F[a]+1ll*C[B-1][j]*g[a-j][j])%MOD, j++);
	for(rint a = 1; a <= A; G = G+F[a], G<MOD?:G-=MOD, a++); printf("%d\n",G); return 0;
}

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1e15);
const auto MOD = static_cast<ll>(1e9 + 7);

/*********** Variables ***********/
ll N, ANS;
vector<ll> R, MIN;

/*********** Functions ***********/
bool init() {
    cin >> N;
    R.resize(N, 0);
    MIN.resize(N, 0);
    for (auto& r : R) cin >> r;
    return true;
}

void solve() {
    for (ll i = 0; i < N; i++) {
        if (i == 0) {
            MIN[0] = R[0];
        }
        else {
            MIN[i] = min(MIN[i - 1], R[i]);
        }
    }
    ANS = -INF;
    for (ll i = 1; i < N; i++) {
        ANS = max(ANS, R[i] - MIN[i - 1]);
    }
}

void output() {
    cout << ANS << endl;
}

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


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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,y,a,b,x;
    scanf("%d %d",&n,&y);
    for(a = 0 ; a <= n ; a++)
    {
        for(b = 0 ; b <= n ; b++)
        {
            if(n - a - b >= 0 && y == 10000 * a + 5000 * b + 1000 * (n - a - b))
            {
                printf("%d %d %d\n",a,b,n - a - b);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 1732
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Cin.Int()
    Dim st As String() = Cin.StrArr()
    Dim s As String = st(0)
    Dim t As String = st(1)
    Dim ans As String = ""
    For i As Integer = 0 To n - 1
      ans &= (s(i) & t(i))
    Next
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 11220
#include<iostream>
int main()
{
	int N;
	std::cin >> N;
	bool*result = new bool[N];
	for(int i = 0; i < N; i++)
	{
		int a, b, c;
		std::cin >> a >> b >> c;
		result[i] = a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a;
	}
	for(int i = 0; i < N; i++)
	{
		std::cout << (result[i] ? "YES" : "NO") << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    string s;
    cin >> s;
    
    string out="No";
    REP(i, s.size()-1){
        if(s[i]=='A' && s[i+1]=='C') out = "Yes";
    }
    cout << out<< endl; 

   return 0;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
priority_queue<int , vector<int> , greater<int>> A;
vector<pair<int,int>> P;
int32_t main(){
    fast;
    int n , m ; cin >> n >> m ;
    for(int i = 0; i < n ; ++i){
        int a ; cin >> a;
        A.push(a);
    }
    for(int q = 0; q < m ; ++q){
        int a , b; cin >> a >> b ;
        P.push_back({b,a});
    }
    sort(P.rbegin(),P.rend());
    for(auto i : P){
        int a = i.first , b = i.second;
        if(A.top() >= a) break;
        for(int j = 0 ; j < b ; ++j){
            A.pop();
            A.push(a);
        }
    }

    int ans = 0;
    while(!A.empty()){
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6084
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int N;
  int max_candy = 0;
  cin >> N;
  vector<vector<int>> map(2, vector<int>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> map[i][j];
    }
  }

  for (int i = 0; i < N; i++) {
    int candy_count = 0;
    int row = 0;
    for (int j = 0; j < N; j++) {
      if (row == 0) {
        candy_count += map[0][j];
        if (i == j) {
          row = 1;
          candy_count += map[1][j];
        }
      }
      else if (row == 1) {
        candy_count += map[1][j];
      }
    }
    max_candy = max(max_candy, candy_count);
  }

  cout << max_candy << endl;

  return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A_i = list(map(int, input().split()))


# 20 3 20メートルで3件の家
# 0 5 15

# [5, 10] + [0 + (20 -15)]
# [5, 10, 5]
# max([5, 10, 5]) => 10
# 20 - 10

D_i = []
D_i.append(A_i[0] + K - A_i[-1])


for i in range(N-1):
    D_i.append(A_i[i+1] - A_i[i])

print(K - max(D_i))


Measured memory_bytes: 26420
#include<bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int i,j;
  bool ok=false;
  int n,ans=0;
  cin>>n;
  vector<lli> a(n);
  rep(i,0,n){
    cin>>a.at(i);
    if(a.at(i)==1)ok=true;
  }
  if(!ok){
    cout<<"-1"<<endl;
    return 0;
  }
  if(ok){
    rep(i,0,n){
      if(a.at(i)==i+1-ans)
        continue;
      if(a.at(i)!=i+1-ans)
        ++ans;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int count;
  cin >> count;
  vector<int> v;
  for (int i = 0; i < count; i++)
  {
    int num;
    cin >> num;
    v.push_back(num);
  }

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

  int alice = 0;
  int bob   = 0;
  int no = 0;
  for (auto &&i : v)
  {
    if(no % 2 == 0) alice += i;
    if(no % 2 == 1) bob += i;
    no++;
  }
  cout << (alice - bob) << endl;  
  
}




Measured memory_bytes: 256
str_cookies_num = input()
cookies_num = str_cookies_num.split()
cookies_A = int(cookies_num[0])
cookies_B = int(cookies_num[1])

if (cookies_A + cookies_B) % 3 == 0:
    print("Possible")
elif cookies_A % 3 == 0:
    print("Possible")
elif cookies_B % 3 == 0:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
#!/usr/bin/perl
#abc082_a.pl
#Thu Jan 11 23:22:51 2018
#

use warnings;
use strict;

my $s = <STDIN>;
chomp $s;
my $t = <STDIN>;
chomp $t;

my @first = split("",$s);
my @firstsorted = sort{$a cmp $b} @first;
my $ssorted = join("",@firstsorted);

my @second = split("",$t);
my @secondsorted = sort{$b cmp $a} @second;
my $tsorted = join("",@secondsorted);

my @test = ($ssorted,$tsorted);
my @testsorted = sort{$a cmp $b} @test;
if ($testsorted[0] eq $testsorted[1]){
	print "No\n";
}elsif($testsorted[0] eq $ssorted){
	print "Yes\n";
}else{
	print "No\n";
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
    int N,M,P,i;
    int X[1000];
    int sum;

    while(scanf("%d%d%d",&N,&M,&P),N+M+P){

        sum=0;
        for(i=1;i<=N;i++){
            scanf("%d",&X[i]);
            sum+=X[i];
        }

        printf("%d\n",X[M]!=0?(100-P)*sum/X[M]:0);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
int x[N];
int main(){
    int n,k;cin>>n>>k;
    lol(i,n)cin>>x[i];
    int ans=mod;
    lol(i,n-k+1)ans=min(ans,x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1])));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ary = new int[n];
		for(int i = 0; i < n; i++){
			ary[i] = sc.nextInt();
		}
		int minPower = Integer.MAX_VALUE;
		for(int i = 1; i < 101; i++){
			int power = 0;
			for(int i2 = 0; i2 < n; i2++){
				power += (i - ary[i2]) * (i - ary[i2]);
			}
			minPower = Math.min(minPower, power);
		}
		System.out.println(minPower);
	}
}


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

void solve() {
    int a; cin >> a;
    cout << a * a << endl;
}

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


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

#define FOR(i, s, e) for (int i = (s); i <= (e); i++)


int prime[100010];

int Q;

int pri_num[50000];

int pri_cou = 0;

int memo[100010];

int main()
{
    FOR(n,2,100000)
    {
        if(prime[n] == 0)
        {
            prime[n] = 1;
            for(int i = n + n;i <= 100000;i+=n)
            {
                prime[i] = -1;
            }
        }
    }

    memo[0] = 0;

    for(int i = 3;i <= 100000;i++)
    {
        memo[i] = memo[i - 1];
        if(i % 2 == 1 && prime[i] == 1 && prime[(i + 1) / 2] == 1) memo[i]++;
    }

    cin >> Q;

    


    int l,r;

    FOR(i,1,Q)
    {
        cin >> l >> r;

        int cou = memo[r] - memo[l];

        if(prime[l] == 1 && prime[(l + 1) / 2] == 1) cou++;

        cout << cou << endl;
    }

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	ll num, k, i, ans;
	cin >> num >> k;
	ans = num;
	num %= k;
	chmin(ans, num);
	chmin(ans, abs(k - num));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int r = (int) sc.nextInt();

		double l = 2 * r * Math.PI;
		System.out.println(l);

		sc.close();
	}

}


Measured memory_bytes: 35844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 5e5 + 5, MAXM = 2e5 + 5, BOUND = 1e7, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, a[MAXN], sum[MAXN], b[MAXN];
vi pos[MAXN];
inline void add(int &x, int y) {
	x += y;
	if (x >= MOD)x -= MOD;
}
inline int get_v(int x, int y) {
	if (x > y)swap(x, y);
	return sum[y] - sum[x - 1];
}
int main() {
	cin >> n;
	int k = 0;
	rep(i, 1, n)cin >> a[i], k ^= a[i], a[i] = k, b[i] = a[i];
	b[k = n + 1] = 0;
	sort(b + 1, b + 1 + k);
	k = unique(b + 1, b + 1 + k) - b - 1;
	rep(i, 1, n) {
		a[i] = lower_bound(b + 1, b + 1 + k, a[i]) - b;
		pos[a[i]].push_back(i);
		sum[i] = sum[i - 1] + (a[i] == 1);
	}
	int ans = 0;
	if (a[n] == 1) {
		ans = 1;
		rep(j, 2, pos[1].size())ans = ans * 2 % MOD;
	}
	rep(i, 2, k) {
		if (a[n] != i && a[n] != 1)continue;
		int pre = 0, odd = 0, even = 1;
		for (int j = 0; j < pos[i].size(); j++) {
			int x = get_v(pre, pos[i][j]);
			add(even, (ll)odd * x%MOD);
			add(odd, even);
			pre = pos[i][j] + 1;
		}
		if (a[n] == 1) {
			add(ans, odd);
		}
		else {
			add(ans, even);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 27380
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int a,b,c; cin >> a >> b >> c;
    int k; cin >> k;

    rep(i,k){
        if(a >= b) b*=2;
        else if(a >= c) c*=2;
        else if(b >= c) c*=2;
    }
    //b > a and c > b
    //c > b > a
    if (c > b && b > a) cout << "Yes" << endl;
    else cout << "No" << endl;
}


/*
g++ b.cpp
./a.out

oj d https://atcoder.jp/contests/abc172/tasks/abc172_c
oj t
*/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep( i, n ) for (int i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

int main(){
	string s,t ,u;
	int a,b;

	cin>>s>>t;
	cin>>a>>b;
	cin>>u;

	if(s==u) a--;
	else b--;

	cout<<a<<" "<<b;
}


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

int main() {
  string a;
  int s;
  cin>>a;
  if(a[0]=='1'){
    s++;
  }
   if(a[1]=='1'){
    s++;
  }
   if(a[2] =='1'){
    s++;
  }
  
  cout<<s<<endl;// ここにプログラムを追記
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if(w>=x+r&&h>=y+r&&0<=x-r&&0<=y-r)
    cout<<"Yes"<<"\n";
  else
    cout<<"No"<<"\n";
}

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

int main() {
    int N;
    cin>>N;
    vector<tuple<string, int ,int>> a(N);
    rep(i,N){
        cin >> get<0>(a.at(i)) >> get<1>(a.at(i));
        get<1>(a.at(i))=get<1>(a.at(i))*(-1);
        get<2>(a.at(i))=i;
    }
    sort(a.begin(),a.end());
    rep(i,N){
        cout << get<2>(a.at(i))+1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        int ans = 0;

        for (int i = 0; i < S.length()+1; i++) {
            for (int j = i + 1; j < S.length()+1; j++) {
                String sub = S.substring(i, j);
                int tmpLen = 0;
                for (int k = 0; k < sub.length(); k++) {
                    if (sub.charAt(k) == 'A' || sub.charAt(k) == 'C' || sub.charAt(k) == 'G' || sub.charAt(k) == 'T') {
                        tmpLen++;
                    } else {
                        break;
                    }
                }
                ans = Math.max(ans, tmpLen);
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21076
def binarySearch(A, n, key):
	left = 0
	right = n
	while left < right:
		mid = (left + right) // 2
		if A[mid] == key:
			return True
		elif key < A[mid]:
			right = mid
		else:
			left = mid + 1
	return False


if __name__ == "__main__":
	n = int(input())
	S = list(map(int, input().split()))
	q = int(input())
	sum = 0
	for key in list(map(int, input().split())):
		if binarySearch(S, n, key):
			sum += 1
	print(sum)


Measured memory_bytes: 16708
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
        for(ll j = i; j <= n; j += i) {
		    ans += j;
        }
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := nextString()
	var sum int
	for i := 0; i < 3; i++ {
		if s[i:i+1] == "1" {
			sum++
		}
	}
	fmt.Println(sum)
}

// 以下がテンプレート

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 2e5 + 5;
int par[MAX], sz[MAX];
void init(int n) {
	for(int i = 0; i <= n; i++) {
		par[i] = i;
		sz[i] = 1;
	}
}
int find_parent(int a)
{
	if(a == par[a]) return a;
	return par[a] = find_parent(par[a]);
}
void union_sets(int a, int b)
{
	a = find_parent(a);
	b = find_parent(b);
	if(a != b) {
		if(sz[a] < sz[b])
			swap(a, b);
		par[b] = a;
		sz[a] += sz[b];
	}
}

int main()
{
	boost;
	int n, m, i, a, b;
	cin >> n >> m;
	init(n);
	
	fo(i, 0, m) {
		cin >> a >> b;
		union_sets(a, b);
	}
	
	int ans = 0;
	foe(i, 1, n)
	ans = max(ans, sz[find_parent(i)]);
	cout << ans;
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    string S;
    cin >> S;
    int N=S.size();
    N/=2;
    for(int i=1;i<N;i++){
        if(S.substr(0,N-i)==S.substr(N-i,N-i)){
            cout << 2*N-2*i << endl;
            break;
        }
    }


}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;


int main() {
	ll K;
	string S;
	cin >> K;
	cin >> S;
	ll cnt = 0;
	for (ll i = 0; i < K; ++i) {
		if (S[i] == 'C') {
			if (i < 2) {
				continue;
			}
			if (S[i - 1] == 'B' && S[i - 2] == 'A') {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9+7;


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

    int n,m,t,p;
    vector<int> ans;
    while(cin>>n>>m>>t>>p){
        if(n==0) break;
        vector<int> h(50000),w(50000);
        for(int i=0;i<m;i++) h[i] = 1;
        for(int i=0;i<n;i++) w[i] = 1;
        int dd,c;
        int l=0,d=0;
        for(int i=0;i<t;i++){
            cin>>dd>>c;
            if(dd==1){
                for(int j=1;j<=c;j++){
                    w[l+c+j-1] += w[l+c-j];
                }
                l+=c;
            }
            else {
                for(int j=1;j<=c;j++){
                    h[d+c+j-1] += h[d+c-j];
                }
                d+=c;
            }
        }
        
        
        int x,y;
        for(int i=0;i<p;i++){
            cin >> x >> y;
            cout << h[d+y] * w[l+x] << endl;;
            ans.push_back( h[d+y] * w[l+x]  );
        }
    }
    //cerr<<endl;
    //for(auto i:ans) cerr<<i<<endl;
    
    
    
}


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

int main(){
    string str;
    
    while(getline(cin,str)){
        int flg = 0;
        
        while(true){
            for(int i = 0 ; i < str.length() ; i++){
                string key1 = str.substr(i,3),key2 = str.substr(i,4);
                if(key1 == "the" || key2 == "that" || key2 == "this") flg = 1;
            }
            
            if(flg) break;
            else{
                for(int j = 0 ; j < str.length() ; j++){
                    if('a' <= str[j] && str[j] <= 'z'){
                        str[j] -= 'a' - 'A';
                        str[j] = (char)('A'+(str[j]-'A'+26+1)%26);
                        str[j] += 'a' - 'A';
                    }
                    else continue;
                }
            }
        }
        cout << str << endl;
    }
        
    return 0;
}

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

struct Q {
	int b, e;
	string name;
	Q(int b = 0, int e = 0, string name = string()): b(b), e(e), name(name){}
};

int main()
{
	int n, q;
	while (scanf("%d %d", &n, &q), n|q){
		vector<Q> v;
		for (int i = 0; i < n; i++){
			string str;
			int b, w;
			cin >> str >> b >> w;
			v.push_back(Q(w - b, w, str));
		}
		while (q--){
			int y;
			scanf("%d", &y);
			bool f = false;
			for (int i = 0; i < n; i++){
				Q& a = v[i];
				if (y <= a.b || a.e < y) continue;
				cout << a.name << " " << y - a.b << endl;
				f = true;
				break;
			}
			if (!f) puts("Unknown");
		}
	}
}

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    if (n % 111 == 0)
        cout << n << endl;
    else {
        for (int i = n; ; i++)
            if (i % 111 == 0) {
                cout << i << endl;
                break;
            }
    }   
    return 0;
}




Measured memory_bytes: 256
def ii2ss(n):
    ss = []
    for i in range(n):
        ss.append(input())
    return ss

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

import math
def main(ss):
    nn = ss2nn(ss)
    total = 0
    mod = 0
    for n in nn:
        n2 = math.ceil(n/10)*10
        total += n2
        m = n % 10
        if m != 0:
            if mod == 0:
                mod = m
            elif m < mod:
                mod = m
    if mod != 0:
        total -= 10 - mod
    return total
ss = ii2ss(5)
print(main(ss))

Measured memory_bytes: 3064
#define GODSPEED ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define f(i,x,n) for(i=x;i<n;i++)
#define rf(i,x,n) for(i=n;i>x;i--)
#define ll long long
#define GCD(a,b) __gcd(a,b)
#define adios return 0;

/*
SHERAJUL ARIFIN
Dept. of CSE,
IUT.
*/


#include <bits/stdc++.h>
using namespace std;

int main()
{
    GODSPEED;
    double t,n,a,b,c,d,s=0,i,j,flag,pi=3.14159;
    cin>>a;
    cout<<2.0*a*pi<<endl;





    adios;
}


Measured memory_bytes: 3788
rect_cnt = dia_cnt = 0
 
while True:
  try:
    a, b, c = map(int, input().split(","))
     
    rect_cnt += (a ** 2 + b ** 2 ==  c ** 2)
    dia_cnt += (a == b)
 
  except EOFError:
    break
print(rect_cnt)
print(dia_cnt)


Measured memory_bytes: 5592
#include "bits/stdc++.h"
using namespace std;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

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

		double avg = 0;
		vector<int> a( N );
		for( auto& v: a ) {
			cin >> v;
			avg += v;
		}
		avg /= N;

		double d = DBL_MAX;
		int ans = N;
		for( int i = 0; i < N; ++i ) {
			double x = abs( a[i] - avg );

			if( x < d ) {
				d = x;
				ans = i;
			}
		}

		cout << ans << endl;
	}
};

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> p;
vector<long long int> q;
int main() {
	int A, B;
	cin >> A >> B;
	int x = A + B;
	int y = A - B;
	int z = A * B;
	int max = -100000000;
	if (x >= max)max = x;
	if (y >= max)max = y;
	if (z >= max)max = z;
	cout << max << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b=map(int,input().split())
    if((a+b)%2):
        print("IMPOSSIBLE")
    else:
        print((a+b)//2)
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X,ans,a;
    ans = 0;
    cin >> X;
    a = int(X/100);
    switch (a) {
        case 4:
            ans = 8;
            break;
        case 5:
            ans = 8;
            break;
        case 6:
            ans = 7;
            break;
        case 7:
            ans = 7;
            break;
        case 8:
            ans = 6;
            break;
        case 9:
            ans = 6;
            break;
        case 10:
            ans = 5;
            break;
        case 11:
            ans = 5;
            break;
        case 12:
            ans = 4;
            break;
        case 13:
            ans = 4;
            break;
        case 14:
            ans = 3;
            break;
        case 15:
            ans = 3;
            break;
        case 16:
            ans = 2;
            break;
        case 17:
            ans = 2;
            break;
        case 18:
            ans = 1;
            break;
        case 19:
            ans = 1;
            break;
        default:
            
            break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
	cout<<"1";
	else if(b==0)
	cout<<"2";
	else if(c==0)
	cout<<"3";
	else if(d==0)
	cout<<"4";
	else if(e==0)
	cout<<"5";
	return 0;
}

Measured memory_bytes: 3588
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();

    if(n==1) {
      System.out.println("Hello World");
    } else {
      int a=sc.nextInt();
      int b=sc.nextInt();
      System.out.println(a+b);
    }

  }
}


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

int main() {
    vector<int> vec(5);
    for (int i = 0; i < 5; i++) cin >> vec.at(i);
    int k; cin >> k;

    sort(vec.begin(), vec.end());
    int l;
    l = vec.at(4) - vec.at(0);

    if ( l <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<map>
#include<algorithm> 

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  long N;
  cin>>N;

  map<string,int> A;
  long MAX;

  for(int i=0;i<N;++i){
    string X;
    cin>>X;
    A[X]++;
    if(A[X]==2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define rep(i,a,n) for(ll i=a;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll memo;
  if(n>=b)memo=b-1;
  else memo=n;
  cout<<(a*memo)/b - a*(memo/b)<<endl;
  return 0;
}

Measured memory_bytes: 3636
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
ll x=n%k;
ll y=k-x;
cout<<min(x,y)<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define rep1(i,n) for (int i=1 ; i<=(n) ; ++i)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <string, string> P;

int main(){
  int x,y;
  cin >> x >> y;
  int z = x*2;
  for(z; z<=4*x ; z+=2){
    if(z==y){
      cout << "Yes" << endl;
      return 0;
    }
  }

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


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


int main(){
  int n;
  int prime[55] ={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,991,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471,1481};
  cin >> n;
  cout << prime[0];
  for(int i = 1; i < n; i++)
    cout << " " << prime[i] << endl;
    
  
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,ans1=0,ans2=0;
    cin>>a>>b>>c;
    if(a==5)ans1++;
    if(b==5)ans1++;
    if(c==5)ans1++;
    if(a==7)ans2++;
    if(b==7)ans2++;
    if(c==7)ans2++;
    if(ans1==2&&ans2==1)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x and x <= a + b) cout << "YES\n";
    else cout << "NO\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    ull ma(ull a,ull b)
    {
        return max(a,b);
    }
    int main()
    {
        std::ios::sync_with_stdio(false);
        cin.tie(0);
    	int n,w;
    	cin>>n>>w;
    	vector<vector<ull>> dp(n+1,vector<ull> (w+1));
     
    	for(int i=1;i<n+1;i++)
    	{
    		int s;
    		ull v;
    		cin>>s>>v;
     
     
    		for (int j=0;j<w+1;j++)
    			{
    				if(s>j)
                        {dp[i][j]=dp[i-1][j];}
    				else
    				{dp[i][j]=ma(dp[i-1][j-1], dp[i-1][j-s]+v);}
    			}
    	}
    	cout<<dp[n][w];
     
     
     
     
     
        return 0;
    }

Measured memory_bytes: 83048
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0591

"""
import sys
from sys import stdin
from math import factorial
input = stdin.readline


def solve(n, m, r):
    # https://www.ioi-jp.org/joi/2005/2006-m2-prob_and_sol/2006-m2-t5-review.html
    if n * m > r:
        return 0
    ans = factorial(n+r-m*n-1) // factorial(n-1) // factorial(r - m*n)
    return ans


def main(args):
    n, m, r = map(int, input().split())
    result = solve(n, m, r)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

int main() {
    long long a, b;
    cin >> a >> b;
    if (a%2 != b%2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a+b)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s[2],a[20];main(i,j,n,N,m){for(;scanf("%d",&n),n;printf("%d\n",m)){for(i=0;i<n;i++)scanf("%d",a+i);for(i=0,m=99999,N=1<<n;i<N;j=abs(*s-s[1]),m=m<j?m:j,i++)for(*s=s[1]=j=0;j<n;j++)s[(i>>j)&1]+=a[j];}exit(0);}

Measured memory_bytes: 600
type dice = { one : int; two : int; three : int;
              four : int; five : int; six : int}

let right_side {one=a;two=b;three=c;four=d;five=e;six=f} (top,front) =
  if top=a then (if front=b then c
                 else if front=c then e
                 else if front=d then b
                 else d)
  else if top=b then (if front=a then d
                      else if front=c then a
                      else if front=d then f
                      else c)
  else if top=c then (if front=a then b
                      else if front=b then f
                      else if front=e then a
                      else e)
  else if top=d then (if front=a then e
                      else if front=b then a
                      else if front=e then f
                      else b)
  else if top=e then (if front=a then c
                      else if front=c then f
                      else if front=d then a
                      else d)
  else (if front=b then d
        else if front=c then b
        else if front=d then e
        else c)

let () =
  let dice = Scanf.sscanf (read_line ()) "%d %d %d %d %d %d"
      (fun a b c d e f -> {one=a;two=b;three=c;four=d;five=e;six=f}) in
  let n = read_int () in
  let rec loop = function
      0 -> ()
    | i -> Scanf.sscanf (read_line ()) "%d %d" (fun a b -> a,b)
           |> right_side dice
           |> Printf.printf "%d\n";
      loop (i-1)
  in loop n

Measured memory_bytes: 2392
#include <stdio.h>

int main(void)
{
  int a, b, c, n;

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

  n=0;

  while(a<=b)
    {
      if(c%a==0)
        n++;

      a++;
    }
  printf("%d\n", n);

  return 0;
}

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

int main() {
  int H, W; cin >> H >> W;
  string s[H]; rep(i,H) cin >> s[i];
  int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int dj[] = {1, 1, 1, 0, 0, -1, -1, -1};
  
  rep(i, H) {
    rep(j, W) {
      if (s[i][j] == '#') {
        cout << "#";
        continue;
      }
      int c = 0;
      rep(k, 8) {
        int ik = i + di[k];
        int jk = j + dj[k];
        if (ik < 0 || ik >= H || jk < 0 || jk >= W) continue;
        if (s[ik][jk] == '#') c++;
      }
      cout << c;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int N, W, H, S, T;

main(){
	while(cin >> N >> W >> H, N){
		vector<vi> Y(501, vi(501, 0));
		REP(i, N){
			int x, y;
			cin >> x >> y;
			Y[y][x] ++;
		}
		REP(i, 500)REP(j, 500) Y[i+1][j+1] += Y[i][j+1] + Y[i+1][j] - Y[i][j];
		cin >> S >> T;
		int ans = 0;
		REP(i, 500-T)REP(j, 500-S){
			ans = max(ans, Y[i+T][j+S] - Y[i+T][j] - Y[i][j+S] + Y[i][j]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3
#define mod 1000000007

int N,D;
int ps[1000][1000];

int main(){
  scanf("%d%d",&N,&D);
  vector<vector<int>> f(2*D,vector<int>(2*D));
  ll mx=0;
  rep(i,N){
    int x,y;
    scanf("%d%d",&x,&y);
    x%=D; y%=D;
    ps[x][y]++;
  }
  rep(i,D)rep(j,D){
    maxch(mx,ps[i][j]);
    rep(k,2)rep(l,2){
      f[i+k*D][j+l*D]=ps[i][j];
    }
  }
  int M=0;
  while((M+1)*(M+1)<mx)M++;
  
  vector<vector<int>> table0(2*D+1,vector<int>(2*D+1,0));
  vector<vector<int>> table1(2*D+1,vector<int>(2*D+1,0));
  vector<vector<int>> table2(2*D+1,vector<int>(2*D+1,0));

  rep(i,2*D)rep(j,2*D){
    table0[i+1][j+1]=((M+1)*(M+1)-f[i][j]<0?1:0);
    table1[i+1][j+1]=(M*(M+1)-f[i][j]<0?1:0);
    table2[i+1][j+1]=(M*M-f[i][j]<0?1:0);
  }

  rep(i,2*D+1)rep(j,2*D){
    table0[i][j+1]+=table0[i][j];
    table1[i][j+1]+=table1[i][j];
    table2[i][j+1]+=table2[i][j];
  }
  rep(i,2*D)rep(j,2*D+1){
    table0[i+1][j]+=table0[i][j];
    table1[i+1][j]+=table1[i][j];
    table2[i+1][j]+=table2[i][j];
  }

  int lb=-1,ub=D-1;
  while(ub-lb>1){
    int X=(lb+ub)/2;
    int r=X+1;

    bool aok=false;
    rep(i,D)rep(j,D){
      bool ok=true;
      if(table0[i+r][j+r]-table0[i+r][j]-table0[i][j+r]+table0[i][j]>0)ok=false;
      if(table1[i+D][j+r]-table1[i+D][j]-table1[i+r][j+r]+table1[i+r][j]>0)ok=false;
      if(table1[i+r][j+D]-table1[i][j+D]-table1[i+r][j+r]+table1[i][j+r]>0)ok=false;
      if(table2[i+D][j+D]-table2[i+r][j+D]-table2[i+D][j+r]+table2[i+r][j+r]>0)ok=false;

      if(ok)aok=true;
    }
    if(aok) ub=X;
    else lb=X;
  }
  printf("%d\n", D*M+ub);

  return 0;
}


Measured memory_bytes: 66944