akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    string s; cin >> s;
    rep(i,s.length()) {
        cout << "x";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int P = 1e9 + 7;
ll h, w, t;
ll power(ll x, ll t) {
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}
int main() {
	cin >> h >> w >> t;
	ll n = h / __gcd(h, t), m = w / __gcd(w, t);
	ll tmp = (power(2LL, n) + power(2LL, m) + power(2LL, __gcd(n, m)) - 3 + P) % P;
	ll c = __gcd(h, t) * __gcd(w, t);
	cout << power(tmp, c) << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int array[] = new int[n];
		
		for (int i = 0; i < n; i++ ) {
			array[i] = scan.nextInt();
			
			if ( i == n - 1) {
				System.out.println(array[i]);
			} else {
				System.out.print(array[i] + " ");
			}
		}

		scan.close();
		

		
		for (int i = 1; i < n; i++) {
			int v = array[i];
			int j = i - 1;
			
			while ( j >= 0 && array[j] > v) {
				array[j + 1] = array[j];
				j--;
			}
			array[j + 1] = v;
			
			for (int k = 0; k < n; k++ ) {
				if ( k == n - 1) {
					System.out.println(array[k]);
				} else {
					System.out.print(array[k] + " ");
				}
				
			}
		}
		
	}
}



Measured memory_bytes: 30408
num = gets.split(" ")
W = num[0].to_i
H = num[1].to_i
x = num[2].to_i
y = num[3].to_i
r = num[4].to_i
if x - r < 0 || x + r > W || y - r < 0 || y + r > H
    puts "No"
else
    puts "Yes"
end


Measured memory_bytes: 6872
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;



int main()
{
	Nayon;
	int a,b,i,n;
	cin>>n;
	if(n>=400 && n<=599){
		cout<<8;
	}
	else if(n>=600 && n<=799){
		cout<<7;
	}
	else if(n>=800 && n<=999){
		cout<<6;
	}
	else if(n>=1000 && n<=1199){
		cout<<5;
	}
	else if(n>=1200 && n<=1399){
		cout<<4;
	}
	else if(n>=1400 && n<=1599){
		cout<<3;
	}
	else if(n>=1600 && n<=1799){
		cout<<2;
	}
	else if(n>=1800 & n<=1999){
		cout<<1;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
string tmp="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  tmp+=tmp;
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    string out;
    cin>>out;
    rep(i,out.size()){
      int co=0;
      int count=0;
      rep(j,tmp.size()){
	co=j;
	if(tmp[j]==out[i])count++;
	if(count==2)break;
      }
      out[i]=tmp[co-in[i%n]];
    }
    cout<<out<<endl;
  }
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        System.out.println(solve(x1, y1, x2, y2));

        sc.close();
    }

    static String solve(int x1, int y1, int x2, int y2) {
        Point[] points = new Point[4];
        points[0] = new Point(x1, y1);
        points[1] = new Point(x2, y2);

        for (int i = 2; i < points.length; ++i) {
            points[i] = rotate(points[i - 2], points[i - 1]);
        }

        return String.format("%d %d %d %d", points[2].x, points[2].y, points[3].x, points[3].y);
    }

    static Point rotate(Point p, Point o) {
        int dx = p.x - o.x;
        int dy = p.y - o.y;

        return new Point(o.x + dy, o.y - dx);
    }
}

class Point {
    int x;
    int y;

    Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 35604
n=int(input())
a=[]
b=[]
for i in range(n):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

ans=0

for ii in range(n):
    i=n-ii-1
    aa=a[i]
    bb=b[i]
    ama=(bb-(aa+ans)%bb)%bb
    ans+=ama

print(ans)

Measured memory_bytes: 11052
#include<iostream>
using namespace std;
int main () {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = min(b, d) - max(a, c);
  if (ans < 0) cout << 0 << endl;
  if (ans >= 0) cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     // freopen("error.txt","w",stderr);
      ll a;
      cin>>a;
      cout<<a+a*a+a*a*a<<endl;  
    return 0;
}

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

int main()
{
  ll s;
  cin >> s;
  ll w;
  cin >> w;
  if (w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define for(x,c) for(int x=0;x<c;x++)
#define  pb(x) push_back(x)
int main(){
    str a;
    cin>>a;
	for(i,a.size()) cout<<"x"; 
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];
		sort(ALL(w));
		ll ans = w[N/2] - w[N/2-1];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main() {
	int a;
	int b;
	cin >> a;
	cin >> b;
	int i = 0;
	while ( i<1005) {
		i++;
		int c = i* 0.08 / 1;
		int d = i * 0.1 / 1;
		if (c == a && d == b) {
			cout << i;
			return 0;
		}
	}
	cout << "-1";
}

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200100;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];

void solve()
{
        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        int best = 2e9, h;
        int g1 = a[n] / 2, g2 = g1 + a[n] % 2;
        for(int i = 1; i <= n; i++){
                if(min(abs(a[i] - g1), abs(a[i] - g2)) < best){
                        best = min(abs(a[i] - g1), abs(a[i] - g2));
                        h = a[i];
                }
        }
        cout << a[n] << " " << h << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int L = Integer.parseInt(sc.next());
    int data[] = new int[N];
    int sum = 0;
    int min = Integer.MAX_VALUE;
    for (int i=0; i<N; i++) {
      data[i] = L + i;
      sum += data[i];
      if (Math.abs(min) > Math.abs(data[i])) {
        min = data[i];
      }
    }
    System.out.println(sum - min);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    FOR(i,0,N){
        if(i+3 > N) continue;

        if(S.substr(i,3) == "ABC") ans++;
        
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<vector <lint> > dp;
int ma[2010],mb[2010];
lint mo=998244353;
int main()
{
	string s;cin>>s;int n=s.size();
	ma[0]=mb[0]=0;
	rep(i,n){
		ma[i+1]=ma[i]+(s[i]-'0');
		mb[i+1]=mb[i]+2-(s[i]-'0');
	}
	//memset(dp,0,sizeof(dp));dp[0][0]=1;
	int x=ma[n],y=mb[n];
	rep(i,x+5){
		vector<lint> cl(y+5,0);dp.pb(cl);
	}
	dp[0][0]=1;
	rep(i,x+1) rep(j,y+1){
		//cout<<i<<' '<<j<<' '<<ma[i+j+1]<<' '<<mb[i+j+1]<<endl;
		dp[i][j]%=mo;
		if(i<x && i<ma[min(n,i+j+1)]) dp[i+1][j]+=dp[i][j];
		if(j<y && j<mb[min(n,i+j+1)]) dp[i][j+1]+=dp[i][j];
	}
	cout<<dp[x][y]%mo<<endl;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int x;
    cin >> x;
    cout << ((x == 0) ? 1 : 0) << std::endl;

    // write code above
    return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m = map(int, input().split())
h = list(map(int, input().split()))
ok = [True for i in range(n)]

for i in range(m):
    p = list(map(int, input().split()))
    if h[p[0]-1]<h[p[1]-1]:
        ok[p[0]-1]=False
    elif h[p[0]-1] > h[p[1]-1]:
        ok[p[1]-1] = False
    elif h[p[0]-1] == h[p[1]-1]:
        ok[p[1]-1] = False
        ok[p[0]-1] = False
cnt=0
for i in range(len(ok)):
    if ok[i]==True:
        cnt+=1
#print(ok)
print(cnt)



Measured memory_bytes: 20340
t = gets.chomp.to_i
input = gets.chomp.split(" ")
input.map!(&:to_i)
deff = 0
(0..t-2).each do |num|
    if input[num+1] < input[num]
        deff += input[num]-input[num+1]
        input[num+1] = input[num]
        
    end
end

puts deff


Measured memory_bytes: 28668
#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;
	deque<char> q;
	for (char c : S)
		q.push_back(c);
	int Q;
	cin >> Q;
	bool flip;
	flip = true;
	for (int i = 0; i < Q; i++)
	{
		int a;
		cin >> a;
		if (a == 1)
			flip = !flip;
		else
		{
			int		b;
			char	c;
			cin >> b >> c;
			if (!flip)
				b = 3 - b;
			if (b == 1)
				q.push_front(c);
			else
				q.push_back(c);
		}
	}
	if (!flip)
		reverse(q.begin(), q.end());
	string	ans;
	for (char c : q)
		ans += c;
	cout << ans << endl;
}


Measured memory_bytes: 1412
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void)
{
	long A;
	cin >> A;
	vector<long> data(A + 1);
	vector<long>gekitui(A);
	for (int i = 0; i < A + 1; i++)
	{
		cin >> data[i];
	}
	for (int i = 0; i < A; i++)
	{
		cin >> gekitui[i];
	}

	long sougekituisuu = 0;
	for (int i = 0; i < A; i++)
	{
		long sitai = min(data[i], gekitui[i]);
		sougekituisuu += sitai;
		data[i] -= sitai;
		gekitui[i] -= sitai;
		sitai = min(data[i + 1], gekitui[i]);
		sougekituisuu += sitai;
		data[i+1] -= sitai;
		
	}
	
	cout << sougekituisuu << endl;
	
}

Measured memory_bytes: 1792
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k; cin >> n >> k;
  if (k == 1) {
    cout << 0 << '\n';
    return;
  }
  cout << n % k << '\n';
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	cout << s[0] << s.size() - 2 << s.back() << "\n";

	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=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

int gcd(int,int);

int main(){
        int a,b;
        cin >> a >> b;
        cout << gcd(a,b) << endl;
}

int gcd(int a,int b){
        if (!b) return a;
        gcd(b,a%b);
}            

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    double r; 
    while(cin>>r){
        double ans = 2*M_PI*r;
        printf("%lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3804
i, o, t, j, l, s, z = map(int, input().split())

k = 0
k += (i // 2) * 2
k += o
k += (j // 2) * 2
k += (l // 2) * 2
if i%2 == 1 and j%2 == 1 and l%2 == 1:
    k += 3

kk = 0
if i >= 1 and j >= 1 and l >= 1:
    kk += 3
    i -= 1
    j -= 1
    l -= 1
kk += (i // 2) * 2
kk += o
kk += (j // 2) * 2
kk += (l // 2) * 2

print(max(k, kk))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println((x - a)%b);
	}

}


Measured memory_bytes: 22740
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793
#define MOD 100000007

#define DEBUG 1


int main (void) {
    int h, w, k, i, j;
    cin >> h >> w >> k;

    vector<pair<int, int> > sts;

    vector<string> a(h);

    rep (i, 0, h) {
        cin >> a[i];

        rep (j, 0, w) if (a[i][j] == '#') sts.emplace_back(make_pair(i, j));
    }

    vector<vector<int> > mp(h, vector<int>(w, 0));

    rep (i, 0, k)
        mp[sts[i].first][sts[i].second] = i + 1;

    rep (i, 0, k) {
        int y = sts[i].first, x = sts[i].second, l = x, r = x;

        for (int jj = x + 1; jj < w; ++jj) {
            if (a[y][jj] == '#' || mp[y][jj]) 
                break;

            mp[y][jj] = i + 1;
            r = jj;
        }

        for (int jj = x - 1; jj >= 0; --jj) {
            if (a[y][jj] == '#' || mp[y][jj]) 
                break;

            mp[y][jj] = i + 1;
            l = jj;
        }


        for (int ii = y + 1; ii < h; ++ii) {
            if (accumulate(mp[ii].begin() + l, mp[ii].begin() + r + 1, 0) == 0) {
                rep (j, l, r + 1) {
                    mp[ii][j] = i + 1;
                }
            } 
            else break;
        }

        for (int ii = y - 1; ii >= 0; --ii) {
            if (accumulate(mp[ii].begin() + l, mp[ii].begin() + r + 1, 0) == 0) {
                rep (j, l, r + 1) {
                    mp[ii][j] = i + 1;
                }
            }
            else break;
        }
            
    }


    rep (i, 0, h) {
        rep (j, 0, w) {
            cout << mp[i][j] << " ";
        }
        cout << endl;
    }



    return 0;
}

Measured memory_bytes: 1944
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 20;
vector < int > t[2][N];
int n;

void init() {
    scanf(I,&n);
    rep (i,n) {
        int m = sc.nextInt();
        rep (j,m) {
            int x, y; scanf(II,&x,&y);
            t[y][i].push_back(x-1);
        }
    }
}

void solve() {
    int ans = 0;
    rep (i,(1<<n)) { // 0 represents unkind
        int bits=0; int u=i; while (u) { bits+=(u&1); u>>=1; }
        rep (j,n) {
            if ((i>>j) & 1) {
                repe (k,t[0][j]) if ((i>>t[0][j][k]) & 1) goto nxt;
                repe (k,t[1][j]) if (!((i>>t[1][j][k]) & 1)) goto nxt;
            }
        }
        checkMax(ans,bits);
nxt:;
    }
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i<3:print('#'*20)


Measured memory_bytes: 5624
import sys

n = int(input())
aaa = [int(line) for line in sys.stdin.readlines()]
aaa.sort()
if n % 2 == 0:
    m1, m2 = aaa[n // 2 - 1], aaa[n // 2]
    mid = sum(abs(a - m1) for a in aaa)
    ans = mid * 2 - (m2 - m1)
else:
    m1, m2, m3 = aaa[n // 2 - 1], aaa[n // 2], aaa[n // 2 + 1]
    mid = sum(abs(a - m2) for a in aaa)
    ans = mid * 2 - min(m2 - m1, m3 - m2)
print(ans)


Measured memory_bytes: 14244
N = int(input())
A = [int(input()) for i in range(N)]
dict = {}
for i in range(len(A)):
    if(A[i] in dict):
        dict[A[i]] += 1
    else:
        dict[A[i]] = 1
l = list(dict.keys())
ans = 0
for i in range(len(l)):
    if(dict[l[i]] % 2 == 1):
        ans += 1
print(ans)

Measured memory_bytes: 16268
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  cnt=c
  for j in range(m):
    cnt+=a[i][j]*b[j]
  if cnt>0:
    ans+=1
print(ans)

Measured memory_bytes: 9108
let without ls j =
  let temp = ref [] in
  for i = 0 to (List.length ls) - 1 do
    if i <> j then temp := (List.nth ls i)::!temp
  done;
  List.rev !temp

let solve ar =
  let ls = Array.to_list ar in
  let rec inner cur_time = function
    | [] -> cur_time
    | ls ->
       let next_time = if (cur_time mod 10) <> 0 then
                         cur_time + (10 - (cur_time mod 10))
                       else cur_time
       in let min_time = ref max_int in
       for i = 0 to (List.length ls) - 1 do
         let l = List.nth ls i in
         let ls = without ls i in
         min_time := min !min_time (inner (next_time + l) ls)
       done;
       !min_time
  in inner 0 ls

let _ =
  let ar = Array.make 5 0 in
  for i = 0 to 4 do
    Scanf.scanf "%d\n" (fun a -> ar.(i) <- a)
  done;
  solve ar |> print_int


Measured memory_bytes: 2432
A, B, C, D = map(int, input().split())

turn_flag = True
for i in range(0, 100):
    if turn_flag:
        C -= B
        if C <= 0:
            break
        turn_flag = False
    
    else:
        A -= D
        if A <= 0:
            break
        turn_flag = True

    # print(A,B,C,D)

if turn_flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int N, M, K, p[20][1010];
inline int sum(int L1,int R1,int L2,int R2){
    return  p[L2][R2] + p[L1 - 1][R1 - 1] - p[L1 - 1][R2] - p[L2][R1 - 1] ;
}
void solve(){
	cin>>N>>M>>K;
	rep(i,0,N){
		string s;
		cin>>s;
		rep(j,0,M){
			if(s[j]=='1')p[i+1][j+1] = 1;
		}
	}
	for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) p[i][j] += p[i][j - 1]; }
    for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) p[i][j] += p[i - 1][j]; }
    int res = 1E9;
	for(int bits = 0 ;bits<(1<<(N-1));bits++){
		int n1 = __builtin_popcount(bits);
		if(n1>=res)continue;//剪枝 7ms ~ 3ms 
		VI cut;
		for(int i=0;i<N-1;i++){
			if((bits>>i)&1){
				cut.pb(i+1);
			}
		}
		cut.pb(N);
		int  pcol = 1,ans=sz(cut)-1;
		int ok = 1;
		for(int i=1;i<=M;i++){
			int f=1,prow=1;
			for(int j=0;j<sz(cut);j++){
				if(sum(prow,pcol,cut[j],i)>K){
					f = 0;
					break;
				}
				prow = cut[j]+1;
			}
			if(!f){
				ans++;
				if(pcol==i){//Impossible
					ok = 0;
					break;
				}
				pcol = i;
			}
		}
		if(ok)res = min(res,ans);
	}
	cout<<res;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

Measured memory_bytes: 256
s = list(input())
e = s[0::2]
o = s[1::2]
e_0 = e.count("0")
e_1 = e.count("1")
o_0 = o.count("0")
o_1 = o.count("1")
ans_a = e_1 + o_0
ans_b = e_0 + o_1
ans = min(ans_a, ans_b)
print(ans)

Measured memory_bytes: 4652
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;

int n, m, k;

int main() 
{
	while(scanf("%d %d %d", &n, &m, &k) != EOF)
	{
		bool flag = 0;
		for(int i = 0; i <= n; i++) {
			for(int j = 0; j <= m; j++) {
				if(k == (i * m + (n - i) * j - i * j))
					flag = 1;
			}
		}
		if(flag == 1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import collections

H, W = map(int, input().split())
A = []
for _ in range(H):
    A += list(input())
elements = collections.Counter([x % 4 for x in collections.Counter(A).values()])
c = [0]*4
for x in elements.keys():
    c[x] = elements[x]

ans = False
if H % 2 == 0 and W % 2 == 0:
    if c[1:] == [0, 0, 0]:
        ans = True

elif H % 2 != 0 and W % 2 != 0:
    if c[1] + c[3] == 1:
        if c[1] == 1:
            c[0] += 1
            c[1] = 0
        else:
            c[2] += 1
            c[3] = 0

        if c[1:] == [0, 0, 0] or c[2] <= (H + W)//2 - 1:
            ans = True 

elif H % 2 != 0:
    if c[1:] == [0, 0, 0] or (c[2] <= W//2 and c[1] + c[3] == 0):
        ans = True
else:
    if c[1:] == [0, 0, 0] or (c[2] <= H//2 and c[1] + c[3] == 0):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int h, w;
int main () {
    cin >> h >> w;
    while ((h!=0)||(w!=0)) { 
        for (int j=1;j<=h;j++) {
            for (int i=1;i<=w;i++) {
                if ((i==1)||(i==w)) {
                    cout << "#";
                }
                if ((i>1)&&(i<w)) {
                	if ((j==1)||(j==h)) {
                		cout << "#";
					} else {
						cout << ".";
					}
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
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 = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    int k; cin >> k;
    int l[n]; rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());
    int sum = 0;
    rep(i, k) sum += l[i];
    out(sum);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    io
    int n,r;
    cin >> n >> r;
    int i;
    if(n >= 10)
        i = r;
    else{
        i = r + 100*(10-n);
    }
    cout << i << "\n";
    return 0;
}

Measured memory_bytes: 256
n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import product,permutations
for i,j,k in product(range(n),range(n),range(n)):
    if d[i][j] >d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
for i,j,k in product(range(n),range(n),range(n)):
    if d[i][j] >d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
def Long(args):
    ans=0
    for i in range(len(args)-1):
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(r)))

Measured memory_bytes: 51944
#include<stdio.h>
int main(){
	int num[11][11];
	int n,i,j;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++)num[i][j]=0;
		}	
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)scanf("%d",&num[i][j]);
		}		
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)num[i][n]+=num[i][j];
		}		
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)num[n][i]+=num[j][i];
		}		
		for(i=0;i<n;i++)num[n][n]+=num[i][n];
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				if(num[i][j]>=1000 && num[i][j]<10000)printf(" %d",num[i][j]);
				else if(num[i][j]>=100 && num[i][j]<1000)printf("  %d",num[i][j]);
				else if(num[i][j]>=10 && num[i][j]<100)printf("   %d",num[i][j]);
				else if(num[i][j]>=0 && num[i][j]<10)printf("    %d",num[i][j]);
				else printf("%d",num[i][j]);
			}
		printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
#include<iomanip>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll a;
  cin >> a;
  ll b = 0;
  while (a != 1) {
   a/= 2;
   b++;
  }
  a = powl(2, b + 1);
  cout << a-1;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define irep(i, a, b) for (ll i = (a); i >= (b); i--)
#define v(t) vector<int>

using namespace std;
using ll = long long;
using vi = v(int);

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

    int N;
    cin >> N;
    vi A(N);
    int maxneg = -1, minpos = -1;
    int c = 0;
    ll s = 0;
    rep(i, 0, N - 1) {
        cin >> A[i];
        if (A[i] < 0 && maxneg == -1)
            maxneg = i;
        else if (A[i] < 0 && A[i] > A[maxneg])
            maxneg = i;
        if (A[i] >= 0 && minpos == -1)
            minpos = i;
        else if (A[i] >= 0 && A[i] < A[minpos])
            minpos = i;
        if (A[i] < 0) c++;
        s += abs(A[i]);
    }
    if (c % 2 == 0) {
        cout << s << endl;
    } else {
        if (minpos == -1) {
            s -= 2 * abs(A[maxneg]);
            cout << s << endl;
        } else {
            // cout << maxneg << endl;
            // cout << minpos << endl;
            if (abs(A[maxneg]) < abs(A[minpos]))
                s -= 2 * abs(A[maxneg]);
            else
                s -= 2 * abs(A[minpos]);

            cout << s << endl;
        }
    }
}

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

typedef long long ll;

ll def = 1000000007;

const int mod = 1000000007;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint &operator*(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

mint choose(ll n, ll a)
{
    mint x = 1, y = 1;
    for (int i = 0; i < a; ++i)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
    return 0;
}


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

#define FOR(i, a, b) for(int(i)=(a);(i)<(b);(i)++)
#define REP(i, n) FOR((i), 0, (n))

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int X;
	cin>>X;

	int x=0;
	int i=1;
	while(x < X){
		x+=i++;
	}

	cout<<i-1<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
string s;
void solve(){
    int n;
    cin>>n;
    int ar[n];
    ll total=0;
    f(i,0,n)cin>>ar[i],total+=ar[i];
    map<ll,ll>mp;
    f(i,0,n)mp[ar[i]]++;
    int q;
    cin>>q;
     while(q--){
     	ll a,b;
     	cin>>a>>b;
     	if(mp.find(a)!=mp.end()){
     		total-=mp[a]*a;
     		total+=mp[a]*b;
     		mp[b]+=mp[a];
     		mp[a]=0;
     	}
     	cout<<total<<"\n";
     }
    
  
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


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

using namespace std;

int n;
vector<vector<pair<int, int>>> e;
vector<bool> visited;
vector<bool> color;

void dfs(int u, int v, int w) {
  visited[v] = true;
  if (w % 2 == 0)
    color[v] = color[u];
  else
    color[v] = !color[u];

  for (auto it = e[v].begin(); it != e[v].end(); ++it) {
    if (!visited[(*it).first])
      dfs(v, (*it).first, (*it).second);
  }
  
}

signed main(void) {

  cin >> n;
  e = vector<vector<pair<int, int>>>(n);
  visited = vector<bool>(n, false);
  color = vector<bool>(n, false);

  for (int i = 0; i < n - 1; ++i) {
    int u, v, w; cin >> u >> v >> w;
    e[u - 1].push_back({v - 1, w});
    e[v - 1].push_back({u - 1, w});
  }

  dfs(0, 0, 0);

  for (int i = 0; i < n; ++i) {
    if (color[i])
      cout << "1" << endl;
    else
      cout << "0" << endl;
  }

  

  return 0;
}


Measured memory_bytes: 7808
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
N,K = map(int,input().split())
A = Base_10_to_n(N, K)
print(len(A))


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

int main(){
  	int N,A,temp;
  
  	cin >> N >> A;
  
  	temp = N % 500;
  
  	if(temp > A)	cout << "No" << endl;
  	else	cout << "Yes" << endl;
  
  	return 0;
}

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

int main(){
    int A,B;
    cin >> A>> B;
    int count=0;

    while(true){
        int a5=A/10000;
        int a4=(A-a5*10000)/1000;
        int a3=(A-a5*10000-a4*1000)/100;
        int a2=(A-a5*10000-a4*1000-a3*100)/10;
        int a1=(A-a5*10000-a4*1000-a3*100-a2*10);

        if(a5==a1 && a4==a2){
            count++;
        }

        if(A>=B){
            cout <<count<< endl;
            break;
        }
    

        A++;
}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<"\n";
    return 0;
}


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

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 1;
    ll lar = pow(10, 9)+7;
    REP(i, n){
        ans *= i+1;
        if(ans>lar)ans = ans%lar;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    vector<int>a(n+2);
    rep2(i,1,n)cin>>a[i];

    ll sum=0;
    rep2(i,1,n+1)sum+=abs(a[i]-a[i-1]);

    rep2(i,1,n){
        ll ans=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3748