akhauriyash/Code-Regression huggingface dataset:
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void) {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans=0;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int sum=500*i+100*j+50*k;
                if(sum==x){
                    ans++;
                }
            }
        }
    }

    cout<<ans<<endl;



}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月21日 星期日 20时58分55秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;
int t[N],x[N],y[N];

void solve(){

	int n;
	scanf("%d",&n);
	bool flag=1;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",t+i,x+i,y+i);
		int tmp=t[i]-t[i-1];
		int d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(tmp>=d && (tmp-d)%2==0) continue;
		flag=0;break;
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


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

int main() {
    int N,ans=0,buf=0;
    cin >> N;
    int h[N];
    cin >> h[0];
  	for(int i=1;i<N;i++){
      cin >> h[i];
      if(h[i-1]>=h[i])buf++;
      else{
        if(ans<buf) ans = buf;
        buf=0;
      }
	}
    if(ans<buf) ans = buf;
	cout << ans << endl;
}

Measured memory_bytes: 4000
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
#define mall (nxd*)mallxc(sizexf(nxd))
using namespace std;
typedef long long ll;
ll mod=1000000000+7;
ll dp[1000006][4]={0};
int main(void)
{
	ll n;
	cin>>n;
	dp[1][0]=8;
	dp[1][2]=dp[1][1]=1;
	dp[1][3]=0;
	for(ll i=2;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*8%mod;
		dp[i][1]=dp[i-1][0]+dp[i-1][1]*9;
		dp[i][2]=dp[i-1][0]+dp[i-1][2]*9;
		dp[i][3]=dp[i-1][1]+dp[i-1][2]+dp[i-1][3]*10;
		dp[i][1]%=mod;
		dp[i][2]%=mod;
		dp[i][3]%=mod;
//		for(ll j=0;j<4;j++) printf("%lld ",dp[i][j]);printf("\n");
//		printf("%lld\n",dp[i][3]+dp[i][1]+dp[i][2]+dp[i][0]);
	}
	cout<<dp[n][3];
}

Measured memory_bytes: 34764
S = input()

halfLen = len(S)//2

if halfLen % 2 == 1 and S[0:halfLen//2] == S[halfLen//2+1:halfLen][::-1] and S[halfLen+1:halfLen+1+halfLen//2] == S[len(S)-halfLen//2:len(S)][::-1] and S[0:halfLen] == S[halfLen+1:len(S)][::-1]:
  print('Yes')
elif halfLen % 2 == 0 and S[0:halfLen//2] == S[halfLen//2:halfLen][::-1] and S[halfLen+1:halfLen+1+halfLen//2] == S[len(S)-halfLen//2:len(S)][::-1] and S[0:halfLen] == S[halfLen+1:len(S)][::-1]:
  print('Yes')
else:
  print('No')

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

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

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  string s;
  cin >> s;
  int siz1 = s.size();
  string tmp = s.substr(0,(siz1-1)/2) , _tmp = s.substr(((siz1+3)/2)-1,siz1-(siz1+3)/2+1);
  int siz2 = tmp.size() , siz3 = _tmp.size();
  bool flag = true;
  rep(i,siz2){
    if(tmp[i]!=tmp[siz2-i-1]) flag = false;
  }
  rep(i,siz3){
    if(_tmp[i]!=_tmp[siz3-i-1]) flag = false;
  }
  rep(i,siz1){
    if(s[i]!=s[siz1-i-1]) flag = false;
  }
  if(flag) cout << "Yes";
  else cout << "No";
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 256
import sys
a,b,o,ab = 0,0,0,0
for line in sys.stdin.readlines():
  i,t = line.split(',')
  if t == 'A\n':
    a += 1
  if t == 'B\n':
    b += 1
  if t == 'O\n':
    o += 1
  if t == 'AB\n':
    ab += 1
print(a)
print(b)
print(ab)
print(o)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100], b[100];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	int ma = 0;
	inc(i, n) { b[a[i]]++; setmax(ma, a[i]); }
	
	bool f = true;
	int x = (ma + 1) / 2;
	
	inc1(i, ma) {
		if(i <  x && b[i] > 0) { f = false; }
		if(i == x && ma % 2 == 0 && b[i] != 1) { f = false; }
		if(i == x && ma % 2 != 0 && b[i] != 2) { f = false; }
		if(i >  x && b[i] < 2) { f = false; }
	}
	
	cout << (f ? "Possible" : "Impossible") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int k,s,x=0,i,j;
	scanf("%d %d",&k,&s);
	for(i=0;i<=k;i++){
		for(j=0;j<=k;j++){
			if(i+j<=s && i+j>=s-k)
				x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			final int n = sc.nextInt();
			while (sc.hasNext()) {
				int[] x = new int[3];
				x[0] = sc.nextInt();
				x[1] = sc.nextInt();
				x[2] = sc.nextInt();
				Arrays.sort(x);
				boolean isTriangle = (x[0] * x[0]) + (x[1] * x[1]) == (x[2] * x[2]);
				System.out.println(isTriangle ? "YES" : "NO");
			}
		}
	}
}

Measured memory_bytes: 33284
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        // 解説youtube後
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        // キー集合のID、バリュー鍵の値段
        Map<Integer, Integer> keyInfo = new TreeMap<>();
        for (int i = 0; i < m; i++) {
            int price = sc.nextInt();
            int keyNum = sc.nextInt();
            int keyInfoID = 0;
            for (int j = 0; j < keyNum; j++) {
                int openNo = sc.nextInt();
                openNo--; // 1-indexed;
                keyInfoID |= 1 << openNo;
            }

            // 集合が被った場合はコストが安い方を採用する
            if (price < keyInfo.getOrDefault(keyInfoID, Integer.MAX_VALUE)) {
                keyInfo.put(keyInfoID, price);
            }
        }

        // DP用意と初期化
        int[] dp = new int[1 << n]; // 2^n;
        int AMAX = 1001001001;
        for (int i = 0; i < dp.length; i++) {
            dp[i] = AMAX;
        }
        dp[0] = 0;

        for (int s = 0; s < 1 << n; s++) {
            for (Entry<Integer, Integer> ent : keyInfo.entrySet()) {
                int t = s | ent.getKey();
                int cost = dp[s] + ent.getValue();
                dp[t] = Math.min(cost, dp[t]);
            }
        }

        // 組み合わせが存在しない場合は-1
        int ans = dp[dp.length - 1];
        if (ans == AMAX) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


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


int main() {
    int N, a, b, left=-1e9, ans=0;
    cin >> N;
    vector<pair<int, int>> rob(N);
    for(int i=0; i<N; i++){
    	cin >> a >> b;
	rob[i].second=a-b;
	rob[i].first=a+b;
    }
    sort(rob.begin(), rob.end());

    for(int i=0; i<N; i++){
	if(left<=rob[i].second){
	    left=rob[i].first;
	    ans++;
	}
    }
    cout << ans << endl;
}




Measured memory_bytes: 1024
n = int(input())
A = sorted(map(int, input().split()))
U = A[-1]
line = [1]*(U+1)
ans = set()
depricated = set()
cnt = [0]*(U+1)
for a in A:
    if a in ans:
        depricated.add(a)
        continue
    if line[a]:
        ans.add(a)
        for p in range(2*a, U+1, a):
            line[p] = 0
print(len(ans-depricated))

Measured memory_bytes: 51236
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    int n;cin>>n;
    int j=2;
    int i=0;
    vector<int> prime(0);
    while(i<n){
        bool f=1;
        REP(k,2,sqrt(j)+1){
            if(j%5!=1)f=0;
            else if(j!=k&&j%k==0)f=0;
        }
        if(f){
            prime.push_back(j);
            i++;
        }
        j++;
    }
    rep(i,n-1)cout<<prime[i]<<' ';
    cout<<prime[n-1]<<endl;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 3005;

int n;

long double dp[N][N], p[N];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            //cout << dp[i][j] << " " << i << " " << j << "\n";
            dp[i + 1][j] += dp[i][j] * (1 - p[i + 1]);
            dp[i + 1][j + 1] += dp[i][j] * p[i + 1];
        }
    }
   long double sum = 0;
    for(int i = n / 2 + 1; i <= n; i++) {
        sum += dp[n][i];
        //cout << dp[n][i] << " " << i << "\n";
    }
    cout << fixed << setprecision(10) << sum;
}



Measured memory_bytes: 141184
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

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

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

const int _N = 200000;
int tree[_N+1];
int n,m,q;

/// BIT

void add(int i, int v){
	i++;
	while(i<=n){
		tree[i] += v;
		i+=i&-i;
	}
}
int sum(int i){
	i++;
	int s = 0;
	while(i>=1){
		s += tree[i];
		i-=i&-i;
	}
	return s;
}

///

// O(N log^2 N)

int main() {
	cin >> n >> m >> q;
	REP(i, n)add(i, 1);
	int having = 1; // living
	REP(i, m){
		int p;
		cin >> p;
		int f = n-i; // >= 1
		if(p%2)p = -p+f*101;
		p+=having;
		p %= f;
		if(!p) p = f;
		// binary search i-th person in circle
		int low=0, high=n - 1;
		while(low<high){
			int mid = (low + high) / 2;
			if(sum(mid)<p) low = mid + 1;
			else high = mid;
		}
		add(low, -1);
		having = p;
	}
	REP(i, q){
		int x;
		cin >> x;
		int s = sum(x);
		if(x > 0) s -= sum(x-1);
		cout << s << endl;
	}
}

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

int n, *fw[26];
char *s;

inline int lsb(int x) {
	return x & -x;
}
int fwSum(int ix, int x) {
	int r = 0;
	while(x) {
		r += fw[ix][x];
		x -= lsb(x);
	}
	return r;
}
void fwChange(int ix, int iy, int x) {
	int dx = x - (fwSum(ix, iy) - fwSum(ix, iy - 1));
	if(!dx)
		return;
	while(iy <= n) {
		fw[ix][iy] += dx;
		iy += lsb(iy);
	}
}

int main() {
	int q, i;
	scanf("%d", &n);
	s = malloc((n + 1)*sizeof(char));
	for(i = 0; i < 26; i++)
		fw[i] = calloc(n + 1, sizeof(int));
	scanf(" %s %d", s, &q);
	for(i = 0; i < n; i++)
		fwChange(s[i] - 'a', i + 1, 1);
	
	while(q--) {
		int f, a1;
		scanf("%d %d", &f, &a1);
		a1--;
		if(f == 1) {
			char a2;
			scanf(" %c", &a2);
			if(s[a1] == a2)
				continue;
			fwChange(s[a1] - 'a', a1 + 1, 0);
			fwChange((s[a1] = a2) - 'a', a1 + 1, 1);
		} else {
			int a2, r = 0;
			scanf("%d", &a2);
			for(i = 0; i < 26; i++)
				r += !!(fwSum(i, a2) - fwSum(i, a1));
			printf("%d\n", r);
		}
	}
	return 0;
}

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

int main() {
	vector<int>b;
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (n % 2 == i % 2) {
			b.push_back(a);
		}
		else {
			b.insert(b.begin(), a);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << b[i];
		if (i != n - 1) {
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3060
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here........
int main(){
ll n,k,cnt=0;
cin>>n>>k;
while(n--){
    ll x;
    cin>>x;
    if(x>=k){cnt++;}
}
cout<<cnt<<ses;
}

//Alhamdulillah


Measured memory_bytes: 256
#include <iostream>

using namespace std;//::stdを省略できる

int D,N,count;


int main()
{
 cin>> D ;
 cin>> N ;
 
 switch(D)
 {
 
 case 0:
 
 if(N!=100)
 {
 cout<<N<<endl;
 }
 else if(N==100)cout<<101<<endl;
 
 break;
 
 case 1:
  
 if(N!=100)
 {
 cout<<100*N<<endl;
 }
 else if(N==100)cout<<100*(N+1)<<endl;
 
 
 
 break;
 
 case 2:
 
 if(N!=100)
 {
 cout<<100*100*N<<endl;
 }
 else if(N==100)cout<<100*100*(N+1)<<endl;
 
 break;
 
 
 }
    
}

Measured memory_bytes: 256
N = int(input())
S = str(input())

alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
out=''
for i in range(len(S)):
    for j in range(len(alphabet)):
        if S[i]==alphabet[j]:
            out= out + str(alphabet[(j+N)%(len(alphabet))])
print(out)

Measured memory_bytes: 41564
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val cellCount: Int = sc.nextInt
  val cellList = List.fill(cellCount)(sc.nextInt)

  val ans = go(cellList.head, cellList.tail)

  def go(curr: Int, remains: List[Int], maxLength: Int = 0, currentLength: Int = 0): Int = {
    remains match {
      case Nil => Math.max(maxLength, currentLength)
      case h::t if (curr >= h) => go(h, t, maxLength, currentLength + 1)
      case h::t => go(h, t, Math.max(maxLength, currentLength))
    }
  }

  println(ans)
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int a[10005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	rep(x, 1, 101) rep(y, 1, 101) rep(z, 1, 101)
		if (x * x + y * y + z * z + x * y + y * z + z * x <= 10000)
			a[x * x + y * y + z * z + x * y + y * z + z * x]++;

	int n; read(n);
	rep(i, 1, n + 1) write(a[i]);
}


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

using namespace std;

typedef long long int lli;

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

    int w, h, x, y;
    
    cin >> w >> h >> x >> y;
    printf("%.10lf %d", (double)w*h/2., (w==2*x && h==2*y));

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
    }
    if n*a < b {
        println!("{}", n*a);
    }else{
        println!("{}", b);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N, M;
	cin >> N >> M;

	vector<ll> v(M);
	for (ll i = 0; i < M; i++)
	{
		cin >> v[i];
	}

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

	ll min = 0;
	vector<ll> d(M - 1); // 余ると0になるので注意

	for (ll i = 0; i < M - 1; i++)
	{
		d[i] = abs(v[i] - v[i + 1]);
	}
	sort(d.begin(), d.end());


	for (ll i = 0; i < M - N; i++)
	{
		min += d[i];
	}

	cout << min << endl;
}

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

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

  string S;
  cin>>S;

  int N=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='x') N++;
  }
  
  cout<<(N>=8? "NO":"YES")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A,B;
string s;
bool isValid(){
  for(int i=0;i<s.size();++i){
    if(s[i]!=' '&&s[i]==s[(i+1)%s.size()])return false;
  }
  return true;
}
main(){
  cin>>A>>B;
  s="                ";
  for(int i=0;i<A+B;++i){
    s[i]=i<A?'A':'B';
  }
  int n_count=0,n_valid=0;
  do{
    ++n_count;
    // cout<<s<<endl;
    if(isValid()){
      ++n_valid;
      // cout<<s<<endl;
    }
  }while(next_permutation(begin(s),end(s)));
  // printf("n_count=%d\n",n_count);
  printf(n_valid?"Yay!\n":":(\n");
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

void sort(int *,int );

int main()
{
	int n;
	int a[MAX];
	double sum;

	scanf("%d",&n);

	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);

	sort(a,n);

	sum=a[0];

	for(int i=1; i<n; i++)
		sum=(sum+a[i])/2;

	printf("%lf\n",sum);

	return 0;
}

void sort(int *a,int n)
{
	int i, j;
	double temp;

	for(i=0; i<n-1; i++){
		for(j=i+1; j<n; j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
}

Measured memory_bytes: 128
n,m,c=input().split(" ")
cnt=0
n,m,c=int(n),int(m),int(c)
lst=[]
for i in range(n+1):
  lst.append(input().split(" "))

for i in range(1,n+1):
  ans=c
  for j in range(m):
    ans+=int(lst[i][j])*int(lst[0][j])
  if ans>0:
    cnt+=1
print(cnt)

Measured memory_bytes: 9096
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            Long A = Long.valueOf(args.get(0).split(" ")[0]) - 1L;
            Long B = Long.valueOf(args.get(0).split(" ")[1]);
            Long C = Long.valueOf(args.get(0).split(" ")[2]);
            Long D = Long.valueOf(args.get(0).split(" ")[3]);
            Long ansA = A - ((A / C) + (A / D) - (A / ((C * D) / gcd(C, D))));
            Long ansB = B - ((B / C) + (B / D) - (B / ((C * D) / gcd(C, D))));
            System.out.println(ansB - ansA);
        };
    }

    private static Long gcd(long x, long y) {
        if (x < y) return gcd(y, x);
        if (x % y > 0) return gcd(y, x % y);
        return y;
    }

}


Measured memory_bytes: 26832
#include <bits/stdc++.h>
//#define int long long
#define INF 1000000007
using namespace std;

int n,a[200010],b[200010];
int dp[200010][5];
int k[]={0,2,1,2,0};

signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
		if(a[i]==0) continue;
		else if(a[i]%2==0) a[i]=2;
		else a[i]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<5;j++){
			dp[i][j]=INF;
			for(int l=0;l<=j;l++){
				dp[i][j]=min(dp[i][j],dp[i-1][l]);
			}
			if(a[i]==0) dp[i][j]+=k[j];
			else if(k[j]==0) dp[i][j]+=b[i];
			else dp[i][j]+=abs(a[i]-k[j]);
		}
	}
	int ans=INF;
	for(int i=0;i<5;i++) ans=min(ans,dp[n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,x,y,p,flag,i,count;
	cin>>n>>m;
	string s1,s2;
	cin>>s1>>s2;
	x=(n*1ll*m);
	y=__gcd(n,m);
	x=x/y;
	vector<ll> vi1,vi2;
	vi1.pb(1);
	vi2.pb(1);
	for(i=2;i<=n;i++){
	    p=1+(x/n)*(i-1);
	    vi1.pb(p);
	}
	for(i=2;i<=m;i++){
	    p=1+(x/m)*(i-1);
	    vi2.pb(p);
	}
/*	for(auto x:vi1){
	    cout<<x<<" ";
	}
	cout<<endl;
	for(auto x:vi2){
	    cout<<x<<" ";
	}
	cout<<endl;*/
	map<ll,char> mp1;
	count=0;
	for(auto x:vi1){
	    mp1[x]=s1[count];
	    count++;
	}
	flag=0;
	count=0;
	for(auto x:vi2){
	    if(mp1[x]>='a'&&mp1[x]<='z'){
	        if(mp1[x]!=s2[count]){
	            flag=1;
	        }
	    }
	    count++;
	}
	if(flag==0){
	    cout<<x;
	}
	else{
	    cout<<-1;
	}
}

Measured memory_bytes: 12084
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // gcd(a, b) * b

def func(x, a, b):
    return (b // x - (a-1) // x)

a, b, c, d = map(int, input().split())
print(b - a + 1 - func(c, a, b) - func(d, a, b) + func(lcm(c, d), a, b))

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int func(int s, int m, int n)
{
	if(0 < s && s <= m){
		return s;
	}
	if(0 > s){
		return func(s+n, m, n);
	}
	return func(n-s, m, n);;
}

int main()
{
	int n, m, a[10001];
	
	while(cin>>n&&n){
		set<int> st;
		vector<int> vec;
		fill(a, a+10001, 0);
		
		for(int i = 1; i < n; i++){
			st.insert((i*i)%n);
		}
		set<int>::iterator it = st.begin();
		while(it != st.end()){
			vec.push_back(*it);
			it++;
		}
		
		m = (n-1)/2;
		for(int i = 0; i < vec.size(); i++){
			for(int j = i+1; j < vec.size(); j++){
				a[func(vec[i]-vec[j], m, n)]++;
				a[func(vec[j]-vec[i], m, n)]++;
			}
		}
		
		for(int i = 1; i <= m; i++){
			cout << a[i] << endl;
		}
	}
	
	return 0;
}

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

const int MOD = 1000000007;

void tw(int &x){ x = x + x < MOD ? x + x : x + x - MOD; }

struct Edge {
  int x, y, v;
  bool operator< (Edge &r){ return v < r.v; }
};

Edge es[2002]; int p[1002];

int _p(int x){
  if(x == p[x]) return x;
  return p[x] = _p(p[x]);
}

int main(){
  int N, M; scanf("%d%d", &N, &M);
  long long X; scanf("%lld", &X);

  for(int i = 1; i <= M; i++){
    int x, y, v; scanf("%d%d%d", &x, &y, &v);
    es[i] = { x, y, v };
  }

  sort(es + 1, es + M + 1);

  int a = 2, b = 2;

  for(int m = 2; m <= M; m++){
    for(int i = 1; i <= N; i++) p[i] = i;

    const Edge &t = es[m];
    long long v = t.v; p[t.y] = t.x;

    for(int i = 1; i <= M; i++){
      const Edge &e = es[i];

      int px = _p(e.x), py = _p(e.y);
      if(px == py) continue;

      v += e.v; p[py] = px;
    }

    if(v > X){ tw(a); tw(b); } else if(v == X) tw(a);
  }

  printf("%d\n", a < b ? a - b + MOD : a - b);
  return 0;
}

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

using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<ll> v;
    partial_sum(istream_iterator<ll>(cin), istream_iterator<ll>(), back_inserter(v));

    ll r = (ll)1e9 * 1e9;

    const ll full_sum = v.back();
    v.pop_back();

    for(const auto x : v)
        r = min(r, abs(2ll * x - full_sum));

    cout << r << endl;
    return 0; }


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           M                           100009
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           bug(i)                      cout<<"akhane bug nai  "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;

bool cmp(int a,int b)
{
    return a>b;
}

int chk=0;
int sum=0;
 main()
{  fast
    int x,y,a,b,c,tmp,nisi=0,baki=0,ses=0;
    cin>>x>>y>>a>>b>>c;
    vector<int>vec;
    f(i,1,a)
    {
        cin>>tmp;
        vec.pb(tmp);
    }
    sort(vec.begin(),vec.end(),cmp);
    tmp=min(x,a);
    nisi+=tmp;
    vector<int>one,two;
    f(i,0,tmp-1)
    {
        one.pb(vec[i]);
        ses+=vec[i];
    }
    vec.clear();
    f(i,1,b)
    {
        cin>>tmp;
        vec.pb(tmp);
    }
    sort(vec.begin(),vec.end(),cmp);
    tmp=min(y,b);
    nisi+=tmp;
     f(i,0,tmp-1)
    {
        two.pb(vec[i]);
        ses+=vec[i];
    }
    vec.clear();
    baki=(x+y)-nisi;
    f(i,1,c)
    {
        cin>>tmp;
        vec.pb(tmp);
    }
    sort(vec.begin(),vec.end());
    while(vec.size() && baki)
    {
        baki--;
        tmp=vec.back();
        ses+=tmp;
        vec.pop_back();
    }
    reverse(vec.begin(),vec.end());
    vector<int>uff;
    while(one.size() && two.size())
    {
        int op1=one.back();
        int op2=two.back();
        if(op1<=op2)
        {
            one.pop_back();
            uff.pb(op1);
        }
        else
        {
            two.pop_back();
            uff.pb(op2);
        }
    }
    while(one.size())
    {
        tmp=one.back();
        one.pop_back();
        uff.pb(tmp);
    }
     while(two.size())
    {
        tmp=two.back();
        two.pop_back();
        uff.pb(tmp);
    }
    int sz=uff.size();
    sz=min(sz,(int)vec.size());
    int mx=0;
    for(int i=0;i<sz;i++)
    {
        sum+=vec[i];
        chk+=uff[i];
        tmp=sum-chk;
        mx=max(mx,tmp);
    }
    if(mx>=0)ses+=mx;
    cout<<ses<<endl;










































return 0;

}





Measured memory_bytes: 4596
/*Its-Rashid*/
#include <bits/stdc++.h>
using namespace std;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    ll x ;
    cin >> x ;

    if (x % 2 == 0) {
        cout << x ;
    }
    else if (x % 2 == 1) {
        cout << (x * 2) ;
    }
    
    return 0 ;

}



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

using namespace std;

int main()
{

    int n;
    cin >> n;
    int modSum = 0;
    for(int i = 0 ; i < n; ++i)
    {
        int a;
        cin >> a;
        modSum += a;
    }

    cout << modSum - n << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

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

    if(A%3==0||B%3==0||(A+B)%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}



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

int main() {
	int n;
	cin >> n;
	int A[111];
	for (int i = 0; i < n; i++) cin >> A[i];
	int ans = 0;
	bool flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				ans++;
			}
		}
	}
	for (int i = 0; i < n; i++) cout << A[i] << " \n"[i == n - 1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
using namespace std;
long n,h,a[1<<17],b[1<<17];
main()
{
	cin>>n>>h;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	sort(a,a+n);sort(b,b+n);
	long cnt=0;
	for(int i=n;i--;)
	{
		if(b[i]<a[n-1])break;
		cnt++;
		h-=b[i];
		if(h<=0)break;
	}
	cout<<(cnt+(h>0?(h+a[n-1]-1)/a[n-1]:0))<<endl;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n;
    int five = 0, seven = 0;
    rep(0, 3) {
        cin >> n;
        if (n == 5) five++;
        else if (n == 7) seven++;
    }

    cout << (five == 2 && seven == 1 ? "YES" : "NO") << endl;

    return 0;
}


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

#define endl '\n'
#define N 10000000

using namespace std;

typedef unsigned long long int ulli;

bool criba[N + 1];
ulli n, sumaHasta[N + 1], dp[N + 1];
vector<int> primos;

ulli f(ulli x)
{
    ulli copia = x, indice = 0, factor1 = 1, factor2 = 1;
    while (copia%primos[indice] != 0)
        ++indice;
    while (copia%primos[indice] == 0)
        copia /= primos[indice];
    factor1 = x / copia;
    factor2 = copia;
    return dp[factor1] * dp[factor2];
}

void computo(ulli n)
{
    for (int i=2; i<=n; ++i)
        criba[i] = true;
    for (int i=2; i*i<=n; ++i)
        if (criba[i])
            for (int j=i*i; j<=n; j+=i)
                criba[j] = false;
    for (int i=0; i<=n; ++i)
        if (criba[i])
            primos.push_back(i);
    dp[1] = 1;
    sumaHasta[1] = 1 * dp[1];
    for (int i=0; i<primos.size(); ++i)
    {
        ulli indice = primos[i], exp = 1;
        while (indice <= n)
        {
            dp[indice] = (exp + 1);
            ++exp;
            indice *= primos[i];
        }
    }
    for (int i=2; i<=n; ++i)
    {
        if (!dp[i])
        {
            dp[i] = f(i);
        }
        sumaHasta[i] = sumaHasta[i - 1] + (i * dp[i]);
    }
}

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

    ulli n;
    cin >> n;
    computo(n);
    cout << sumaHasta[n] << endl;

    return 0;
}

Measured memory_bytes: 171836
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    while(true){
        int a,b;char s;cin>>a>>s>>b;
        if(s=='+')cout<<a+b<<endl;
        else if(s=='-')cout<<a-b<<endl;
        else if(s=='*')cout<<a*b<<endl;
        else if(s=='/')cout<<a/b<<endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main()
{
    int r, D, x, total = 0;
    cin >> r >> D >> x;

    for (int i=2001; i<=2010; i++) {
        total = (r*x) - D;
        x = total;
        cout << total << endl;
    }
    return 0;
}

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

if n == 1:
  print('Yes')
  exit()

for i in reversed(range(n)):
  if i == n-1:
    continue
  else:
    if l[i] == l[i+1]+1:
      l[i] -= 1
    elif l[i] <= l[i+1]:
      continue
    else:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 63856
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004
int N;
int H[MAXN];

const int INF = 1000000010;
int memo[MAXN];
int go(int n) {
   if (n == N)
      return 0;
   int& res = memo[n];
   if (res < 0) {
      res = go(n+1) + abs(H[n]-H[n+1]);
      if (n+2 <= N)
         res = min(res, go(n+2) + abs(H[n]-H[n+2]));
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   FOR(i, 1, N)
      cin >> H[i];

   memset(memo, -1, sizeof(memo));
   int res = go(1);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;
int main()
{
	ll h,w;
	cin>>h>>w;
	std::vector<std::vector<char> > a(h+1,std::vector<char> (w+1));
	std::vector<std::vector<ll> > v(h+1,std::vector<ll> (w+1,0));
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')
				v[i][j]=0;
		}
	}
	v[1][1]=1;
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			if(a[i][j]=='.')
				v[i][j]=(v[i-1][j]+v[i][j-1])%1000000007;
			v[1][1]=1;
		}
	}
	cout<<v[h][w]<<"\n";

}


Measured memory_bytes: 9088
using System;
class Product
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		bool[] b = new bool[3];
		for(int i = 0; i < s.Length; i++)
		{
			char c = s[i];
			b[0] |= c == 'a';
			b[1] |= c == 'b';
			b[2] |= c == 'c';
		}
		Console.WriteLine((b[0] && b[1] && b[2]) ? "Yes" : "No");
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define N 100005
#define ll long long
#define NoSolution return puts("-1"),0 
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
#define p_b push_back 
using namespace std;

int f[N],fa[N],dep[N],cnt=0,b[N],_u,_v;
vector<int> g[N];

void dfs(int x,int v){
	f[x]=v;
	for(auto to:g[x]){
		if(!dep[to]){
			fa[to]=x,dep[to]=dep[x]+1;
			dfs(to,-v);
			f[x]+=f[to];
		} else if(to!=fa[x]){
			_u=x,_v=to;
		}
	}
}
int main(){
	int n,m,u,v,ans=INT_MAX,mid,tmp,cnt;
	dep[1]=1;
	scanf("%d%d",&n,&m);
	For(i,1,m){
		scanf("%d%d",&u,&v);
		g[u].p_b(v),g[v].p_b(u);
	}
	dfs(1,1);
	if(m==n-1){
		ans=0;
		if(f[1]) NoSolution;
		For(i,1,n) ans+=abs(f[i]);
		printf("%d\n",ans);
	} else{
		if((dep[_v]-dep[_u]+1)%2==0){
			if(f[1]) NoSolution;
			tmp=0,cnt=0;
			For(i,1,n) tmp+=abs(f[i]);
			ans=min(ans,tmp);
			for(int i=_v;i!=_u;i=fa[i]) tmp-=abs(f[i]),b[++cnt]=f[i];
			sort(b+1,b+cnt+1);
			cnt&1?mid=b[(cnt+1)/2]:mid=(b[cnt/2]+b[cnt/2+1])/2;
			tmp+=abs(mid);
			for(int i=_v;i!=_u;i=fa[i]) tmp+=abs(f[i]-mid);
			ans=min(ans,tmp);
			printf("%d\n",ans);		
		} else{
			if(f[1]%2) NoSolution;
			int tmp=f[1]/2;ans=abs(tmp);
			for(int i=_u;i;i=fa[i]) f[i]-=tmp;
			for(int i=_v;i;i=fa[i]) f[i]-=tmp;
			For(i,1,n) ans+=abs(f[i]);
			printf("%d\n",ans);
		}
	}
}

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

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

    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    rep(i, min(n + 1, k + 1)) rep(j, min(n - i + 1, k - i + 1))
    {
        vector<int> a;
        a.push_back(0);
        rep(s, i) a.push_back(v[s]);
        rep(t, j) a.push_back(v[n - 1 - t]);
        sort(a.begin(), a.end());
        int s = 0;
        while (a[s] < 0 && s < i + j && i + j + s < k)
        {
            a[s] = 0;
            s++;
        }
        s = 0;
        for (auto t : a)
            s += t;
        ans = max(ans, s);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000


struct queue{
    char name[10];
    int time;
};

void initialize();
int isFull();
int isEmpty();
void enqueue(struct queue);
struct queue dequeue();

int head;
int tail;

struct queue A[MAX];
struct queue Q[MAX];

int main(){
    int n,q;
    int total = 0;
    int flag = 1;
    struct queue x;

    scanf("%d %d",&n,&q);

    initialize();

    for(int i = 0;i < n;i++){
        scanf("%s %d",A[i].name,&A[i].time);
        enqueue(A[i]);
    }

    while(flag){
        x = dequeue();
        
        if(x.time - q > 0){
            total += q;
            x.time = x.time - q;
            enqueue(x);
        }
        else if(x.time - q == 0){
            total += q;
            printf("%s %d\n",x.name,total);
        }
        else{
            total += x.time;
            printf("%s %d\n",x.name,total);
        }

        flag = isEmpty() - 1;
    }

    return 0;
}

void initialize(){
    head = 0;
    tail = 0;
}

int isEmpty(){
    if(head == tail)return 1;
    return 0;
}

int isFull(){
    if(head == (tail+1) % MAX)return 1;
    return 0;
}

void enqueue(struct queue x){
    if(isFull()){
        fprintf(stderr,"OverFlow");
        exit(1);
    }
    Q[tail] = x;
    if(tail + 1 == MAX)tail = 0; 
    else tail++;
}

struct queue dequeue(){
    struct queue x;
    if(isEmpty()){
        fprintf(stderr,"AnderFlow");
        exit(1);
    }
    x = Q[head];
    if(head + 1 == MAX)head = 0;
    else head++;
    return x;
}


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

using namespace std;

int main()
{
   int n,k,t;
   cin>>n>>k>>t;
   if(n%k==0){
       cout << t*(n/k) << "\n";
   }
   else cout << t*(n/k + 1) << "\n";
   return 0;
}

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

namespace A073
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;

            n = int.Parse(Console.ReadLine());

            if (n % 10 == 9 || n / 10 == 9)
                Console.WriteLine("Yes");

            else Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    S = sr()
    if S[2] == S[3] and S[4] == S[5]:
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1[1];
  cin >> s1[0];
  for(int i=0;i<s1[0].size();i++){
    if(s1[0][i] == ','){
      s1[0][i] = ' ';
    }
  }

  cout << s1[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int x, a, b;
int main()
{
    scanf("%d%d%d", &x, &a, &b);
    a = a - b;
    if(a >= 0) printf("delicious");
    else{
        a = -a;
        if(a > x) printf("dangerous");
        else printf("safe");
    }
    return 0;
}


Measured memory_bytes: 128
from fractions import gcd
K = int(input())
ans = 0
dp = [0]*201

for i in range(1,K+1):
    for j in range(1,K+1):
        S = 0
        n = gcd(i,j)
        if dp[n] != 0:
            ans += dp[n]
        else:
            for k in range(1,K+1):
                S += gcd(k,n)
            ans += S
            dp[n] = S

print(ans)



Measured memory_bytes: 77276
import java.util.Scanner;
import java.util.TreeSet;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next(); int K = sc.nextInt();
		TreeSet<String> ans = new TreeSet<String>();
		for(int k = 1; k <= K; k++) {
			for(int i = 0; i + k <= s.length(); i++) {
				ans.add(s.substring(i, i + k));
			}
		}
		while(K > 1) {
			ans.pollFirst();
			K--;
		}
		System.out.println(ans.pollFirst());
	}
}

Measured memory_bytes: 25812
#include <iostream>

using namespace std;

int main(){
    int n, cnt;
    
    while(cin >> n){
        cnt=0;
        for(int a=0;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    for(int d=0;d<10;d++){
                        if(n==(a+b+c+d)) cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;

	cin >> N;

	SINT32 min;
	SINT32 max;


	vector<SINT32> DATA(N);
	cin >> DATA[0];
	min = DATA[0];
	max = DATA[0];
	
	for (SINT32 i = 1; i < N; i++) {
		cin >> DATA[i];
		min = MIN(min,DATA[i]);
		max = MAX(max,DATA[i]);
	}

	cout << (max-min) << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256