akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

#define INFL (1LL << 60)

using namespace std;

typedef long long ll;

int main() {
    ll x, y, z, k;
    scanf("%lld%lld%lld%lld", &x, &y, &z, &k);
    vector<ll> a(x + 1), b(y + 1), c(z + 1), abc;
    abc.reserve(k);
    a.at(0) = (b.at(0) = (c.at(0) = INFL));
    for (ll i = 1; i <= x; ++i) scanf("%lld", a.begin() + i);
    for (ll i = 1; i <= y; ++i) scanf("%lld", b.begin() + i);
    for (ll i = 1; i <= z; ++i) scanf("%lld", c.begin() + i);
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    for (ll i = 1; i <= x; ++i) for (ll j = 1; j <= y; ++j) for (ll h = 1; i * j * h <= k && h <= z; ++h) abc.push_back(a.at(i) + b.at(j) + c.at(h));
    sort(abc.begin(), abc.end(), greater<ll>());
    for (ll i = 0; i < k; ++i) printf("%lld\n", abc.at(i));
    return 0;
}


Measured memory_bytes: 2216
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        Edge[] edges = new Edge[E];
        for(int i = 0; i < E; i++){
            edges[i] = new Edge(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }
        
        System.out.println(kruskal(V, edges));
    }
    
    static int kruskal(int V, Edge[] edges){
        
        Arrays.sort(edges);
        UnionFind uf = new UnionFind(V);
        int totalCost = 0;
        for (Edge e : edges) {
            if (!uf.same(e.s, e.t)) {
                uf.unite(e.s, e.t);
                totalCost += e.w;
            }
        }
        return totalCost;
    }
    
    static class Edge implements Comparable<Edge>{
        int s;
        int t;
        int w;
        
        public Edge(int s, int t, int w) {
            this.s = s;
            this.t = t;
            this.w = w;
        }
        
        @Override
        public int compareTo(Edge e) {
            return this.w - e.w;
        }
    }
    
    static class UnionFind {
        int[] parent;
        int[] rank;
        
        public UnionFind(int n) {
            parent = new int[n];
            rank = new int[n];
            for(int i = 0; i < n; i++){
                parent[i] = i;
            }
        }
        int root(int x){
            if(parent[x] == x){
                return x;
            }else{
                return parent[x] = root(parent[x]);
            }
        }
        void unite(int x, int y){
            x = root(x);
            y = root(y);
            if(x == y) return;

            if(rank[x] < rank[y]){
                parent[x] = y;
            }else{
                parent[y] = x;
                if(rank[x] == rank[y]){
                    rank[x]++;
                }
            }
        }
        boolean same(int x, int y){
            return root(x) == root(y);
        }
    }
}


Measured memory_bytes: 74664
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << " " << max(A + B - N, 0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int isPrime(int);

int main() {

  int *p;
  int i;
  int n;
  int count = 0;

  scanf("%d",&n);
  
  p = (int *)malloc(n * sizeof(int)); //メモリ領域の確保

  for (i=0; i<n; i++)
    scanf("%d", &p[i]);
  if(n>10000 || n<1) return 0;

      /* 素数の判定 */
  for(i=0; i<n; i++) {
    count+=isPrime(p[i]);
  }

  printf("%d\n",count);
  
  return 0;

}
  
 int isPrime(int num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数除外

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

ll n, m;
vll a;

bool check(ll x) {
	ll sum = 0;
	rep(i, n) {
		ll b = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
		sum += n - b;
	}
	if(sum >= m) return true;
	else return false;
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> n >> m;
	a = vll(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());

	ll ok = 2 * a[0];
	ll ng = 2 * a[n - 1] + 1;
	while(ng - ok > 1) {
		ll mid = (ok + ng) / 2;
		if(check(mid)) ok = mid;
		else ng = mid;
	}

	vll sa(n + 1);
	rep(i, n) sa[i + 1] = sa[i] + a[i];
	ll ans = 0;
	ll cnt = 0;
	rep(i, n) {
		ll b = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
		ans += sa[n] - sa[b] + a[i] * (n - b);
		cnt += n - b;
	}
	if(cnt > m) ans -= ok * (cnt - m);
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1e5+100;
 
int n,m;
int a[N],b[N],ans;
bool ok1=false,ok2=false;
 
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];b[i]=a[i];
		if(a[i]>=0) ok1=true;
		if(a[i]<=0) ok2=true;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if(ok1&&ok2){
		for(int i=2;i<=n-1;i++){
			if(b[i]>0) b[1]-=b[i];
		}
		b[n]-=b[1];
		for(int i=2;i<=n-1;i++){
			if(b[i]<=0) b[n]-=b[i];
		}
		cout<<b[n]<<endl;
		for(int i=2;i<=n-1;i++){
			if(a[i]>0){
				cout<<a[1]<<" "<<a[i]<<endl;
				a[1]-=a[i];
			}
		}
		cout<<a[n]<<" "<<a[1]<<endl;
		a[n]-=a[1];
		for(int i=2;i<=n-1;i++){
			if(a[i]<=0) {
				cout<<a[n]<<" "<<a[i]<<endl;
				a[n]-=a[i];
			}
		}
		return 0;
	}
	if(ok1){
		b[1]-=b[n];
		for(int i=2;i<=n-2;i++) b[1]-=b[i];
		b[n-1]-=b[1];
		cout<<b[n-1]<<endl;
		cout<<a[1]<<" "<<a[n]<<endl;
		a[1]-=a[n];
		for(int i=2;i<=n-2;i++) cout<<a[1]<<" "<<a[i]<<endl,a[1]-=a[i];
		cout<<a[n-1]<<" "<<a[1];
		return 0;
	}
	if(ok2)
	{
		b[n]-=b[1];
		for(int i=2;i<n;i++) b[n]-=b[i];
		cout<<b[n]<<endl;
		cout<<a[n]<<" "<<a[1]<<endl;
		a[n]-=a[1];
		for(int i=2;i<n;i++) cout<<a[n]<<" "<<a[i]<<endl,a[n]-=a[i];
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second

const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
typedef pair<P,P> L;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

typedef vector<P> G;
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

bool isIntersectSP(L s, P p) {
  return abs(s.F-p)+abs(s.S-p)-abs(s.S-s.F) < EPS;
}

vector<P> getIntersectCS(C c, L s){
  vector<P> res;
  P h = proj(c.p, s);
  double d = abs(c.p - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isIntersectSP(s,h)) res.push_back(h);
  }
  else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isIntersectSP(s, h+v)) res.push_back(h+v);
    if(isIntersectSP(s,h-v)) res.push_back(h-v);
  }
  return res;
}

int main() {
  int n;
  while(cin >> n && n) {
    vector<C> c;
    rep(i,n) {
      double x,y,r;
      cin >> x >> y >> r;
      c.pb(C(P(x,y),r));
    }
    int m;
    cin >> m;
    rep(j,m) {
      L l;
      double x1,x2,y1,y2;
      cin >> x1 >> y1 >> x2 >> y2;
      l.F.real(x1);
      l.F.imag(y1);
      l.S.real(x2);
      l.S.imag(y2);
      int cnt=0;
      rep(i,n) {
	vector<P> v=getIntersectCS(c[i],l);
	cnt+=v.size();
      }
      if(!cnt) pr("Danger");
      else pr("Safe");
    }
  }
  return 0;
}


Measured memory_bytes: 1248
#include <iostream>

int main() {
  int n, i;
  std::cin >> n;
  
  long ans = 0;
  for (i = 1; i <= n; i++) {
  	if ((i % 3 != 0) && (i % 5 != 0)) {
  		ans += i;
  	}
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 3636
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        j=1
        while 1:
            j+=1
            if i*j>max:
                break
            dp[i*j]=True
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        dp[a[i]]=True
cnt=0
for i in a:
    if dp[i]==False:
        cnt+=1

print(cnt)



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

template <typename T> void swap(T &a, T &b) {
	T t = a;
	a = b;
	b = t;
}

template <typename T> void reverse(T *a, int len) {
	for (int i = (len - 1) / 2; i >= 0; --i) {
		swap(a[i], a[len - i - 1]);
	}
}

int main() {
	char seq[22];
	scanf("%20s", seq);

	reverse(seq, (int)strnlen(seq, 22));

	puts(seq);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e9;

signed main()
{
    string s; cin>>s;
    int ans=INF;
    for(char c='a';c<='z';c++){
        s+=c;
        int Max=0;
        REP(i,SZ(s)){
            int x;
            for(int j=i;j<SZ(s);j++){
                if(s[j]==c){
                    x=j-i;
                    break;
                }
            }
            Max=max(Max,x);
        }
        ans=min(ans,Max);
        s.pop_back();
    }
    cout<<ans<<endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool ans = false;
    for (char i : s) {
        if (i == '7') ans = true;
    }
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		System.out.println(num + num * num + num * num * num);
	}
}


Measured memory_bytes: 35384
import java.io.*;
import java.util.*;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                int lt = i * j;
                int rb = (n - i) * (m - j);
                if (lt + rb == k) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 23252
// https://atcoder.jp/contests/abc131/tasks/abc131_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

//方針：（Cで割り切れる数）+（Dで割り切れる数） - CとDの最小公倍数で割り切れる数
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll lcm_a = lcm(c, d);
    ll ans1 = b / c + b / d - b / lcm_a;
    ll ans2 = (a - 1) / c + (a - 1) / d - (a - 1) / lcm_a;

    cout << (b - a + 1) - (ans1 - ans2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector<int> BigDecimal;
const int digit = 10010;

BigDecimal div(ll x){
  ll now = 1LL;
  BigDecimal res;
  for(int i=0;i<digit;i++){
    res.push_back(now/x);
    now %= x;
    now *= 10;
  }
  return res;
}

void print(BigDecimal b, int len){
  cout << b[0] << ".";
  for(int i=1;i<=len;i++)cout << b[i];
  cout << endl;
}

int main(){
  int n,k,m,r;
  while(cin >> n >> k >> m >> r,n){
    BigDecimal res = div(n);
    if(m==1){
      for(ll i=1;i<n;i++){
	BigDecimal tmp = div(i*n);
	for(int j=0;j<digit;j++)res[j] += tmp[j];
      }
      for(int j=digit-1;j>0;j--){
	res[j-1] += res[j]/10;
	res[j] %= 10;
      }
    }

    print(res,r);
  }
}

    

Measured memory_bytes: 1356
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll ans[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ll temp=j-i;
            temp=min(temp,abs(x-i)+1+abs(y-j));
            temp=min(temp,abs(y-i)+1+abs(x-j));
            ans[temp]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<ans[i]<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pllint a, pllint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	YES(a - b == b - c);
	return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	if (k == 0) {
		cout << ll(n) * ll(n) << endl;
		return 0;
	}
	FOR(i, 1, n + 1) {
		ans += (n / i * max(0, i - k)) + max(0, n%i - k+1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge {
    int s, t, w;

    bool operator< (const edge& other) const {
        if (w != other.w) {
            return w < other.w;
        } else if (s != other.s) {
            return s < other.s;
        } else {
            return t < other.t;
        }
    }
};

class union_find{
    int n_; 
    vector<int> par, rank, size;
    public:
    union_find(int n): n_{n} {
        par.resize(n_);
        rank.resize(n_);
        size.resize(n_);

        REP(i, n_){
            par[i] = i;
            rank[i] = 1;
            size[i] = 1;
        }
    } 

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] > rank[y]){
            par[y] = x;
            size[x] += size[y];
        } else {
            par[x] = y;
            size[y] += size[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    int find(int x) {
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
};


int main() {
    int v, e; cin >> v >> e;
    vector<edge> edges(e);

    REP(i, e) {
        int s, t, w; cin >> s >> t >> w;
        edges[i] = {s, t, w};
    }

    // kruscal
    union_find uf(v);
    sort(edges.begin(), edges.end());

    int ans = 0;

    for (const edge& e : edges) {
        if (!uf.same(e.s, e.t)) {
            ans += e.w;
            uf.unite(e.s, e.t);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4120
def main():
    N,T  = map(int, input().split()) 
    A = list(map(int, input().split())) 
    cnt  = 0
    temp = 0

    for i in range(N):
        if temp > A[i]:
            cnt += T-temp+A[i]
        else:
            cnt += T
        temp = A[i] + T
    print(cnt)




if __name__ == '__main__':
    main()


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

int main(){
	int N;
	cin >> N;
	ll A[N], B[N], C[N], s = 0;
	for(int i=0; i<N; i++){
		cin >> A[i] >> B[i];
		C[i] = A[i] + B[i];
		s += B[i];
	}
	sort(C, C+N);
	ll ans = 0;
	for(int i=0; i<N; i++){
		if(i%2 == 0){
			ans += C[N-i-1];
		}
	}
	cout << ans - s << endl;
	return 0;
}

Measured memory_bytes: 2560
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

start_cooking
{
    main_ingredient_added
    //start with your recipe
    int n, a, b;
    cin>>n>>a>>b;
    if(a%n == 0 || b%n == 0)
        cout<<"OK";
    else if(a/n == b/n)
        cout<<"NG";
    else
        cout<<"OK";
    food_is_ready
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n;
int a[N];

int main()
{
    cin >> n;
    bool all_even = true;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] % 2) all_even = false;
    }

    int res = 0;
    while(all_even)
    {
        for(int i = 0; i < n; i++)
        {
            a[i] /= 2;
            if(a[i] % 2) all_even = false;
        }
        res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

class Program
{

    public void Slove()
    {
        string[] inputs = Console.ReadLine().Split();
        int ab = int.Parse(inputs[0]);
        int bc = int.Parse(inputs[1]);
        Console.WriteLine(ab * bc / 2);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],b[n];
  int i,j,s;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    b[i]=0;
  }
  b[1]=max(a[0],a[1])-min(a[0],a[1]);
  b[2]=min(max(a[0],a[2])-min(a[0],a[2]),b[1]+max(a[2],a[1])-min(a[2],a[1]));
  for(i=3;i<n;i++)
    b[i]=min(b[i-1]+max(a[i],a[i-1])-min(a[i],a[i-1]),b[i-2]+max(a[i],a[i-2])-min(a[i],a[i-2]));
  cout<<b[n-1];
}


Measured memory_bytes: 1024
from itertools import groupby
from functools import reduce

MOD = 1000000007

def mod_pow(x, k):
    ret = 1
    while k > 0:
        if k & 1:
            ret *= x
            ret %= MOD
        k >>= 1
        x *= x
        x %= MOD
    return ret


def max_t():
    i, t_max = 0, 0
    for j, v in enumerate(t):
        if v < t_max:
            print(0)
            quit(0)
        if v > t_max:
            t_max = v
            i = j
    return i, t_max


def validate_a(i, t_max):
    for v in a[:i + 1]:
        if v != t_max:
            print(0)
            quit(0)
    for v in a[i + 1:]:
        if v > t_max:
            print(0)
            quit(0)


if __name__ == '__main__':
    n = int(input())
    t = [int(s) for s in input().split()]
    a = [int(s) for s in input().split()]
    i, t_max = max_t()
    validate_a(i, t_max)

    highests = [min(x, y) for x, y in zip(a, t)]
    print(reduce(lambda x, y: x * y % MOD, (mod_pow(v, ((length - 1) if v < t_max else max(length - 2, 0))) for v, length in ((v, len(list(l))) for v, l in groupby(highests)))))


Measured memory_bytes: 19132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            String array[] = br.readLine().split("\\s+");
 
            System.out.printf("%d",Integer.parseInt(array[array.length-1]));
            for(int i = array.length-2; i >= 0; i--){
                System.out.printf(" %d", Integer.parseInt(array[i]));
            }
            System.out.printf("\n");
 
 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24692
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	private static boolean ispf = false;

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] systemInLine = br.readLine().split(" ");
		int provinceCount = Integer.parseInt(systemInLine[0]);
		int cityCount = Integer.parseInt(systemInLine[1]);
		pf("辖区总数:" + provinceCount + " 城市总数:" + cityCount);

		/**
		 * 所有的城市
		 */

		// 城市数组，0：省份，1：年份，2：输入顺序号，4：年份序号
		int[][] proviceCityArray = new int[cityCount][4];

		for (int i = 0; i < cityCount; i++) {
			systemInLine = br.readLine().split(" ");
			int provinceIndex = Integer.parseInt(systemInLine[0]);
			int cityCreateYear = Integer.parseInt(systemInLine[1]);
			proviceCityArray[i][0] = provinceIndex;
			proviceCityArray[i][1] = cityCreateYear;
			proviceCityArray[i][2] = i + 1;
		}
		br.close();

		/**
		 * 这次排序后辖区和年份已经排序了
		 */

		Arrays.sort(proviceCityArray, (o1, o2) -> (o1[0] == o2[0]) ? (o1[1] - o2[1]) : (o1[0] - o2[0]));

		for (int i = 0; i < proviceCityArray.length; i++) {
			if (i == 0) {
				proviceCityArray[i][3] = 1;
			} else {
				if ((proviceCityArray[i][0] == proviceCityArray[i - 1][0])) {// 于上一次比较
					proviceCityArray[i][3] = proviceCityArray[i - 1][3] + 1;
				} else {
					proviceCityArray[i][3] = 1;
				}
			}
		}

		/**
		 * 再次排序拍会回来
		 */
		Arrays.sort(proviceCityArray, (o1, o2) -> o1[2] - o2[2]);
		String[] padding = new String[] { "", "0", "00", "000", "0000", "00000" };
		for (int i = 0; i < proviceCityArray.length; i++) {
			// System.out.println(String.format("%06d",
			// proviceCityArray[i][0])+String.format("%06d", proviceCityArray[i][3]));
			System.out.println(padding[getPadingIndex(proviceCityArray[i][0])] + proviceCityArray[i][0]
					+ padding[getPadingIndex(proviceCityArray[i][3])] + proviceCityArray[i][3]);
		}

	}

	public static void pf(String s) {
		if (ispf) {
			System.out.println(s);
		}
	}

	private static int getPadingIndex(int n) {
	        if (n < 10) {
	        	return 5;
        	}else if (n < 100) {
        		return 4;
        	}else if (n < 1000) {
        		return 3;
        	}else if (n < 10000) {
        		return 2;
        	}else if (n < 100000) { 
        		return 1;
        	}else {
        		return 0;
        	}
	    }
}


Measured memory_bytes: 78660
using System;
using System.Linq;

    class Program4
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var md = new Modulo(2000);
            for (int i = 1; i <= input[1]; i++)
            {
                if (i - 1 > input[0] - input[1])
                {
                    Console.WriteLine("0");
                    continue;
                }
                //i個青いボール列　それぞれに何個割り当てるか i-1個のセパレーション i+1個の枠に赤を入れる
                var blue = md.DuplicateCombination(i, input[1] - i);
                var red = md.DuplicateCombination(i + 1, input[0] - input[1] - (i - 1));
                var ans = md.Multiply(blue, red);
                Console.WriteLine(ans);
            }
        }
    }

    class Modulo
    {
        private readonly int M = 1000000007;
        private readonly int[] m_facs;

        public Modulo(int n, int m = -1)
        {
            m_facs = new int[n + 1];
            m_facs[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                m_facs[i] = Multiply(m_facs[i - 1], i);
            }
            if (m != -1)
                M = m;
        }

        public int Multiply(int a, int b)
        {
            return (int)(Math.BigMul(a, b) % M);
        }

        public int Factorial(int n)
        {
            return m_facs[n];
        }

        public int Pow(int a, int m)
        {
            switch (m)
            {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    int p1 = Pow(a, m / 2);
                    int p2 = Multiply(p1, p1);
                    return ((m % 2) == 0) ? p2 : Multiply(p2, a);
            }
        }

        public int Divide(int a, int b)
        {
            return Multiply(a, Pow(b, M - 2));
        }

        public int DuplicateCombination(int n, int r)
        {
            n = n + r - 1;
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            int res = Factorial(n);
            res = Divide(res, Factorial(r));
            res = Divide(res, Factorial(n - r));
            return res;
        }
    }

Measured memory_bytes: 13380
import sys

for s in sys.stdin:
    xa,ya,xb,yb,xc,yc,xd,yd = map(float,s.split())
    if abs( (xb-xa)*(xd-xc)+(yb-ya)*(yd-yc) )< 1e-10: print "YES"
    else: print "NO"

Measured memory_bytes: 4220
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: f64,
        h: f64,
        x: f64,
        y: f64
    };
    let ans = w * h / 2.0;
    if w == x || h == y {
        println!("{} {}", ans, 0);
    } else if x == w / 2.0 && y == h / 2.0 {
        println!("{} {}", ans, 1);
    } else {
        println!("{} {}", ans, 0);
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				while (s.Length != 1)
				{
					var n = s.Select(c => c - '0').ToArray();
					s = "";
					for (int i = 0; i < n.Length - 1; i++)
					{
						s += (n[i] + n[i + 1]).ToString().Last().ToString();
					}
				}
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
using namespace std;
using pii = pair<int, int>;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int x;
  cin >> x;
  cout << (x == 7 || x == 5 || x == 3 ? "YES" : "NO") << endl;

  return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (x >= 30){
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}


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

#define rep(i, n)		reps (i, 0, n)
#define reps(i, f, n)	for (int i = f; i < (int)n; ++i)
#define sz(c)           (int)(c).size()

int main()
{
    int n;
    string str[11];
    int same[11][11];

    while (cin >> n, n) {
        rep (i, n) cin >> str[i];

        sort(str, str + n);
        n = unique(str, str + n) - str;
        //cout << "n: " << n << endl;

        vector<int> part(n);
        rep (i, n) rep (j, i) {
            int a, b;
            if (sz(str[i]) < sz(str[j])) a = j, b = i;
            else if (sz(str[i]) == sz(str[j])) continue;
            else a = i, b = j;
            rep (k, sz(str[a]) - sz(str[b]) + 1) {
                if (str[a].substr(k, sz(str[b])) == str[b])
                    part[b] = 1;
            }
        }

        vector<int> perm;
        rep (i, n) if (!part[i]) perm.push_back(i);

        fill_n(*same, 11 * 11, 0);
        rep (i, n) rep (j, n) {
            int m = min(sz(str[i]), sz(str[j]));
            reps (k, 1, m) {
                if (str[i].substr(sz(str[i]) - k, k) == str[j].substr(0, k))
                    same[i][j] = k;
            }
        }

        int best = -1;
        string ans;
        int z = sz(perm);

        do {
            int t = 0;
            reps (i, 1, z) t += same[perm[i-1]][perm[i]];
            if (t > best) {
                best = t;
                ans = str[perm[0]];
                reps (i, 1, z) ans += str[perm[i]].substr(same[perm[i-1]][perm[i]]);
            } else if (t == best) {
                string tmp;
                tmp = str[perm[0]];
                reps (i, 1, z) tmp += str[perm[i]].substr(same[perm[i-1]][perm[i]]);
                ans = min(ans, tmp);
            }
        } while (next_permutation(perm.begin(), perm.end()));

        cout << ans << endl;
    }
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dob;
typedef pair<int,int> par;
const int N=200020;
char s[N];
int to[N],l[30],r[30],a[N],n;
void add(int x,int k){
	for (;x<=n+10;x+=x&-x) a[x]+=k;
}
int ask(int x){
	int y=0;
	for (;x;x-=x&-x) y+=a[x];
	return y;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	LL ans=0,flag=0;
	rep(i,1,n){
		int k=s[i]-'a';
		if (!l[k]) l[k]=i;
		r[k]=i;
	}
	rep(i,0,25){
		if (!l[i]) continue;
		while (l[i]<=r[i]){
			to[l[i]]=r[i];
			to[r[i]]=l[i];
			while (++l[i]<=n){
				if (s[l[i]]=='a'+i) break;
			}
			while (--r[i]>=1){
				if (s[r[i]]=='a'+i) break;
			}
		}
	}
	rep(i,1,n) 
		ans+=ask(to[i]),add(to[i],1),flag+=to[i]==i;
	printf("%lld\n",flag>1?-1:ans/2);
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int m;
    cin>>m;
    vector<int> v(m+1);
    for(int i=1;i<=m;i++) cin>>v[i];
    vector<int> b(m+1,0);
    //for(int i=1;i<=m;i++) cout<<v[i]<<" ";
    //cout<<endl;
    int cnt=0;
    for(int i = m;i>0;i--){
        //cout<<endl;
        //cout<<i<<"start"<<endl;
        int sum = 0;
        for(int j=2*i;j<=m;j+=i){
            //if(j>m) break;
            if(b[j]==1) sum+= 1;
        }
        if(v[i]==0){
            //cout<<"0"<<endl;
            if(sum%2==0) b[i]=0;
            else{
                b[i]=1;
                cnt++;
            }
        }
        else{
            //cout<<"1"<<endl;
            if(sum%2==0){
                b[i]=1;
                cnt++;
            }
            else b[i]=0;
        }
        //cout<<sum<<endl;
        //cout<<"v["<<i<<"]"<<"="<<v[i]<<endl;
    }
    
    if(cnt==0) cout<<0<<endl;
    else{
        cout<<cnt<<endl;
        for(int i=1;i<=m;i++){
            if(b[i]==1) cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <set>
#include <tuple>

using namespace std;

using ll = long long;

bool in(int d, int D)
{
    return (0 <= d && d < D);
}

int main()
{
    ll A, B, C, N;
    cin >> A >> B >> C >> N;
    vector<int> x(N), y(N), z(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }
    
    constexpr int dx[] = {-1, +0, +1, +0, +0, +0};
    constexpr int dy[] = {+0, -1, +0, +1, +0, +0};
    constexpr int dz[] = {+0, +0, +0, +0, -1, +1};
    
    set<tuple<int, int, int>> er;
    ll res = 2 * (A * B + B * C + C * A);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 6; j++) {
            int nx = x[i] + dx[j];
            int ny = y[i] + dy[j];
            int nz = z[i] + dz[j];

            if (!in(nx, A) || !in(ny, B) || !in(nz, C)) {
                res--;
                continue;
            }

            if (er.count(make_tuple(nx, ny, nz)) > 0) {
                res--;
            } else {
                res++;
            }            
        }
        er.insert(make_tuple(x[i], y[i], z[i]));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3152
#  --*-coding:utf-8-*--

MAX = 1000000
H,W = map(int, input().split())


S0 = '.' + '#'*(W-1)
X0 = [MAX]*W
X0[0] = 0

for _ in range(H):
    S = input()
    X = [None]*W

    for i in range(W):
        sc1 = MAX
        sc2 = MAX

        if i > 0:
            sc1 = X[i-1] + (1 if S[i-1] == '.' and S[i] == '#' else 0)

        sc2 = X0[i] + (1 if S0[i] == '.' and S[i] == '#' else 0)

        X[i] = min(sc1, sc2)

    X0 = X
    S0 = S

print(X0[-1])



Measured memory_bytes: 3064
package main

import(
      "fmt"
      "math"
)

func main(){
  var n,t,a,b int
  ans := math.MaxInt64
  fmt.Scan(&n,&t)

  for i := 0; i < n; i++ {
    fmt.Scan(&a,&b)
    if b <= t {
      ans = min(ans, a)
    }
  }

  if ans == math.MaxInt64 {
    fmt.Println("TLE")
  }else{
    fmt.Println(ans)
  }
}

func min(a, b int) int{
  if a < b {
    return a
  }
  return b
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#define mod 1000000007
#define int long long int
int answer=1000000000000000000;
void subset(int arr[],vector<int> &v,int initial,int final,int mat[15][15],int n,int m,int x)
{
	if(initial>final)
	{
		int count[m+1]={0};
		int here=0;
		int j;
		if(v.size()!=0)
		{
			for(int p:v)
			{
				here+=arr[p];
				for(j=1;j<=m;j++)
				{
					count[j]+=mat[p][j];
				}
				
			}
		}
		bool result=true;
		for(j=1;j<=m;j++)
		{
			if(count[j]<x)
			{
				result=false;
				break;
			}
		}
		if(result)
		{
			answer=min(answer,here);
		}
	}
	else
	{
		v.push_back(initial);
		subset(arr,v,initial+1,final,mat,n,m,x);
		v.pop_back();
		subset(arr,v,initial+1,final,mat,n,m,x);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m,x;
	cin>>n>>m>>x;
	int mat[15][15];
	int i,j;
	int arr[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>arr[i];
		for(j=1;j<=m;j++)
		{
			cin>>mat[i][j];
		}
	}
	vector<int> v;
	subset(arr,v,1,n,mat,n,m,x);
	if(answer==1000000000000000000)
	  cout<<-1<<endl;
	else
	  cout<<answer<<endl;
}


Measured memory_bytes: 3652
a = int(input())
 
sum=0
i=0
 
while i<len(str(a)):
	if i==int(len(str(a)))-1:
		sum=sum+a-10**i+1
	else:
		sum=sum+10**(i+1)-10**(i)
	#print(i,sum)
	i=i+2
print(sum)

Measured memory_bytes: 3060
abc = sorted(list(map(int, input().split())))

ans = 0
if (abc[1]-abc[0])%2 == 1:
  ans += 1
  abc[1] += 1
  abc[2] += 1

ans += (abc[1]-abc[0])//2
abc[0] += abc[1]-abc[0]
ans += abc[2]-abc[1]
print(ans)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,C;
int ans_buf = 0;
int ans = 0;
bool flg = false;
int cnt =0;
cin >> N >> M >> C;
vector<vector<int>> A(N,vector<int>(M));
vector<int> B(M);

for(int i = 0;i<M;i++){
cin >> B.at(i);
}

for(int j = 0;j<N;j++){
for(int k = 0;k<M;k++){
	cin>>A.at(j).at(k);
	}
}

for(int l = 0;l<N;l++){
for(int m = 0;m<M;m++){
	ans_buf += B.at(m)*A.at(l).at(m);
	}
	
	ans = ans_buf + C;
    ans_buf = 0;
	if(ans > 0){
    cnt++;
	//flg = true;
	//break;
	}
}

//if(flg){
cout << cnt << endl;
//}else{
//cout << ans<< endl;
//}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    int res = 0;
    int n;
    int[] a;
    int[] work = new int[3];
    void Run()
    {
        var sc = new Scanner();
        a = new int[3];
        for (int i = 0; i < 3; i++) a[i] = sc.NextInt();
        n = sc.NextInt();
        Dfs(0);
        Console.WriteLine(res);
    }

    void Dfs(int c)
    {
        if (c == 2)
        {
            int sum = 0;
            for (int j = 0; j < 2; j++) sum += a[j] * work[j];
            if (n - sum >= 0 && (n - sum) % a[2] == 0) res++;
        }
        else
        {
            for (int i = 0; a[c] * i <= n; i++)
            {
                work[c] = i;
                Dfs(c + 1);
            }
        }
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140