akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
  rep(i, 1<<3) {
    int e = a;
    char op1, op2, op3;
    if (i & 1<<2) {
      e += b;
      op1 = '+';
    } else {
      e -= b;
      op1 = '-';
    }
    if (i & 1<<1) {
      e += c;
      op2 = '+';
    } else {
      e -= c;
      op2 = '-';
    }
    if (i & 1<<0) {
      e += d;
      op3 = '+';
    } else {
      e -= d;
      op3 = '-';
    }
    if (e == 7) {
      printf("%d%c%d%c%d%c%d=7\n", a, op1, b, op2, c, op3, d);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string &str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }


//------------------------------------------------------------------------------------------------------------------------------


int main() {

	INPUT_STR(s);
	INPUT_STR(t);

	vector<int> dp(t.length()+1);
	dp[0] = 0;

	bool valid = true;
	int lastIndex;
	for (int i = 1; i <= t.length(); ++i) {

		if (i == 1) {
			lastIndex = s.find(t[0]);
			if (lastIndex != string::npos) {
				dp[1] = 1;
			} else {
				valid = false;
				break;
			}
		} else {

			lastIndex = s.find(t[i-1], lastIndex+1);
			if (lastIndex != string::npos) {
				dp[i] = dp[i-1];
			} else {
				lastIndex = s.find(t[i - 1]);
				if (lastIndex != string::npos) {
					dp[i] = dp[i - 1] + 1;
				} else {
					valid = false;
					break;
				}
			}

		}

	}

	if (valid) {
		long long int res = (long long int)(dp[t.length()] - 1) * s.length() + (lastIndex + 1);
		OUTPUT(res);
	} else {
		OUTPUT(-1);
	}

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

vector<int>a, b,am,bm;


signed main() {
	int N; cin >> N;
	a.resize(N); b.resize(N);
	am.resize(N); bm.resize(N);
	REP(i, N)cin >> a[i];
	REP(i, N)cin >> b[i];
	int ans = 0;
	REP(k, 31) {
		int T = 1 << k;
		REP(i, N) {
			am[i] = a[i] % (2 * T);
			bm[i] = b[i] % (2 * T);
		}
		//bm[N] = INF;
		VSORT(bm);
		
		int cnt = 0;
		REP(i, N) {
			auto itr = lb(bm, T - am[i]);
			int it = itr - bm.begin();
			itr = lb(bm, 2 * T - am[i]);
			int it2 = itr - bm.begin();
			itr = lb(bm, 3 * T - am[i]);
			int it3 = itr - bm.begin();
			cnt += N - it3;
			cnt += it2 - it;
		}
		if (cnt % 2 == 1) {
			ans += (1 << k);
		}
	}
	print(ans);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
/*
int cnt_bomb(char s[], int i, int j){
    int num = 0;
    if(i >= 1){
        if(i <= h)
    }

    return num;
}
*/
int main(void){
    int h = 0, w = 0;
    char s[51][51]; 

    scanf("%d%d", &h, &w);

    for(int i = 0; i < h; i++){
        scanf("%s", s[i]);
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int cnt = 0;
            if(s[i][j] == '#'){
                printf("#");
            }else{
//                cnt = cnt_bomb(*s, i, j);
                // 左上
                if(i >= 1 && j >= 1){
                    if(s[i - 1][j - 1] == '#'){
                        cnt++;
                    }
                }
                // 上
                if(i >= 1){
                    if(s[i - 1][j] == '#'){
                        cnt++;
                    }
                }
                // 右上
                if(i >= 1 && j <= w - 2){
                    if(s[i - 1][j + 1] == '#'){
                        cnt++;
                    }
                    
                }
                // 左
                if(j >= 1){
                    if(s[i][j - 1] == '#'){
                        cnt++;
                    }
                    
                }
                // 左
                if(j <= w - 2){
                    if(s[i][j + 1] == '#'){
                        cnt++;
                    }
                    
                }
                // 左下
                if(i <= h - 2 && j >= 1){
                    if(s[i + 1][j - 1] == '#'){
                        cnt++;
                    }
                    
                }
                // 下
                if(i <= h - 2){
                    if(s[i + 1][j] == '#'){
                        cnt++;
                    }
                    
                }
                // 右下
                if(i <= h - 2 && j <= w - 2){
                    if(s[i + 1][j + 1] == '#'){
                        cnt++;
                    }
                    
                }

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

} 


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	int X, Y; cin >> X >> Y;

	if(X%Y == 0) cout << -1 << endl;
	else cout << X << endl;



	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)        int i; cin >> i
#define in2(i, j)    int i, j; cin >> i >> j
#define in3(i, j, k) int i, j, k; cin >> i >> j >> k
#define in_ll(i)        ll i; cin >> i
#define in2_ll(i, j)    ll i, j; cin >> i >> j
#define in3_ll(i, j, k) ll i, j, k; cin >> i >> j >> k
#define in_ld(i)        ld i; cin >> i
#define in2_ld(i, j)    ld i, j; cin >> i >> j
#define in3_ld(i, j, k) ld i, j, k; cin >> i >> j >> k
#define in_c(i)        char i; cin >> i
#define in2_c(i, j)    chari, j; cin >> i >> j
#define in3_c(i, j, k) char i, j, k; cin >> i >> j >> k
#define in_str(s) std::string s; cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){cin>>x;}

#define print(x)   cout << (x)
#define println(x) cout << (x) << "\n"

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)
/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())


using namespace std;
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in(N);
    vec_in(A, N);
    auto s = uset_i(A.begin(), A.end());

    vec_sort(A);

    rep(i, N) {
        int j = 2;
        while (A[i] * j <= A[N - 1]) {
            if (s.count(A[i] * j)) {
                s.erase(A[i] * j);
            }
            j++;
        }
        if (i < N - 1&& A[i] == A[i + 1]) s.erase(A[i]);
    }
    println(s.size());
    return 0;
}


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


int main()
{

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int cnt=0;
    while(a>0&&c>0){
        if(cnt%2==0)
            c-=b;
        else
            a-=d;

        cnt++;
    }

    if(a>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}   

Measured memory_bytes: 3624
import sys
import numpy as np

n, a, *x = map(int, sys.stdin.read().split())

def main():
    m = 2500
    dp = np.zeros((n + 1, m + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(n):
        dp[1:, x[i]:] += dp[:-1, :-x[i]].copy()
    i = np.arange(1, n + 1)
    print(dp[i, i * a].sum())

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14532
n = gets.to_i
list = []
n.times do |time|
    s = gets.chomp.to_s
    list << s
end

max = 0
counts = list.each_with_object(Hash.new(0)) do |s, h|  
    h[s] += 1
    max = h[s] if h[s] >= max
end

puts counts.select { |a, v| v == max }.keys.sort

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

int main() {
  string s;cin>>s;
  if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
    cout<<"Yes"<<endl;
  }
    else cout<<"No"<<endl;
}

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

int main(){

	    int n, m;
	    scanf("%d%d", &n,&m);
	    vector<int> heights(n);
	    for (int& x: heights){
			scanf("%d", &x);
		}
		vector<int> tempheights(n);
		tempheights = heights;
        //vector<vector<int> > matrix(n, vector<int>(n));
        int f,s;
        for (int i=0; i<m; i++){
			scanf("%d%d", &f,&s);
			int a = heights[f-1],b = heights[s-1];
			if (a>b) tempheights[s-1] = 0;
			else if (a < b) tempheights[f-1] = 0;
			else {
				tempheights[f-1] = 0;
				tempheights[s-1] = 0;
			}
		}
		int count = 0;
		for (int& x: tempheights){
			if (x) count++;
		}
		printf("%d", count);

		
        return 0;
}


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

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
   t.pop_back();
   if(s==t) cout<<"Yes"<<'\n';
   else cout<<"No"<<'\n';
    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int h,w,k; cin >> h >> w >> k;
    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    vvi d(h, vi(w, INF));
    queue<pii> Q;
    Q.push(pii(x1-1,y1-1));
    d[x1-1][y1-1] = 0;
    while(!Q.empty()){
        int i = Q.front().fi;
        int j = Q.front().se;
        Q.pop();
        rep(l,4){
            REP(m,1,k+1){
                int ni = i + di[l] * m;
                int nj = j + dj[l] * m;
                if(ni < 0 || h <= ni) continue;
                if(nj < 0 || w <= nj) continue;
                if(s[ni][nj] == '@') break;
                if(d[ni][nj] <= d[i][j]) break;
                if(d[ni][nj] == INF){
                    d[ni][nj] = d[i][j] + 1;
                    Q.push(pii(ni,nj));
                }
            }
        }
    }
    if(d[x2-1][y2-1] == INF) cout << -1 << endl;
    else cout << d[x2-1][y2-1] << endl;
    return 0;
}

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

using namespace std;

#define all(x) begin(x), end(x)

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

ll brute(string s, int p) {
    int n = s.size();
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int x = 0;
            for (int k = i; k < j; ++k) {
                x *= 10;
                x += s[k] - '0';
                x %= p;
            }

            if (x == 0) {
                ++ans;
            }
        }
    }

    return ans;
}

ll fast(string s, int p) {
    int n = s.size();
    ll ans = 0;
    if (p == 2 or p == 5) {
        for (int i = 0; i < n; ++i) {
            if ((s[i] - '0') % p == 0) {
                ans += i + 1;
            }
        }
    } else {
        map<ll, int> m;
        ll p10 = 1;
        ll v = 0;
        ++m[v];
        for (int i = n - 1; i >= 0; --i) {
            v = ((p10 * (s[i] - '0')) + v) % p;
            p10 = p10 * 10 % p;
            ans += m[v];
            m[v]++;
        }
    }

    return ans;
}

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

    while (false) {
        int n = rand() % 100;
        int r = rand();
        int p;
        if (r % 3 == 0) {
            p = 2;
        } else if (r % 3 == 1) {
            p = 5;
        } else {
            p = 13;
        }
        string s(n, '0');
        for (int i = 0; i < n; ++i) {
            s[i] = (rand() % 10) + '0';
        }

        ll b = brute(s, p);
        ll f = fast(s, p);
        cout << s << ' ' << p << ' ' << b << ' ' << f << '\n';
        assert(b == f);
    }

    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    cout << fast(s, p) << '\n';
    
    return 0;
}


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

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

    rep(i, s.size()) {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int x;
        int y=0;
        
   while(true){

    x = sc.nextInt();
     if ( x == 0 ) break;   
     y++;
 
     System.out.println("Case "+y+ ": "+x);
    }
   }
   
}




Measured memory_bytes: 42432
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

num = 0
while True:
    if all((A+1) // 2 == A // 2):
        num += 1
        A = A // 2
    else:
        break
print(num)

Measured memory_bytes: 12248
n = int(input())
a = []

for i in range(n):
    a.append(int(input())-1)

button = 0
cnt = 0
done = [False] * n

while True:
    if done[button] == False:
        done[button] = True
        cnt += 1
        if a[button] == 1:
            break
        button = a[button]
    else:
        cnt = -1
        break

print(cnt)


Measured memory_bytes: 7852
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;
#define int long long

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

    map<string,int> MIN;
    vector<string> colors{"gray","brown","green","cyan","blue","yellow","orange","red"};
    int fcolor = 0;
    for(int i=0;i<N;i++){
        if(A[i] < 400) MIN["gray"]++;
        if(A[i] >= 400 && A[i] < 800) MIN["brown"]++;
        if(A[i] >= 800 && A[i] < 1200) MIN["green"]++;
        if(A[i] >= 1200 && A[i] < 1600) MIN["cyan"]++;
        if(A[i] >= 1600 && A[i] < 2000) MIN["blue"]++;
        if(A[i] >= 2000 && A[i] < 2400) MIN["yellow"]++;
        if(A[i] >= 2400 && A[i] < 2800) MIN["orange"]++;
        if(A[i] >= 2800 && A[i] < 3200) MIN["red"]++;
        if(A[i] >= 3200) fcolor++;
    }

    int res = 0;
        
    for(string i : colors){
        if(MIN[i]) res++;
    }
    int res2 = res + fcolor;
    if(!res) res++;


    cout<<res<<" "<<res2<<endl;

}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
        int y = sc.nextInt();
      
        int ans = 0;
        if (n <= k) {
          ans += n * x;
        } else {
          ans += k * x;
          ans += (n - k) * y;
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
n, k = map(int, input().split())
V = list(map(int, input().split()))


def get_jewelries(box, left_pop, right_pop):
    if left_pop + right_pop >= len(box):
        return box[:]

    left = box[:left_pop]
    right = box[-right_pop:] if right_pop else []

    return left + right


candidates = []
pop_max = min(k, n)
for pop_count in range(pop_max+1):
    residue = k - pop_count

    for left_pop in range(pop_count+1):
        right_pop = pop_count - left_pop
        jewelries = get_jewelries(V, left_pop, right_pop)
        jewelries.sort(reverse=True)

        for _ in range(residue):
            if not jewelries:
                break
            if jewelries[-1] < 0:
                jewelries.pop()

        value = sum(jewelries)
        candidates.append(value)

print(max(candidates))


Measured memory_bytes: 3064
x = input()
n = len(x)

stack=[]
ans = 1
for i in range(n):
    if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'):
        ans += 1
        stack.pop()
    else:
        stack.append(x[i])
    
print(len(stack))


Measured memory_bytes: 10508
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
 
int main(void){
   int n,m;
   long long ans=1;
   cin>>n>>m;
   long long a[m],F[n+1];F[0]=1;F[1]=1; for(int i=2;i<1+n;i++)F[i]=(F[i-1]+F[i-2])%1000000007;//  std::cout << F[i] << std::endl; }
   if(m==0){
       std::cout << F[n] << std::endl;return 0;
   }
   cin>>a[0];
   for(int i=1;i<m;i++){
       std::cin >>a[i] ;if(a[i]==a[i-1]+1){std::cout << 0 << std::endl;return 0;}
   }
   ans=F[a[0]-1];  
   for(int i=1;i<m;i++){
       int k=a[i]-a[i-1]-2;
       ans=(ans*F[k])%1000000007;
   }
   std::cout <<(ans*F[n-a[m-1]-1])%1000000007  << std::endl;
   
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    cout << ((K+1)/2) * (K/2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<bool> a_visit(1e9 + 2, false);
  rep(i, n){
    int a;
    cin >> a;
    if(a_visit[a]){
      cout << "NO" << endl;
      return 0;
    }else{
      a_visit[a] = true;
    }
  }
  cout << "YES" << endl;

  return 0;
}

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

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

    maxv = max(a, b);
    for (int i = 0; i < maxv; i++)
    {
        if (abs(a - i) == abs(b - i))
        {
            cout << i << endl;
            return 0;
        }
        
    }

    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;int n,m,q,a[50],b[50],c[50],d[50],o,p[10];void u(int l,int f){if(l==n){int s=0;for(int i=0;i<q;i++)if(p[b[i]-1]-p[a[i]-1]==c[i])s+=d[i];o=max(o,s);return;}for(int i=f;i<=m;i++){p[l]=i;u(l+1,i);}}int main(){cin>>n>>m>>q;for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];u(0,1);cout<<o;}


Measured memory_bytes: 3596
#include<stdio.h>

int main(){

char p[101],ch,CH;
int N;
while(scanf("%c",&ch)!=EOF){
if(ch!='@')printf("%c",ch);
else{
scanf("%c",&ch);
N=ch-'0';
scanf("%c",&CH);
for(int i=0;i<N;i++)
printf("%c",CH);

}
}
return 0;
}

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

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long[] numbers = new long[5];
        for (int i = 0; i < 5; i++) {
            numbers[i] = sc.nextLong();
        }

        Arrays.sort(numbers);
        long min = numbers[0];

        long ans = 0;
        if ((N % min) == 0) {
            ans = N / min - 1;
        }
        else {
            ans = N / min;
        }
        System.out.print(ans + 5);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21844
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string w;
	cin >> w;
	map<char, int> mp;
	REP(i, SIZE(w))
	{
		mp[w[i]]++;
	}
	REPIT(mp)
	{
		if ((*it).second % 2 > 0)
		{
			print("No");
			return 0;
		}
	}
	print("Yes");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int N, D, X;
  cin >> N >> D >> X;

  int ans = 0;

  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  for (int i = 0; i < D; i++) {
    for (int j = 0; j < N; j++) {
      if(i*vec.at(j)+1<=D){
        ans+= 1;
      }
    }
  }

  cout << ans+X << endl;

  return 0;
}

Measured memory_bytes: 3592
n    = gets.to_i
ary1 = gets.split.map(&:to_i)
ary2 = gets.split.map(&:to_i)

sum = 0
ary1.each do |i|
  sum += i
end
sum += ary2[-1]

ans = sum

(n - 1).times do |i|
  sum -= ary1[n - i - 1]
  sum += ary2[n - i - 2]
  ans  = [sum, ans].max
end

puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c, i;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for (i = max(a, max(b, c)); ; i++) {
        if (i % 2 != (a + b + c) % 2) continue;
        
        printf("%d\n", (i * 3 - (a + b + c)) / 2);
        break;
    }
    
    return 0;
}


Measured memory_bytes: 128
import bisect

n = int(input())
li = list(map(int,input().split()))
count = 0
li.sort()
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    ab = li[i] + li[j]
    x = bisect.bisect_left(li, ab, lo=0, hi=n)
    count += (x - j - 1)
 
print(count)

Measured memory_bytes: 42972
#include<iostream>
#include<string>
using namespace std;
string S;int J,I;
int main(){
	while(cin>>S){
		J=0;I=0;
		for(int i=0;i<S.size()-2;i++){
			if(S.substr(i,3)=="JOI")J++;
			if(S.substr(i,3)=="IOI")I++;
		}
		cout<<J<<endl;
		cout<<I<<endl;
	}
}

Measured memory_bytes: 3172
import sys
h, w, k = map(int, input().split())
gr = []
for i in range(h):
    gr.append(list(sys.stdin.readline().rstrip()))

ct = 0
pres = -1
for i in range(h):
    if not '#' in gr[i]:
        if ct == k:
            for j in range(w):
                gr[i][j] = gr[i-1][j]
        continue
    cr = False
    for j in range(w):
        if gr[i][j] == '#':
            ct += 1
            gr[i][j] = ct
            cr = True
        else:
            if cr:
                gr[i][j] = ct
            else:
                gr[i][j] = ct+1
        for x in range(pres+1, i)[::-1]:
            gr[x][j] = gr[x+1][j]
    pres = i
for i in range(h):
    print(' '.join(map(str, gr[i])))

Measured memory_bytes: 48624
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]:
   if A[i][2]>A[i+1][2]:return 0
 return 1
n=int(input())
f=lambda x,y:(x,int(y))
A=[(*f(*e.split()),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
print(['Not s','S'][s(A)]+'table')
for e in A:print(*e[:2])


Measured memory_bytes: 20336
def cmb(n, r):
    return fct[n] * inv[r] * inv[n - r] % md

md = 10 ** 9 + 7
n, m = map(int, input().split())
ans = 1
pa = -1
ds = []
for _ in range(m):
    a = int(input())
    if a == 1:
        pa = 1
        continue
    d = a - pa-2
    if d == -1:
        print(0)
        exit()
    ds.append(d)
    pa = a
ds.append(n - pa-1)
#print(ds)
mxd = max(ds)
fct = [1, 1]
inv = [1] * (mxd + 1)
s = 1
for i in range(2, mxd + 1):
    s = (s * i) % md
    fct.append(s)
inv[-1] = s = pow(fct[-1], md - 2, md)
for i in range(mxd, 1, -1):
    s = s * i % md
    inv[i - 1] = s
for d in ds:
    tmp = 0
    for i in range(d // 2 + 1):
        tmp = (tmp + cmb(d - i, i)) % md
    ans = (ans * tmp) % md
print(ans)


Measured memory_bytes: 11052
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static ll BASE;
    ll value = 0;
    static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
    Mod(ll value)
    : value(residue(value)) {}
    Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
    void operator+=(const Mod& rhs) { *this = *this + rhs; }
    Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
    void operator-=(const Mod& rhs) { *this = *this - rhs; }
    Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
    void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;

vector<vector<ll>> tree;
vector<bool> visited;
vector<vector<Mod>> ans;

void visit(ll idx) {
    visited[idx] = true;
    for (ll neighbour : tree[idx]) {
        if (visited[neighbour]) {
            continue;
        }
        visit(neighbour);
        ans[0][idx] *= (ans[0][neighbour] + ans[1][neighbour]);
        ans[1][idx] *= ans[0][neighbour];
    }
}

int main() {
    ll N;
    cin >> N;
    tree.resize(N);
    visited.resize(N);
    ans = make_vec_nd((Mod)1, 2, N); // 0=白, 1=黒
    for (ll i = 0; i < N-1; i++) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    visit(0);
    cout << (ans[0][0] + ans[1][0]).value << endl;
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> B(n);
    rep(i, n) cin >> B[i];

    stack<int> ans;
    rep(i, n)
    {
        bool ok = false;
        for (int j = B.size() - 1; j >= 0; j--)
        {
            if (j + 1 == B[j])
            {
                ans.push(j + 1);
                B.erase(B.begin() + j);
                ok = true;
                break;
            }
        }
        if (!ok)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, n)
    {
        cout << ans.top() << endl;
        ans.pop();
    }
}

//いわれてみれば確かにだが

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

int main()  
{  
	int n,w;
	cin>>n>>w;
	ll aa,bb;
	vector<pair<ll,ll> > val(n);
	for(int i=0;i<n;i++){
		cin>>aa>>bb;
		val[i] = {aa,bb};
	}
	
	vector<ll> dp(w+1,0);
	dp[0] = 0;
	
	for(ll i=0;i<n;i++){
		for(ll j=w;j>=0;j-- ){
			if(j-val[i].first>=0)
			dp[j] = max(dp[j],dp[j-val[i].first] + val[i].second);
		}
	}
	
	 cout<<dp[w];
    return 0;  
} 


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  string s;
  cin >> s;
  int ok = 0;
  for(char c : s){
    if(ok == 0 and c == 'C') ok = 1;
    if(ok == 1 and c == 'F') ok = 2;
  }
  cout << (ok==2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, N := getInt(), getInt(), getInt()

	i := min(N, B-1)

	ans := A*i/B - A*(i/B)
	out(ans)
}


Measured memory_bytes: 1756
#include <stdio.h>
int main(void){
    int a, b, k=0;
    
    scanf("%d %d", &a, &b);
    
    if(a <= 5){
        k = 0;
    }else if(a >= 6 && a <= 12){
        k = b / 2;
    }else if(a >= 13){
        k = b;
    }
    printf("%d\n", k);
    
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
#define ls ch[x][0]
#define rs ch[x][1]
int rd()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
const int p = 998244353;
int n,k;
int fac[1001000];
int inv[1001000];
int max(int a,int b){return a>b?a:b;}
int del(int a,int b){return ((a-b)%p+p)%p;}
int calc(int a,int b){return (a+b)%p;}
int Pow(int a,int x)
{
	int now = 1;
	for(;x;x >>= 1,a = 1ll*a*a%p) if(x&1)now = 1ll*now*a%p;
	return now;
}
int C(int i,int j)
{
	if(j > i || j < 0) return 0;
	int now = 1ll*fac[i]*inv[j]%p;
	now = 1ll*now*inv[i-j]%p;
	return now;
}
int main()
{
	n = rd();k = rd();
    int ans = 0;
    fac[0] = 1;inv[0] = 1;rep(i,1,1000000) fac[i] = 1ll*fac[i-1]*i%p,inv[i] = Pow(fac[i],p-2);
	rep(x,max((k+1)/2,n),k)
    {//(x,n-x)
    	int y = (x*2==k?k-x-1:k-x),t = x-n+1;
    	ans = calc(ans,del(C(x+y,x),C(x+y,y-t)));
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll N;
	cin >> N;

	ll A[N];
	rep(i,N) cin >> A[i];

	ll ans = 0;

	// 奇数がでたら連番にする
	rep(i,N){
		if(A[i] % 2 == 1 && i+1 < N && A[i+1] > 0){
			A[i]--;
			A[i+1]--;
			ans++;
		}
	}

	// 残りは自分自身でペアとする
	rep(i,N){
		ans += A[i] / 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())

MOD = 10**9 + 7
ans = 0
# 選ぶ個数で場合分け
# 選べる個数はK,K+1,K+2,...,N+1

# 等差数列の和S
# 項数n, 初項a,末項l,公差d
# S=(n/2)*(a+l)
# S=(n/2)*{2a+(n-1)d}

for i in range(K, N + 2):
    min_sum = i * (i - 1) // 2  # 0+1+...(項数=i)
    max_sum = (2 * N - i + 1) * i // 2  # N+(N-1)+...(項数=i)
    ans += max_sum - min_sum + 1  # minとmaxの間の数を全て取れる
    ans %= MOD

print(ans)


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

int main(){

    int n;
    cin >> n;

    vector<vector<int> > cnt(n, vector<int>(26,0));

    for(int i=0; i<n; i++){
        string s;
        cin >> s;

        int len = s.length();
        // 各文字列の各アルファベット数をカウント
        for(int j=0; j<len; j++){
            cnt[i][s[j]-'a']++;
        }
    }

    for(int i=0; i<26; i++){
        int flg=51;
        for(int j=0; j<n; j++){
           flg = min(flg, cnt[j][i]); 
        }
        if(flg == 51){  // 各アルファベットの共通数を選択
            continue;
        }
        for(int k=0; k<flg; k++){
            cout<<(char)(i+'a');
        }
    }
    cout << endl;

    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

llong GCD(llong a, llong b){
	a = abs(a), b = abs(b);
	while(b){
		a %= b;
		swap(a,b);
	}

	return a;
}

llong LCM(llong a, llong b){
	return a / GCD(a, b) * b;
}

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

	cout << LCM(a, b) << endl;

	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef	long long ll;
int main() {
  ll ans = 0;
  vector<ll> cnt(5,0);
  int N; cin>>N;
  REP(i,N) {
    string s; cin>>s;
    //    cout << s << endl;                                                            
    switch (s[0]) {
    case 'M': cnt[0]++; break;
    case 'A': cnt[1]++; break;
    case 'R': cnt[2]++; break;
    case 'C': cnt[3]++; break;
    case 'H': cnt[4]++; break;
    }
  }
  //  REP(i,5) cout << cnt[i];                                                          
  for(int i = 0; i < 5; i++) {
    for(int j = i + 1; j < 5; j++) {
      for(int k	= j + 1; k < 5;	k++) {
	ans += (cnt[i] * cnt[j] * cnt[k]);
      } 
    }
  }
  cout << ans << endl;
#ifdef DEBUG
#endif
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> ps(n);
  F0R(i, n) {
    cin >> ps[i];
  }
  int result = 0;
  FOR(i, 1, n - 1) {
    if (ps[i - 1] < ps[i] && ps[i] < ps[i + 1]) {
      result++;
    }
    else if (ps[i - 1] > ps[i] && ps[i] > ps[i + 1]) {
      result++;
    }
  }
  cout << result;
}
#endif


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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3, y3, x4, y4, hen;
  hen = y2 - y1;
  x3  = x2 - (y2 - y1);
  y3  = y2 + (x2 - x1);
  x4  = x1 - hen;
  y4  = y3 - hen;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
}

Measured memory_bytes: 256
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
	 ll x,k,d; cin >> x >> k >> d;
     x = abs(x);
     
     if(x/k < d){
     	 ll temp = (k - x/d);
     	 if(temp%2==0)
     	 	cout << (x%d);     	 
     	 else
     	 	cout << (d-(x%d));     	 
     }
     else{
     	 cout << (x - (k*d));
     }
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class E { static void Main() => new K(); }
class K
{
	const long InfL = 4011686018427387913L;
	int F => int.Parse(Console.ReadLine());
	int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
	int X, Y, V, N;
	List<Tuple<int, int>>[] es;
	void AddOneEdge(int a, int b, int w) => es[a].Add(new Tuple<int, int>(b, w));
	void AddEdge(int a, int b, int w) { AddOneEdge(a, b, w); AddOneEdge(b, a, w); }
	public K()
	{
		var I = G;
		X = I[0]; Y = I[1];
		N = F; V = X + Y;
		es = new List<Tuple<int, int>>[V];
		for (var i = 0; i < V; i++) es[i] = new List<Tuple<int, int>>();
		for (var i = 0; i < N; i++) { I = G; AddEdge(I[0] - 1, X + I[1] - 1, I[2]); }
		var used = new bool[V]; for (var i = 0; i < V; i++)
			if (!used[i])
			{
				var com = new Dictionary<int, int> { [i] = 0 };
				var queue = new Queue<Tuple<int, Tuple<int, int>>>();
				queue.Enqueue(new Tuple<int, Tuple<int, int>>(-1, new Tuple<int, int>(i, 0)));
				while (queue.Count > 0)
				{
					var t = queue.Dequeue(); var e = t.Item2;
					int p = t.Item1, v = e.Item1, w = e.Item2;
					if (used[v]) continue;
					used[v] = true;
					if (p >= 0) com[v] = w - com[p];
					foreach (var f in es[v]) queue.Enqueue(new Tuple<int, Tuple<int, int>>(v, f));
				}
				long mx = InfL, my = InfL;
				foreach (var k in com.Keys)
				{
					foreach (var e in es[k]) if (com[k] + com[e.Item1] != e.Item2) { Console.WriteLine("No"); return; }
					if (k < X) mx = Min(mx, com[k]);
					else my = Min(my, com[k]);
				}
				if (mx + my < 0) { Console.WriteLine("No"); return; }
			}
		Console.WriteLine("Yes");
	}
}

Measured memory_bytes: 34800
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;

//文件输入输出
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);

//浮点型运算
typedef long double db;
const double eps = 1e-7;
bool eq(const double &a, double const &b) { return fabs(a - b) < eps; }
bool ls(const double &a, double const &b) { return a + eps < b; }

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

int main ()
{
    int n;
    scanf("%d",&n);
    int a[maxn];
    rep(i,0,n) scanf("%d",&a[i]);

    sort(a,a+n,cmp);

    ll ans[2],cnt = 0;
    ans[0] = 0; ans[1] = 0;
    rep(i,1,n) {
        if (a[i] == a[i-1]) {
            ans[cnt++] = a[i];
            i++;
        }
        if (cnt == 2) break;
    }
    ll area = ans[0] * ans[1];
    cout<<area<<endl;

    return 0;
}

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

int main () {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	bool flag = true;
	for (int i = 1; i < n; ++i) {
		if (arr[i] >= arr[i-1] || arr[i]-1 >= arr[i-1]){
			if (arr[i] - 1 >= arr[i-1]) arr[i] -= 1;
			continue;
		}
		else {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640