akhauriyash/Code-Regression huggingface dataset:
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n;
void solve()
{
    cin>>n;
    string s;cin>>s;
    if(n%2)
        {cout<<"No"<<endl;return;}
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[i+n/2])
            {cout<<"No"<<endl;return;}
    }
    cout<<"Yes"<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const ll INF = (1LL << 60);
string s,t; ll n,m,p, q, ans = 0, sum = 0,r;
const ll MOD = 1000000007;
int main() {
    int a, b, c, d, e, f, i, j, k, l, s = 0, w = 100;
    cin >> a >> b >> c >> d >> e >> f; a *= 100; b *= 100;
    for (i = 0; i <= f; i += a)
        for (j = 0; i + j <= f; j += b)
            for (k = 0; i + j + k <= f; k += c)
                for (l = 0; i + j + k + l <= f; l += d)
                    if (((k + l) * (100 + e) <= e * (i + j + k + l) && s * (i + j + k + l) <= (k + l) * (w + s))) {
                        w = i + j, s = k + l;
                    }
    cout << w + s << " " << s << endl;
}

Measured memory_bytes: 256
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(" ");

const A = parseInt(input[0], 10);
const P = parseInt(input[1], 10);

const parts = (A * 3) + P;

console.log(Math.floor(parts / 2));


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

int main(){

  int n, a;
  cin >> n;
  a = 3;
  int d[3];
  
  for(int i = 0;i < 3;i++){
  int b = n % 10;
    if(b == 9) d[i] = 1;
    else if(b == 1) d[i] = 9;
    else d[i] = b;  
    n /= 10;
  }

  for(int i = 2;i >= 0; i--){
  cout << d[i];
  }
  
return 0;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]) - 1;

		String s = br.readLine();
		br.close();

		String s1 = s.substring(0, k);
		String s2 = s.substring(k, k + 1).toLowerCase();
		String s3 = s.substring(k + 1, n);
		System.out.println(s1 + s2 + s3);
	}
}


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

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

int main()
{   
    long long l, r;
    cin >> l >> r;

    int mod = 2018*2018;

    bool zero = false;

    if (r - l > 2019)
        zero = true;

    else
    {
        for (long long i = l; i < r; i++) {
            for (long long j = i+1; j < r+1; j++) {
                if (mod > (i*j)%2019)
                    mod = (i*j)%2019;
            }
        }
    }

    if (zero)   cout << 0 << endl;
    else cout << mod << endl;
}


Measured memory_bytes: 256
//abc116_d.cpp
//Sun May 12 11:15:03 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

int main(){
	ll n,k;
	cin >> n >> k;

	P d[n];
	for (int i=0;i<n;i++){
		cin >> d[i].second >> d[i].first;
		d[i].second--;
	}

	sort(d,d+n,greater<P>());

	priority_queue<ll,vector<ll>,greater<ll>> q;
	ll score = 0;
	ll neta[n];
	fill(neta,neta+n,0);
	ll choosedneta = 0;
	for (int i=0;i<k;i++){
		score += d[i].first;
		if (neta[d[i].second]==0){
			choosedneta++;
		}else{
			q.push(d[i].first);
		}
		neta[d[i].second]++;
	}
//	cout << score << endl;

	ll bestscore = score + choosedneta*choosedneta;
	for (int i=k;i<n;i++){
		if (neta[d[i].second]==0 && q.size()>0){
			neta[d[i].second]++;
			choosedneta++;
			ll temp = q.top();
			q.pop();
			score = score-temp+d[i].first;
			if (score+choosedneta*choosedneta > bestscore){
				bestscore = score+choosedneta*choosedneta;
			}
//			cout << bestscore << " " << choosedneta <<endl;
		}
	}

	cout << bestscore << endl;
}

Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

char s[3][101]; int n[3], c[3] = {};
int dfs(int i){
  if(c[i] == n[i]) return i;
  return dfs(s[i][c[i]++] - 'a');
}

int
main(int argc, char *argv[])
{
  rep(i, 3){
    scanf("%s", s[i]);
    n[i] = strlen(s[i]);
  }

  printf("%c\n", dfs(0) + 'A');

  return 0;
}
  


Measured memory_bytes: 128
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long A,B,C,K;cin >> A >> B >> C >> K;
    long long maxi = 1000000000000000000;
    if(K % 2 == 0){
        long long diff = A-B;
        if(abs(A-B) >= maxi){
            cout << "Unfair" << endl;
            return 0;
        }
        cout << diff << endl;
    }
    else{
        long long diff = B-A;
        if(abs(B-A) >= maxi){
            cout << "Unfair" << endl;
            return 0;
        }
        cout << diff << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i, j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(i=0; i<n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		if(n==2) {
			System.out.println(Math.max(a[0], a[1]));
		} else {
			int[] b = new int[n];
			b[1] = a[0];
			for(i=2; i < n; i++) {
				b[i] = gcd(b[i-1], a[i-1]);
			}
			int[] c = new int[n];
			c[n-2] = a[n-1];
			for(i=n-3; i >= 0; i--) {
				c[i] = gcd(c[i+1], a[i+1]);
			}
			b[0] = c[0];
			c[n-1] = b[n-1];
			int max = 1;
			int pre;
			for(i=0; i < n; i++) {
//				System.out.println("b,c=" + b[i] + "," + c[i]);
				pre = gcd(b[i], c[i]);
				if(pre>max)max=pre;
			}
			System.out.println(max);
		}
	}
	public static int gcd(int a, int b) {
		int t;
		while((t=a%b)!=0) {
			a = b;
			b = t;
		}
		return b;
	}
}


Measured memory_bytes: 48840
#include <iostream>
#include <algorithm>
using namespace std;
using llong = long long;

llong sum[3005];
llong n;
llong l[2005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        sum[l[i]]++;
    }
    for (int i = 1; i < 3005; i++) {
        sum[i] += sum[i - 1];
    }

    llong ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            llong left = max({0ll, l[i] - l[j], l[j] - l[i]});
            llong right = l[i] + l[j];

            ans += sum[right - 1] - sum[left];
            if (left < l[i] && l[i] < right) ans--;
            if (left < l[j] && l[j] < right) ans--;
        }
    }

    ans /= 3;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main(){
	ll ans = 0;
	int N;cin>>N;
	rep(i, N) {
		if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) {
			ans += (i + 1);
		}
    }
   cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <unordered_map>
typedef long long lld;
const int LEN = 10;
const int MAXS = LEN + 5;
std::unordered_map<std::string, int> cnt;
char S[MAXS];
int N;

int main() {
  scanf("%d", &N);
  cnt.reserve(N);
  lld ret = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%s", S);
    std::sort(S, S + LEN);
    ret += cnt[S]++;
  }
  printf("%lld\n", ret);
  return 0;
}

Measured memory_bytes: 10496
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		char c[]=S.toCharArray();
		int d=c.length;
		boolean isAC=false;
		for(int i=0;i<d-1;i++) {
			if(c[i]=='A'&&c[i+1]=='C') {
				isAC=true;
				break;
			}
		}
		if(isAC) System.out.println("Yes");
		else System.out.println("No");
		
	}
}


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

using namespace std;

int main(){
  int i,j,k,l=-1,n,m;
  string s;
  cin >> n >> m;
  for(i=1;i*i<=m;i++){
    if(m%i==0 && i<=m/n)l=max(i,l);
    if(m%i==0 && m%(m/i)==0 && m/i <= m/n)l=max(m/i,l);
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string x,y,s;
int dp[3009][3009];
int main()
{
    cin>>x>>y;
    for(int i=1;i<=x.size();i++)
    {
        for(int j=1;j<=y.size();j++)
        {
            if(x[i-1]==y[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=x.size(),j=y.size(),a;
    a=dp[i][j];
    while(a!=0)
    {
        if(a>dp[i-1][j]&&a>dp[i][j-1])
        {
            s+=x[i-1];
            i--;
            j--;
            a=dp[i][j];
            continue;
        }
        else
        {
            if(a==dp[i-1][j])
            {
                i--;
                a=dp[i][j];
                continue;
            }
            else
            {
                j--;
                a=dp[i][j];
                continue;
            }
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string S,T="CODEFESTIVAL2016";
signed main() {
    cin>>S;
    int ans=0;
    for(int i=0;i<16;i++)if(S[i]!=T[i])ans++;
    cout<<ans<<endl;
}


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


using namespace std;

int roll(int x) {
	return(x + 9) / 10 * 10;
}
int ros(int x) {
	return roll(x) - x;
}
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int time = roll(a) + roll(b) + roll(c) + roll(d) + roll(e);
	time -= max({ ros(a),ros(b),ros(c),ros(d),ros(e) });
	cout << time << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s,t;
  cin>>s>>t;
  if(s.size() < t.size())puts("LESS");
  else if(s.size() > t.size())puts("GREATER");
  else{
    puts(s<t ? "LESS" : s>t ? "GREATER" : "EQUAL");
  }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//a^n
cpp_int Pow(cpp_int a, cpp_int n) {
  cpp_int ans = 1;
  while (n > 0) {
    if (n & 1)ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}

int main(){
  VS str={"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
  
  cpp_int m,n;
  while(cin>>m>>n && (m||n)){
    cpp_int x=Pow(m,n);
    vector<cpp_int> ans(18);
    
    rep(i,18)
      ans[i]=x % Pow(10,i*4+4) / Pow(10,i*4);
    
    for(int i=17; i>=0; i--)
      if(ans[i]!=0)cout << ans[i] << str[i];
    cout<<endl;
  }
}


Measured memory_bytes: 3212
#include <iostream>

int main()
{
  int A, B, C, X, count = 0;
  std::cin >> A; std::cin >> B; std::cin >> C; std::cin >> X;
  
  for (int a = 0; a <= A; a++)
  {
    for (int b = 0; b <= B; b++)
    {
      for (int c = 0; c <= C; c++)
      {
        int sum = 500*a + 100*b + 50*c;
        if (sum == X) count++;
      }
    }
  }
  
  std::cout << count;
  
  return 0;
}
    

Measured memory_bytes: 3132
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <functional>

int main(){
    int32_t N;
    std::cin >> N;
    assert(2 <= N && N <= 50);
    std::vector<float> v(N);
    for(auto& i : v){
        std::cin >> i;
    }
    
    std::sort(v.begin(), v.end());
    float res = v[0];
    for(int32_t i = 1; i < N; i++){
        res = (res + v[i]) / 2;
    }
  
    std::cout << res;

    return 0;
}


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

int main() {
  // Input
  int n;
  cin >> n;
  
  vector<int> R(n);
  for (int i = 0; i < n; i++) {
    cin >> R.at(i);
  }
  
  // Compute
  int ans = -1000000000;
  int R_min = R.at(0);
  for (int i = 1; i < n; i++) {
    if (R.at(i) - R_min > ans) {
      ans = R.at(i) - R_min;
    }
    if (R.at(i) < R_min) {
      R_min = R.at(i);
    }
  }
  
  // Output
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<algorithm>
 */
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    int d, g;
    cin >> d >> g;
    int p[d], c[d];
    rep(i, d) cin >> p[i] >> c[i];
    int anscnt = inf;
    rep(i, (1 << d)) {
        int sum = 0, cnt = 0;
        rep(j, d) {
            if (i & (1 << j)) {
                sum += c[j] + p[j] * 100 * (j + 1);
                cnt += p[j];
                if (sum >= g) { chmin(anscnt, cnt); break; }
            }
        }
        // out(i << " " << cnt << " " << sum);
        if (sum >= g) { chmin(anscnt, cnt); continue; }
        for (int j = d - 1; j >= 0; --j) {
            if (i & (1 << j)) continue; // careful!!
            int rest = g - sum;
            int tmp = min(p[j] - 1, rest / ((j + 1) * 100));
            cnt += tmp;
            sum += tmp * (j + 1) * 100;
            if (sum >= g) { chmin(anscnt, cnt); break; }
        }
        // out(cnt << " " << sum);
        if (sum >= g) { chmin(anscnt, cnt); continue; }
    }
    out(anscnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
	}

	int amin = *min_element(a.begin(), a.end());
	int amax = *max_element(a.begin(), a.end());

	int result = 0;
	if (amin != amax) {
		result = 1000000;
		rep(i, amin, amax+1) {
			int cost = 0;
			rep(j, N) {
				cost += (a[j] - i) * (a[j] - i);
			}
			if (result > cost) result = cost;
		}
	}
	cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int n, m;
	cin >> n >> m;
	cout << (n==m?"Yes":"No") << endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    int n,m,q;
    cin >> n >> m >> q;
    vi a(q),b(q),c(q),d(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vi A(n,1);
    int score=0;
    rrep(i1,m){
        srep(i2,i1,m+1){
            srep(i3,i2,m+1){
                srep(i4,i3,m+1){
                    srep(i5,i4,m+1){
                        srep(i6,i5,m+1){
                            srep(i7,i6,m+1){
                                srep(i8,i7,m+1){
                                    srep(i9,i8,m+1){
                                        A[1]=i1;
                                        A[2]=i2;
                                        A[3]=i3;
                                        A[4]=i4;
                                        A[5]=i5;
                                        A[6]=i6;
                                        A[7]=i7;
                                        A[8]=i8;
                                        A[9]=i9;
                                        int score2=0;
                                        rep(i,q){
                                            if(A[b[i]-1]-A[a[i]-1]==c[i])
                                            score2 += d[i];
                                        }
                                        chmax(score,score2);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    cout << score << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    string s;cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int P[100001];

int Find(int A) {
	if (P[A] == A) return A;
	else return P[A] = Find(P[A]);
}

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


	int N;
	cin >> N;

	pair<int, int> X[100001], Y[100001];
	rep1(i, N) {
		int x, y;
		cin >> x >> y;
		X[i] = mp(x, i);
		Y[i] = mp(y, i);
	}
	sort(X + 1, X + N + 1);
	sort(Y + 1, Y + N + 1);

	vector<pair<int, pair<int, int>>> eda;
	rep1(i, N - 1) {
		eda.pb(mp(abs(X[i + 1].first - X[i].first), mp(X[i].second, X[i + 1].second)));
		eda.pb(mp(abs(Y[i + 1].first - Y[i].first), mp(Y[i].second, Y[i + 1].second)));
	}
	sort(eda.begin(), eda.end());

	rep1(i, N) P[i] = i;
	ll kotae = 0;
	for (auto itr : eda) {
		int a = Find(itr.second.first);
		int b = Find(itr.second.second);
		if (a != b) {
			P[a] = b;
			kotae += itr.first;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int m = 0, point = 0;
  rep(i,N){
    int x,y;cin >> x >> y;
    if(x>m){
      m = x;
      point = y;
    }
  }
  cout << m+point << endl;
  return 0;
}


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

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;
const int MAX_K = 1000;

ll N, K;

ll mod[4 * MAX_K + 1][4 * MAX_K + 1];

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

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            mod[x % (2 * K) + 1][(y + K) % (2 * K) + 1]++;
        } else {
            mod[x % (2 * K) + 1][y % (2 * K) + 1]++;
        }
    }

    for (int i = 0; i < 4 * K; i++) {
        for (int j = 0; j < 4 * K; j++) {
            mod[i + 1][j + 1] = mod[i % (2 * K) + 1][j % (2 * K) + 1];
        }
    }

    for (int i = 1; i <= 4 * K; i++) {
        for (int j = 1; j <= 4 * K; j++) {
            mod[i][j] += mod[i - 1][j] + mod[i][j - 1] - mod[i - 1][j - 1];
        }
    }

    ll ans = 0;
    for (int i = 1; i <= 2 * K; i++) {
        for (int j = 1; j <= 2 * K; j++) {
            ll res = 0;
            res += mod[i + 2 * K - 1][j + 2 * K - 1] - mod[i + K - 1][j + 2 * K - 1] - mod[i + 2 * K - 1][j + K - 1] + mod[i + K - 1][j + K - 1];
            res += mod[i + K - 1][j + K - 1] - mod[i + K - 1][j - 1] - mod[i - 1][j + K - 1] + mod[i - 1][j - 1];
            ans = max(res, ans);
        }
    }

    /*
    for (int i = 1; i <= 2 * K; i++) {
        for (int j = 1; j <= 2 * K; j++) {
            cout << "i = " << i << ", j = " << j << ", sum = " << sum[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 128612
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;


int main(){
  int i,j,a,b,total=0,left[100000],right[100000],max_L=0,min_R=10000000;

  cin >>a>>b;
  for(i=0;i<b;i++){cin>>left[i]>>right[i];}

  for(i=0;i<b;i++){
    max_L = max(left[i],max_L);
    min_R = min(right[i],min_R);
  }

  total = min_R-max_L+1;
  total = max(total,0);


  cout <<total <<endl;
}

Measured memory_bytes: 1024
const input = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n')
const [X, Y] = input[0].split(' ').map(Number)
let ans = 'No'
if (X < Y) {
  const r = Y - X * 2
  if (0 <= r && r % 2 === 0 && r / 2 <= X) ans = 'Yes'
}
console.log(ans)


Measured memory_bytes: 29632
import numpy as np

N = int(input())
t_target = [0] * N
x_target = [0] * N
y_target = [0] * N
for i in range(N):
    t_target[i], x_target[i], y_target[i] = map(int, input().split())

t = 0
x_t = 0
y_t = 0
for i in range(N):
    time_surplus = (t_target[i] - t) - (np.abs(x_target[i] - x_t) + np.abs(y_target[i] - y_t))
    if time_surplus >= 0 and time_surplus % 2 == 0:
        t = t_target[i]
        x_t = x_target[i]
        y_t = y_target[i]
    else:
        print('No')
        exit()

print('Yes')

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

int v[51];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    double ans = v[1];
    for (int i = 2; i <= n; i++) ans = (ans + v[i]) / 2;
    printf("%.6lf", ans);
    return 0;
}

Measured memory_bytes: 256
a = input()
for i in range(2**3):
    tmp = a[0]
    for j in range(3):
        if (i >> j) & 1:
            tmp += "+"+a[j+1]
        else:
            tmp += "-"+a[j+1]
    if eval(tmp) == 7:
        print(tmp + "=7")
        exit()

Measured memory_bytes: 38256
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		998244353
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
void solve()
{
    for1(i,6)
    {
        int x;cin>>x;if(x==0){cout<<i<<endl;return;}
    }
}
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <bitset>
using namespace std;

int n, s, a;
bitset<1 << 22> d;
int main()
{
	int i;
	cin >> n;
	d[0] = 1;
	while (n--) {
		scanf("%d", &a);
		d |= d << a;
		s += a;
	}
	for (i = (s + 1) / 2; ; i++) {
		if (d[i]) {cout << i; return 0;}
	}
    return 0;
}

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


void solve(long long N, std::vector<long long> A){
    ll ok = 0;
    ll ng = 1e18;
    auto f = [&](ll k){
        ll node = 1;

        for(int i = 0;i < N + 1;i++){
            if(node < A[i]){
                return 2;
            }
            node -= A[i];
            if(node < k){
                if(node * 2 <= k){
                    node *= 2;
                }else{
                    node = k;
                }
            }
        }
        if(node >= 0){
            return 1;
        }else{
            return 0;
        }
    };
    if(f(1e18) == 2){
        cout<<-1<<endl;
        return;
    }
    while(ng - ok > 1){
        ll mid = (ok + ng)/2;
        if(f(mid) == 2){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    ok = ng;
    ng = 1e18;
    while(ng - ok > 1){
        ll mid = (ok + ng)/2;
        if(f(mid) == 0){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    ll ans = 0;
    ll node = 1;
    ok = accumulate(A.begin(), A.end(), 0LL);
    for(int i = 0;i < N + 1;i++){
        ans += node;
        node -= A[i];
        ok -= A[i];
        if(node < ok){
            if(node * 2 <= ok){
                node *= 2;
            }else{
                node = ok;
            }
        }
    }
    //cout<<node<<endl;
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		long x = sc.nextLong();
		long m = 100;
		int y = 0;
		while(m < x) {
			y++;
			m = (long)(1.01 * m);
		}
		System.out.println(y);
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll K, N;
    cin >> K >> N;
    
    vector<ll> A(N);
    REP(i, N) { 
        cin >> A[i];
    }
    ll ma = K - A[N-1] + A[0];
    REP(i, N-1) {
        ma = max(ma, A[i+1] - A[i]);
    }
    PRINT(K - ma);
    return 0;
} 

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys

def main():
    H,W,K = list(map(int, sys.stdin.readline().split()))
    C_list = [list( sys.stdin.readline().rstrip() ) for _ in range(H)]

    bit_H = 1 << H
    bit_W = 1 << W
    cnt_K = 0

    for b_H in range(bit_H):
        for b_W in range(bit_W):
            cnt_black = 0

            for row in range(H):
                for col in range(W):
                    if (C_list[row][col] == "#") and ( b_H & (1 << row) ) and ( b_W & (1 << col) ):
                        cnt_black += 1
            
            if cnt_black == K:
                cnt_K += 1
    
    print(cnt_K)


if __name__ == "__main__":
    main()


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    }
    else {
        cout << b - a << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13)
        cout << b;
    else if(6 <= a && a <= 12)
        cout << b / 2;
    else
        cout << 0;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

            var ordered = X.Select((x, i) => new { Value = x, Index = i }).OrderBy(x => x.Value).ToArray();
            var mid1 = ordered[N / 2].Value;
            var mid2 = ordered[N / 2 - 1].Value;
            var answer = new int[N];
            for (var i = 0; i < ordered.Length; i++)
            {
                var index = ordered[i].Index;
                answer[index] = (i < N / 2) ? mid1 : mid2;
            }
            Console.WriteLine(string.Join("\n", answer));
        }
    }
}

Measured memory_bytes: 57464
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
int main() {
    int n, a, cnt; cin >> n; vector<int> v, p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) {
        a = p[i];
        if (v.empty() && a > 0) {
            v.push_back(a);
        }
        else if (v.empty() && a < 0) {
            cout << i + 1 << endl;
            return 0;
        }
        else if (a < 0) {
            auto it = v.end(); it--;
            if (*it != abs(a)) {
                cout << i + 1 << endl;
                return 0; 
            }
            else v.erase(it);
        }
        else {
            if (find(ALL(v), a) != v.end()) {
                cout << i + 1 << endl;
                return 0;
            }
            else v.push_back(a);
        }
    }cout << "OK" << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = 1; i < n; i++) {
        if (arr[i] > arr[i - 1]) arr[i]--;
        if (arr[i] < arr[i - 1]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
import itertools
import sys
input = sys.stdin.readline


# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# nの約数列挙
def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass


# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def coprime(a, b):
    return gcd(a, b) == 1


def main():
    A, B = map(int, input().split())
    gcdab = gcd(A, B)
    cd = divisor(gcdab)
    # print(factorization(gcdab))
    # print(cd)
    # da = sorted(divisor(A))
    # db = sorted(divisor(B))
    # cd = []
    # for i in da:
    #     if i in db:
    #         cd.append(i)

    ans = 0

    for i in cd:
        if is_prime(i) or i == 1:
            ans += 1

    print(ans)

    # print(cd)
    # li = []
    # # c = itertools.combinations(cd, 2)
    # for i in cd:
    #     if i == 1:
    #         li.append(i)
    #         continue

    #     flg = True
    #     for c in li:
    #         if not coprime(i, c):
    #             flg = False

    #     if flg:
    #         li.append(i)

    # # print(li)
    # print(len(li))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67692
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    string sub = s.substr(0, 4);
    if (sub == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main() {
	char str[1001], tem[1001], com[10];
	int a, b, c, i, j;

	scanf("%s", &str); // ?????????
	scanf("%d", &a);   // ????????°???

	for (i = 0; i < a; i++){
		scanf("%s", &com);
		if (strcmp(com, "print") == 0) {
			scanf("%d %d", &b, &c);
			for (j = b; j < c + 1; j++) {
				putchar(str[j]);
			}
			puts("");
		}
		else if (strcmp(com, "reverse") == 0) {
			scanf("%d %d", &b, &c);
			for (j = 0; j < c - b + 1; j++) {
				tem[j] = str[c - j];
			}
			for (j = 0; j < c -b + 1; j++) {
				str[b + j] = tem[j];
			}
		}
		else if(strcmp(com, "replace") == 0) {
			scanf("%d %d %s", &b, &c, &tem);
			for (j = 0; j < c - b + 1; j++) {
				str[b + j] = tem[j];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 592