akhauriyash/Code-Regression huggingface dataset:
S = input()

flag = True
if S[0] != "A":flag = False
if S[2:-1].count("C") != 1:flag = False
if flag:
    ind = S[2:-1].index("C") + 2
    print("AC") if (S[1:ind] + S[ind+1:]).islower() else print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();

        StringBuilder sb = new StringBuilder(s);
        loop:
        while (true) {
            int cnt = 0;
            for (int i = 0; i < sb.length(); ++i) {
                if (sb.charAt(i) == ')') {
                    --cnt;
                } else {
                    ++cnt;
                }
                if (cnt < 0) {
                    sb.insert(0, '(');
                    continue loop;
                }
            }
            while (cnt > 0) {
                sb.append(')');
                --cnt;
            }
            if (cnt == 0) {
                break;
            }
        }

        _out.println(sb);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21584
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a, b;
	double c;
	cin >> a >> b;
	c = 1.0*a / b;
	cout << a / b << " " << a%b <<" ";
	printf("%.8lf\n", c);
	return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}
ll c[1000000];
int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    if(n%2==0){
        rep(i,0,n-1){
            c[a[i]]++;
        }
        for(ll i=1;i<=n;i=i+2){
            if(c[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<hpow(2,n/2)%i_7<<endl;
        
    }else{
        rep(i,0,n-1){
            c[a[i]]++;
        }
        if(c[0]!=1){
            cout<<0<<endl;
            return 0;
        }
        for(ll i=2;i<=n;i=i+2){
            if(c[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<hpow(2,n/2)%i_7<<endl;
        
    }
    
    
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int h, w;
	int i, j;
	while (1) {
		scanf("%d %d ", &h, &w);
		if (h == 0 && w == 0)break;
		for (i = 0; i<h; i++) {
			for (j = 0; j<w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2532
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

int main() {
    int a,b;
    while(cin >> a >> b) {
        int ans = -1;
        for(int i = 10 * b ; i / 10 <= b ; i++) {
            if((int)(i * 0.08) == a) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int a,b;
    std::cin >> a >> b;
    if(a<b) std::cout << "a < b" << std::endl;
    else if(a>b) std::cout << "a > b" << std::endl;
    else std::cout << "a == b" << std::endl;
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    string s;
    cin >> s;
    if (s == ".") return 0;
    
    reverse(s.begin(), s.end());
    
    int p;
    cin >> p;
    
    int hash;
    map<int, int> mp;
    for (int num = 0; num < 10000; num++) {
      vector<int> x(4);
      int tmp = num;
      for (int i = 3; i >= 0; i--) {
        x.at(i) = tmp % 10;
        tmp /= 10;
      }
      
      stack<int> st;
      for (int i = 0; i < s.size(); i++) {
        if (s[i] == '[' || s[i] == ']') continue;
        if ('a' <= s[i] && s[i] <= 'd') st.push(x[s[i] - 'a']);
        
        if (s[i] == '+') {
          int k1 = st.top();
          st.pop();
          int k2 = st.top();
          st.pop();
          int k3 = (k1 | k2);
          st.push(k3);
        }
        if (s[i] == '*') {
          int k1 = st.top();
          st.pop();
          int k2 = st.top();
          st.pop();
          int k3 = (k1 & k2);
          st.push(k3);
        }
        if (s[i] == '^') {
          int k1 = st.top();
          st.pop();
          int k2 = st.top();
          st.pop();
          int k3 = (k1 ^ k2);
          st.push(k3);
        }
      }
      
    mp[st.top()]++;
    if (p == num) hash = st.top();
    }
    
    cout << hash << " " << mp[hash] << '\n';
  }
}


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

int main(){
    char a;
    std::cin >>a;
    if(a=='A'){
        std::cout << 'T' << std::endl;
    }
    if(a=='T'){
        std::cout << 'A'<< std::endl;
    }
    if(a=='C'){
        std::cout << 'G' << std::endl;
    }
    if(a=='G'){
        std::cout << 'C' << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
#define ll long long

int main(){
    std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int blood=c,cnt=0;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout <<"No"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3652
// 解き直し.
// https://img.atcoder.jp/abc166/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
const string ABC[] = {"AB", "BC", "CA"};

int main(){
    
    // 1. 入力情報.
    int N;
    LL A, B, C;
    map<char, LL> m;
    vector<string> v;
    scanf("%d %lld %lld %lld", &N, &A, &B, &C);
    m['A'] = A, m['B'] = B, m['C'] = C;
    rep(i, N){
        char c[11];
        scanf("%s", c);
        string s(c);
        // 配列ABC を使いたいので, "AC" は, "CA" と 見る.
        if(s == "AC") s = "CA";
        v.pb(s);
    }
    
    // 以下, 解説通り.
    // 2. A, B, C が 負にならないように操作できるか？
    bool ok = true;
    queue<char> q;
    
    // 2-1. A + B + C = 0.
    if(A + B + C == 0) ok = false;
    
    // 2-2. A + B + C = 1.
    if(A + B + C == 1){
        rep(i, N){
            // "AB", "AC", "BC" の いずれに等しいか確認.
            rep(j, 3){
                if(ABC[j] == v[i]){
                    char x = ABC[j][0], y = ABC[j][1];
                    if(m[x] > m[y]) m[x]--, m[y]++, q.push(y);
                    else            m[x]++, m[y]--, q.push(x);
                    if(m[x] < 0 || m[y] < 0) ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
    }
    
    // 2-3. A + B + C >= 2.
    if(A + B + C >= 2){
        rep(i, N){
            // "AB", "AC", "BC" の いずれに等しいか確認.
            rep(j, 3){
                if(ABC[j] == v[i]){
                    char x = ABC[j][0], y = ABC[j][1];
                    if(m[x] > m[y]){
                        m[x]--, m[y]++, q.push(y);
                    }else{
                        if(m[x] == 1 && m[y] == 1){
                            if(i < N - 1 && v[i] != v[i + 1]){
                                // 次の要素.
                                char nx = v[i + 1][0], ny = v[i + 1][1];
                                if(x == nx || x == ny) m[x]++, m[y]--, q.push(x);
                                else                   m[x]--, m[y]++, q.push(y);
                            }else{
                                m[x]++, m[y]--, q.push(x);
                            }
                        }else{
                            m[x]++, m[y]--, q.push(x);
                        }
                    }
                    if(m[x] < 0 || m[y] < 0) ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
    }
    
    // 3. 出力.
    printf("%s\n", ok ? "Yes" : "No");
    if(ok){
        while(!q.empty()){
            char ans = q.front();
            q.pop();
            printf("%c\n", ans);
        }
    }
    return 0;
    
}

Measured memory_bytes: 7484
N = input()
 
if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
    print('hon')
     
elif N[-1]=='0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8':
    print('pon')
     
else:
    print('bon')

Measured memory_bytes: 9048
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        s: [u64; 2]
    }
    let mut ss = s.clone();
    ss.sort();
    for i in 0..ss[1]{
        print!("{}", ss[0]);
    }
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
enum = enumerate
inf = 1001001002002002002

import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

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

def bye(res):
	sT = "No Yes".split()
	print(sT[res])
	#exit(0)

def sol2(N,A,B,C,D):
	dM = dict({0: 0, 1: D})
	
	def dfs(n):
		if n in dM:
			return dM[n]

		res = min(
				D*n,
				D*(n%2) + A + dfs(n//2),
				D*(n%3) + B + dfs(n//3),
				D*(n%5) + C + dfs(n//5),
				D*(n%2) + A + dfs((n+1)//2),
				D*((3 - n%3)%3) + B + dfs((n+2)//3),
				D*((5 - n%5)%5) + C + dfs((n+4)//5)
			)

		dM[n] = res
		return res
	
	dfs(N)
	#print(dM)###
	print(dM[N])


def main():
	T, = linput()
	for _ in "*"*T:
		sol2(*linput())

def ran():
	vRan = [random.randint(1,10) for _ in "*"*5]
	print(vRan)
	sol2(*vRan)

if __name__ == "__main__":
	main()
	#ran()


Measured memory_bytes: 99880
w=raw_input()
n=input()
l=['print','replace','reverse']
for i in range(n):
    c=map(str,raw_input().split())
    if c[0]==l[0]:
        print w[int(c[1]):int(c[2])+1]
    elif c[0]==l[1]:
        w=w[:int(c[1])]+c[3]+w[int(c[2])+1:]
    else:
        w=w[0:int(c[1])]+w[int(c[1]):int(c[2])+1][::-1]+w[int(c[2])+1:]


Measured memory_bytes: 4676
from collections import deque
N, M = map(int,input().split())
graph = [[] for i in range(N + 1)]
dist = [-1] * (N + 1)
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

dist[1] = 1
q = deque([1])
while q:
    x = q.popleft()
    for j in graph[x]:
        if dist[j] == -1:
            q.append(j)
            dist[j] = x
ans = dist[2:]
if -1 in ans:
    print("No")
else:
    print("Yes")
    print(*ans, sep = "\n")

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


bool l[26];

int main()
{
  string s;cin>>s;
  for(auto x : s)l[x-'a']=true;
  for(int i=0;i<26;i++)
    if(!l[i])
      {
	printf("%c\n",i+'a');
	return 0;
      }
  printf("None\n");
  return 0;
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if(A+B>C+D){
    cout<<"Left"<<endl;
  }
  
  else if (A+B==C+D) {
    cout<<"Balanced"<<endl;
  }
  
  else {
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h> 
int main()
{
	
	int x,a,b,m,n;
	while(scanf("%d%d%d",&x,&a,&b)!=EOF)
	{
		m=abs(x-a);
		n=abs(x-b);
		if(m>n)
		printf("B\n");
		else
		printf("A\n"); 
	}
	return 0;
}

Measured memory_bytes: 128
class Dice
  def init
    @up_value    = 1
    @front_value = 2
    @right_value = 3
    @left_value  = 4
    @back_value  = 5
    @down_value  = 6
  end

  def move_north
    tmp = [@front_value, @up_value, @back_value, @down_value]
    @up_value, @back_value, @down_value, @front_value = tmp
  end

  def move_east
    tmp = [@left_value, @up_value, @right_value, @down_value]
    @up_value, @right_value, @down_value, @left_value = tmp
  end

  def move_west
    tmp = [@right_value, @up_value, @left_value, @down_value]
    @up_value, @left_value, @down_value, @right_value = tmp
  end

  def move_south
    tmp = [@back_value, @up_value, @front_value, @down_value]
    @up_value, @front_value, @down_value, @back_value = tmp
  end

  def move_right
    tmp = [@right_value, @front_value, @left_value, @back_value]
    @front_value, @left_value, @back_value, @right_value = tmp
  end

  def move_left
    tmp = [@left_value, @front_value, @right_value, @back_value]
    @front_value, @right_value, @back_value, @left_value = tmp
  end

  def up_value
    @up_value
  end
end

dice = Dice.new
array = []

while (num = gets.to_i) != 0
  dice.init
  sum = 1
  num.times do
    operation = gets.chomp
    case operation
    when "North"
      dice.move_north
    when "East"
      dice.move_east
    when "West"
      dice.move_west
    when "South"
      dice.move_south
    when "Right"
      dice.move_right
    when "Left"
      dice.move_left
    end
  sum += dice.up_value
  end
  array << sum
end

puts array

Measured memory_bytes: 8880
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	int A, B;
	cin >> A >> B;
	Cout((A+B)%24);
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class CReplacingInteger {
public:
	void solve(istream& in, ostream& out) {
        ll n,k;
        in >> n >> k;
        ll a = n % k;
        ll ans = min(a,abs(k-a));
        out << ans << endl;
	}
};

int main() {
	CReplacingInteger solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main()
{
  using namespace std;
  string S = "";
  cin >> S;

  // cout << S.length();
  if (S[2] == S[3] && S[4] == S[5])
  {
    cout << "Yes";
  }
  else
    cout << "No";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

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

	std::vector<lld> v(n);
	lld ans=0;
	for(lld i=0;i<n;i++)
		cin>>v[i];

	lld max=v[0];
	for(lld i=1;i<n;i++)
	{
		if(v[i]<max)
		{
			ans+=(max-v[i]);
		}

		else
			max=v[i];
	}

	cout<<ans<<endl;
}

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

int main()
{
	int q;
	scanf("%d", &q);
	
	long long s = 0;
	
	while (q--){
		long long p, n;
		string c;
		cin >> p >> c >> n;
		if (c == "(") s += n;
		else s -= n;
		
		puts(s == 0 ? "Yes" : "No");
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll gi() {
    ll x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n;
ll a[N],b[N],c[N];
int pri[N],tot=0;
bool vis[N];
void init() {
    const int n=5000;
    vis[1]=1;
    for(int i=2;i<=n;i++) {
        if(!vis[i]) pri[++tot]=i;
        for(int j=1;j<=tot&&i*pri[j]<=n;j++) {
            vis[i*pri[j]]=1;
            if(i%pri[j]==0) break;
        }
    }
}
map<ll,int> cnt;
map<ll,bool> M;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    init();
    for(int i=1;i<=n;i++) {
        ll x=a[i],u=1,v=1;
        for(int j=1;j<=tot;j++)
            if(x%pri[j]==0) {
                int cnt=0;
                while(x%pri[j]==0) x/=pri[j],cnt++;
                cnt%=3;
                if(cnt==1) u*=pri[j],v*=pri[j]*pri[j];
                else if(cnt==2) u*=pri[j]*pri[j],v*=pri[j];
            }
        if(x>1) {
            ll t=sqrt(x)+2;
            while(t*t>x) t--;
            if(t*t==x) u*=x,v*=t;
            else u*=x,v*=x*x;
        }
        cnt[u]++;b[i]=u;c[i]=v;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(!M[b[i]]) {
            M[b[i]]=M[c[i]]=1;
            if(b[i]==c[i]) ans++;
            else ans+=max(cnt[b[i]],cnt[c[i]]);
        }
    printf("%d\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


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

int K=1000000000;

int main(){
  int N;
  cin >> N;
  set<int> p={};
  int A;
  for (int i=0;i<N;i++){
    cin >> A;
    auto q=p.insert(A);
    if (q.second==false){
      p.erase(A);
    }
  }
  cout << p.size() << endl; 
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <iostream>

const std::string units[] = {
    "", "Man", "Oku", "Cho", "Kei", "Gai", "Jo",
    "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs",
    "Asg", "Nyt", "Fks", "Mts"
};
const int MAX_D = 400;

struct Integer{
    Integer(int i = 0){
        memset(digits, 0, sizeof(digits));
        n = 0;
        
        while(i > 0){
            digits[n++] = i % 10;
            i /= 10;
        }
    }
    Integer(const std::string& s){
        memset(digits, 0, sizeof(digits));
        n = 0;
        
        bool f = false;
        for(int j=(int)s.size()-1;j>=0;j--){
            if(!std::isdigit(s[j])){continue;}
            
            if(s[j] != '0'){
                digits[n++] = s[j] - '0';
                f = true;
            }else if(f){
                digits[n++] = s[j] - '0';
            }
        }
    }
    int digits[MAX_D], n;
};

Integer operator*(const Integer& lhs, const Integer& rhs){
    Integer res;
    for(int i=0;i<MAX_D;i++){
        for(int j=0;j<MAX_D;j++){
            if(i + j >= MAX_D){continue;}
            int x = lhs.digits[i] * rhs.digits[j] + res.digits[i+j];
            res.digits[i+j] = x % 10;
            if(i + j + 1 < MAX_D){
                res.digits[i+j+1] += x / 10;
            }
        }
    }
    
    return res;
}

Integer operator+(const Integer& lhs, const Integer& rhs){
    Integer res;
    for(int i=0;i<MAX_D;i++){
        int x = lhs.digits[i] + rhs.digits[i] + res.digits[i];
        res.digits[i] = x % 10;
        if(i+1 < MAX_D){
            res.digits[i+1] = x / 10;
        }
    }
    
    return res;
}

int main(){
    int M, N;
    while(scanf("%d %d", &M, &N), M || N){
        Integer num(1), a(M);
        while(N > 0){
            if(N & 1){num = num * a;}
            a = a * a;
            N >>= 1;
        }

        int mx;
        bool f = false;
        for(int i=MAX_D-1;i>=0;i--){
            if(num.digits[i] != 0){f = true;}

            if(f){
                mx = i;
                break;
            }        
        }
        
        std::string S = "";
        for(int i=mx;i>=0;){
            int x = 0;
            while(true){
                x = x * 10 + num.digits[i];
                if(i % 4 == 0){break;}
                i--;
            }
            if(x > 0){
                S += std::to_string(x) + units[i/4];
            }
            i--;
        }

        std::cout << S << std::endl;
    }
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N, K;
	long ans = 0;
	char D[11][4];
	long i, j;
	char buf[100];
	
	scanf("%ld %ld", &N, &K);
	for(i=1;i<=K;i++) {
		scanf("%s", D[i]);
	}
	
	ans = N;
	while(1) {
		sprintf(buf, "%ld", ans);
		for(i=1;i<=K;i++) {
			if(strstr(buf, D[i]) != NULL) break;
		}
		if(i > K) break;
		ans++;
	}
	
	printf("%ld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import math
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

f = min(a, b, c, d, e)
if n % f == 0:
    print(n // f - 1 + 5)
else:
    print(n // f + 5)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    int n;
    cin >> n;
    n /= 100;
    string ei1333 = "ai1333";
    for (int i = 0; i < n; i++) {
        ei1333 += '3';
    }
    cout << ei1333 << endl;
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}

int main ()
{
	int n, k; read (n), read (k);
	long long ans = 0;
	for (int i = k; i <= n + 1; ++i) {
		long long lef = 1LL * (i - 1) * i / 2, rig = 1LL * i * (2 * n - i + 1) / 2;
		ans = (ans + rig - lef + 1) % 1000000007;
		// debug ("%lld %lld %lld\n", i, lef, rig);
	}
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3760
a,b,c,k = map(int, input().split())
ans = 0
l = [a,b,c]
while k>0:
    if k < a:
        ans=k
        break
    else:
        ans += a 
        k-=a  
        a-=a 
    if k ==0:
        break    
    if k > b:
        k-=b
        b-=b
    else:
        k-=k
        b-=k    
    if k ==0:
        break    
    if k < c:
        ans += -k 
        k-=k
    else:
        ans += -c
        k -= c
    if k ==0:
        break 
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s ;
    int k=0;
    if(s[0]=='o') k++;
    if(s[1]=='o') k++;
    if(s[2]=='o') k++;
    cout << 700+100*k<<endl;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
sum_li = []
for i,l in enumerate(li):
    if i == 0:
        sum_li.append(l)
        continue
    sum_li.append(sum_li[-1]+l)
all_li = []
for ii,ss in enumerate(sum_li):
    if ii == len(sum_li)-1:
        break
    all_li.append(abs(s-2*ss))
#print(all_li)
print(min(all_li))

Measured memory_bytes: 100300
N, M = list(int(i) for i in input().split())


K = {}
for i in range(0, N):
    tmp_list =  list(int(i) for i in input().split())
    K[i] = tmp_list


# result = K[0][0]
foods_set = set(K[0][1:])
for i in range(1, N):
    foods_set = set(foods_set) & set(K[i][1:])
    result = len(foods_set)
    if(result == 0): 
        break

print(len(foods_set))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var list = new List<KeyValuePair<int, int>>();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine();
                var ar = input.Split(' ');
                list.Add(new KeyValuePair<int, int>(int.Parse(ar[0]), int.Parse(ar[1])));
            }

            var sum = 0;
            foreach (var item in list.OrderBy(t => t.Value))
            {
                sum += item.Key;
                if (sum > item.Value)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


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

  
int main(){
 int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) <<endl;
  
   
 
}
 

Measured memory_bytes: 256
n = gets.chomp.to_i
ss = n.times.map { gets.chomp }

dict = {}
ss.each do |s|
  key = s.chars.sort.join
  dict[key] = (dict[key] || 0) + 1
end

cnt = 0
dict.each do |k, v|
  next if v <= 1
  cnt += (v * (v - 1)) / 2
end

puts cnt


Measured memory_bytes: 37004
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals("H") & b.equals("H")){
		    System.out.println("H");
		}else if(a.equals("H") & b.equals("D")){
		    System.out.println("D");
		}else if (a.equals("D") & b.equals("H")){
		    System.out.println("D");
		}else{
		    System.out.println("H");
		}
	}
}


Measured memory_bytes: 20820
N = int(input())
s = [int(input()) for _ in range(N)]

if sum(s)%10 != 0:
    print(sum(s))
    exit()

ans = 0

for i in s:
    tmp = sum(s) - i
    if tmp%10 != 0:
        ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] input = (Console.ReadLine().Split(' '));
        int[] array = input.Select(int.Parse).ToArray();

        int sum = 0;
        sum = (array[0] * 3 + array[1]) / 2;
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

int main(void){
  char n[2000000];
  scanf("%s",n);


  int ans = 0;
  for(int i = 0;n[i] != '\0';i ++){
    ans += n[i] - '0';
  }

  if(ans%9 == 0){
    printf("Yes\n");
  }

  else{
    printf("No\n");
  }

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 1;
  int first_num = 0;
  int last_num = 0;
  int trend = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (first_num == 0) {
      first_num = A;
      last_num = A;
      continue;
    }
    if (trend == 0) {
      if (A - first_num > 0) trend = 1;
      else if (A - first_num < 0) trend = 2;
    }
    if ((trend == 1 && A < last_num) || (trend == 2 && A > last_num)) {
      first_num = A;
      trend = 0;
      ans++;
    }
    last_num = A;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int r;

  cin >> r;

  cout << r * r;

  return 0;
}

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

#define ll long long

int main() {
	int n, k;
	int i;
	int sum = 0;
	cin >> n >> k;
	vector<int>p(n);
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	for (i = 0; i < k; i++) {
		sum += p[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N, M;
	cin >> N >> M;
	ll ans = 0;
	vector<int>A(N);
	priority_queue<int>waribiki;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += A[i];
		while (A[i] > 0) {
			waribiki.push(A[i] - (A[i]/2));
			A[i] /= 2;
		}
	}

	int cnt = 0;
	while (cnt < M && waribiki.size()) {
		ans -= waribiki.top();
		waribiki.pop();
		cnt++;
	}
	puts(ans);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int n, k;
  cin >> n >> k;

  int res = 1;

  int ans = 1 + k * n;
  vector<int> v(n);
  rep(i, n + 1) {
    res = res * pow(2, i);
    res += k * (n - i);
    debug(res);

    ans = min(ans, res);

    res = 1;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=100;
int arr[N+10][N+10],fx[10]={0,1,0,-1,1,1,-1,-1},fy[10]={1,0,-1,0,1,-1,1,-1};
inline void paint(int x,int y)
{
	for(int i=0;i<8;i++)	arr[x+fx[i]][y+fy[i]]=1;
}
int main()
{
	int a=ri(),b=ri(),j,i,nowx=2,nowy=2,flag=0;
	if(a>b)	swap(a,b),flag=1;
	for(i=1;i<=a-1;i++)
	{
		paint(nowx,nowy);
		nowx+=4;
		if(nowx+1>N)	nowx=2,nowy+=4;
	}
	b-=a-1;
	nowx=1,nowy+=3;
	for(i=1;i<=b;i++)
	{
		arr[nowx][nowy]=1;
		nowx+=2;
		if(nowx>N)	nowx=1,nowy+=2;
	}
	printf("100 100\n");
	for(i=1;i<=N;i++,puts(""))
		for(j=1;j<=N;j++)
			printf("%c",(arr[i][j]==1)^flag?'#':'.');
//	printf("nowx=%d nowy=%d\n",nowx,nowy);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 K, A[101010], B[101010];

i64 solve(i64 lim)
{
	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		if ((lim & A[i]) == A[i]) {
			ret += B[i];
		}
	}
	return ret;
}

int main()
{
	scanf("%d%lld", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%lld%lld", A + i, B + i);
	}

	i64 ret = solve(K);
	for (int i = 0; i < 30; ++i) {
		if (K & (1 << i)) {
			i64 K2 = (K - (1 << i)) | ((1 << i) - 1);
			ret = max(solve(K2), ret);
		}
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int Mod = 998244353;
int D2[11][1024];
vector<int>D[11][1024];
vector<int> Do(string S);
int Do2(string S) {
	if (S.size() == 1) {
		if (S[0] == '0')return 1;
		return 2;
	}
	int n = S.size(), i, j, k, res = 0, ss = 0;
	if (n <= 10) {
		for (i = 0; i < n; i++)ss += (S[i] - '0') << i;
		if (D2[n][ss] != -1)return D2[n][ss];
	}
	for (i = 1; i < n; i++) {
		if (n%i)continue;
		vector<int>V(i);
		for (j = 0; j < n; j += i) {
			for (k = j; k < j + i; k++) {
				if (S[k] == '0')V[k - j] = 1;
			}
		}
		string p = "";
		for (j = 0; j < i; j++) {
			if (V[j])p += '0';
			else p += '1';
		}
		res = (res + Do(p)[p.size()-1]) % Mod;
	}
	if (n <= 10)D2[n][ss] = res;
	return res;
}
vector<int> Do(string S) {
	if (S.size() == 1) {
		if (S[0] == '0')return { 1 };
		return { 2 };
	}
	int n = S.size(), i, j, k, res = Do2(S), ss = 0;
	if (n <= 10) {
		for (i = 0; i < n; i++)ss += (S[i] - '0') << i;
		if (!D[n][ss].empty())return D[n][ss];
	}
	string T = S;
	T.pop_back();
	vector<int>DD = Do(T);
	string tp = "";
	for (i = n-1; i > 0; i--) {
		tp = S[i] + tp;
		res = (res + (long long)DD[i - 1] * Do2(tp)) % Mod;
	}
	DD.push_back(res);
	if (n <= 10)D[n][ss] = DD;
	return DD;
}
int main() {
	int i, j;
	for (i = 1; i <= 10; i++)for (j = 0; j < (1 << i); j++)D2[i][j] = -1;
	char p[110];
	scanf("%s", p);
	string S = p;
	printf("%d\n",Do(S)[S.size()-1]);
}

Measured memory_bytes: 1020
s = input()
if len(s) % 2 == 0:
    ans = True
    for i in range(len(s)//2):
        if s[2*i] != "h" or s[2*i+1] != "i":
            ans = False
            print("No")
            break
    if ans:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);
    int n;
    scanf("%d",&n);

    int ans = 0;

    if(n%2==0){
        ans=x-y;
    }else{
        ans=y-x;
    }

    cout << ans << endl;
   
    return 0;
}
 
 


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

int main()
{
    map<ll, int> mp;
    rep(i, 1, 1000000){
        mp[i*i] = 1;
    }
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll> (d));
    rep(i, 0, n) rep(j, 0, d) cin >> x[i][j];
    ll ans = 0;
    rep(i, 0, n-1) rep(j, i+1, n){
        ll dist = 0;
        rep(k, 0, d){
            dist += pow((x[i][k] - x[j][k]), 2);
        }
        if(mp[dist]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 66096
#include <stdio.h>
#include <ctype.h>
int a,b,i;
int main() {
 scanf("%d %d",&a,&b);
 
 char s[a];
 
 for(i=0;i<=a;i++)
  {
   scanf("%c",&s[i]);
  }
 
  
 for(i=0;i<=a;i++)
 {
   if(i==b)
   {
     s[i]=tolower(s[i]);
   }
 }
 
 for(i=0;i<=a;i++)
  {
   printf("%c",s[i]); 
  }
 

 return 0;
 
 } 

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

ll N, M;
struct UnionFind{
    vector<int> parents;
    vector<int> rank;
    UnionFind(int n){
        parents.resize(n);
        rank.assign(n, 1);
        REP(i, n){
            parents[i] = i;
        }
    }
    int find(int x){
        if(parents[x] == x) return x;
        return parents[x] = find(parents[x]);
    }
    
    int unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return -1;
        if(rank[x] > rank[y]) parents[y] = x;
        else{
            parents[x] = y;
            if(rank[x]==rank[y]) rank[y]++;
        }
        return 0;
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

struct edge{ll to, cost;};
vector<vector<edge> > edges;
vector<ll> val;
bool isValid = true;
void solve(ll st) {
    for(auto x: edges[st]) {
        if (val[x.to] == -INF*INF) {
            val[x.to] = val[st] + x.cost;
            solve(x.to);
        } else if (val[x.to] != val[st] + x.cost) {
            isValid = false;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N >> M;
    UnionFind uf(N);
    edges.resize(N, vector<edge>());
    val.resize(N, -INF*INF);
    REP(i, M) {
        ll L, R, D;
        cin >> L >> R >> D;
        L--;
        R--;
        uf.unite(L, R);
        edges[L].pb(edge{R, D});
        edges[R].pb(edge{L, -D});
    }
    unordered_set<ll> roots;
    REP(i, N) {
        roots.insert(uf.find(i));
    }
    for(auto x: roots) {
        val[x] = 0;
        solve(x);
    }
    if (isValid) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 17280
#include<iostream>

using namespace std;

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

	long long sum = 0;
	


	for (int i = k; i <= n + 1; i++) {
		sum += i * (n - i + 1) + 1;
	
	}

	cout << sum%1000000007 << endl;
	


	return 0;
}

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

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

    vector<int> v;
    int cnt = 0;
    bool has_zero = false;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;

        if (a < 0)
            cnt += 1;

        if (a != 0)
            v.push_back(abs(a));
        else
            has_zero = true;
    }
    
    sort(v.begin(), v.end());

    long long int ans = 0;
    if (cnt % 2 == 0 || has_zero){
        for (auto i: v)
            ans += i;
    }
    else{
        for (int i = 1; i < (int) v.size(); i++)
            ans += v[i];
        ans -= v[0];
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				begin(c), std::end(x)
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define INF					(int)1e4+1

using namespace std;
typedef long long ll;
typedef vector<int> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T>inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int h, w;

int main()
{
	cin >> h >> w;

	vvdef v(w, vdef(h, INF));
	string s;
	struct Point
	{
		int x;
		int y;
	};
	queue<Point> que;

	REP(i, h)
	{
		cin >> s;
		REP(j, w)
		{
			if (s[j] == '#')
			{
				v[j][i] = 0;
				Point p = { j, i };
				que.push(p);
			}
		}
	}

	int ans = 0;

	while (!que.empty())
	{
		Point p = que.front();
		que.pop();
		int xx = p.x;
		int yy = p.y;

		int comp = xx - 1;
		if (xx > 0 && v[comp][yy] == INF)
		{
			v[comp][yy] = v[xx][yy] + 1;
			Point p = { comp, yy };
			que.push(p);
			chmax(ans, v[comp][yy]);
		}

		comp = xx + 1;
		if (xx < w - 1 && v[comp][yy] == INF)
		{
			v[comp][yy] = v[xx][yy] + 1;
			Point p = { comp, yy };
			que.push(p);
			chmax(ans, v[comp][yy]);
		}

		comp = yy - 1;
		if (0 < yy && v[xx][comp] == INF)
		{
			v[xx][comp] = v[xx][yy] + 1;
			Point p = { xx, comp };
			que.push(p);
			chmax(ans, v[xx][comp]);
		}

		comp = yy + 1;
		if (yy < h - 1 && v[xx][comp] == INF)
		{
			v[xx][comp] = v[xx][yy] + 1;
			Point p = { xx, comp };
			que.push(p);
			chmax(ans, v[xx][comp]);
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12432
#include<iostream>
#include<string>
using namespace std;
int main () {
 string s, p;
 cin >> s;
 cin >> p;
 
 s += s;
 
 if(s.find(p) != string::npos) {
  cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
  }

}

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

int main(){
  int n;
  string s;
  int maxi = 0;
  int x = 0;

  cin >> n >> s;

  for(int i=0;i < n;i++){

    if(s[i] == 'I')
      {
       	x++;
	maxi = max(maxi,x);

      }
    if(s[i] == 'D')
      {
       	x--;
	maxi = max(maxi,x);
      }
  }
  cout << maxi << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int x,y,s;
    while (cin >> x >> y >> s, s) {
        int ans = 0;
        for (int i=1; i<s; i++) for (int j=1; j<s; j++) {
            int a = i*(100+x)/100;
            int b = j*(100+x)/100;
            if (a+b == s) {
                int t = i*(100+y)/100 + j*(100+y)/100;
                ans = max(ans,t);
            }
            
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3092