akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);

    for (int i = 0; i < N; i++) {
        int t;
        int target_x;
        int target_y;
        scanf("%d%d%d", &t, &target_x, &target_y);
        // 指定位置に辿り着けるか
        if (t - (target_x + target_y) < 0) {
            printf("No");
            return 0;
        }
        // 時刻tが余っている場合、偶数であれば戻ることが指定位置に戻ることが可能
        if ((t - (target_x + target_y)) % 2 == 0) {
            continue;
        } else {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll n,k,i,j;
    cin>>n>>k;
    if(n>=13){
        cout<<k;
    }
    else if(n>=6&&n<=12)
        cout<<k/2;
        else
    cout<<0;


    return 0;
}





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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(j < a && i < b) printf("0");
      else if(j >= a && i < b) printf("1");
      else if(j < a && i >= b) printf("1");
      else printf("0");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,A[200000];
    cin>>n;
    rep(i,n) cin>>A[i];
    int m=0,a;
    rep(i,n) if(m<A[i]) m=A[i],a=i;
    sort(A,A+n);
    rep(i,n){
        if(i==a) cout<<A[n-2]<<endl;
        else cout<<A[n-1]<<endl;
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=2e5+3;
ll M=1e9+7;
ll BM(ll a,ll b)
{
    ll k=1;
    while(b!=0)
    {
        if(b%2==1)
        {
            k=(k*a)%M;
        }
        a=(a*a)%M;
        b/=2;
    }
    return k;
}
int main()
{
    ft
    ll x,y,z,n;
    cin>>n;
    x=BM(10,n);
    y=BM(9,n);
    z=BM(8,n);
    cout<<(x-2*y+z+5*M)%M<<"\n";
    return 0;
}

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

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

  char b;
  cin >> b;
  switch (b) {
    case 'A': cout << 'T' << endl; break;
    case 'C': cout << 'G' << endl; break;
    case 'G': cout << 'C' << endl; break;
    case 'T': cout << 'A' << endl; break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    ll ans = 0;
    cin >> a ;
    if(a>=10) a %=10;
    if(a==0||a==1||a==6||a==8) cout << "pon";
    else if(a==3) cout << "bon";
    else cout << "hon";
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
 
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        int h[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        long sum = 0;
        //c[0] += 1;
        //int sum = 0;
        //boolean flag = true;
        for(int i = 0; i < n; i++){
            h[i] += stdIn.nextInt();
        }
        
        Arrays.sort(h);
        
        for(int i = 0; i < n - k; i++){
            sum += h[i];
        }
        
        // if(sum >= h){
        //     System.out.println("Yes");
        // }else{
        //     System.out.println("No");
        // }
        
        System.out.println(sum);
 
        //System.out.println();
        //System.out.print();
 
        stdIn.close();
    }
}

Measured memory_bytes: 64728
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,d,x;
  cin>>n>>d>>x;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans=x;
  rep(i,n){
    for(j=0;1+j*a[i]<=d;j++)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
x = a[0]
if a[1] == 0 :
    print(x)
else :
    b = list(map(int,input().split()))
    retu = []
    for i in range(0,102) :
        retu.append(i)
    for i in b :
        if i in retu :
            retu.remove(i)
    k = 1000
    ans = 0
    for i in retu :
        y = abs(i - x)
        if y < k :
            k = y
            ans = i
    print(ans)

Measured memory_bytes: 9088
import queue

K = int(input())

q = queue.Queue()
for i in range(1, 10):
    q.put(i)

for i in range(K):
    q_K = q.get()
    q_K_mod10 = q_K % 10
    if q_K_mod10 != 0:
        q.put(10 * q_K + q_K_mod10 - 1)
    q.put(10 * q_K + q_K_mod10)
    if q_K_mod10 != 9:
        q.put(10 * q_K + q_K_mod10 + 1)

print(q_K)

Measured memory_bytes: 12480
#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() {
    int n, m, a;
    cin >> n >> m;
    vector<int> vec(n);
    rep(i, m * 2) {
        cin >> a;
        vec.at(a-1)++;
    }
    rep(i, n) {
        cout << vec.at(i) << endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define maxn 200015
#define PI 3.1415926535
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void CyBerForCe()
{
	int n;
	cin>>n;
	vector <int> v;
	for(int i=0;i<n;i++)
	{
	    int a;
	    cin>>a;
	    v.push_back(a);
	}
	int m=0,ans=0;
	for(int i=0;i<n;i++)
	{
	    if(v[i]>m)
	    m=v[i];
	    else
	    ans+=m-v[i];
	}
	cout<<ans<<"\n";
}
signed main()
{
    speedUp
    /*int t;
    cin>>t;
    while(t--)*/
    CyBerForCe();
    return 0;
}

Measured memory_bytes: 5328
import sys

n = sys.stdin.readline().rstrip()
len_n = len(n)
m = n[1:-1]
m = int(m) if m else 0
l = int(n[0])
r = int(n[-1])
n = int(n)

def main():
    res = [[0] * 10 for _ in range(10)]

    for i in range(1, 10):
        for j in range(1, 10):
            if i == j:
                if i <= n:
                    res[i][j] += 1
            for k in range(len_n-2+1):
                if k < len_n - 2:
                    res[i][j] += 10 ** k
                else:
                    if i < l:
                        res[i][j] += 10 ** k
                    elif i == l:
                        if j <= r:
                            res[i][j] += m + 1
                        else:
                            res[i][j] += m
                    else:
                        pass

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += res[i][j] * res[j][i]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	_sc.Split(bufio.ScanWords)
	S := readLine()
	s, ir, il := len(S), 0, -1
	A := make([]int, s)
	for i, c := range S {
		if c == 'R' {
			if il != -1 {
				A[il-1] = (il-ir)/2 + (i-il)/2 + (il-ir)%2
				A[il] = (il-ir)/2 + (i-il)/2 + (i-il)%2
				ir = i
				il = -1
			}
		} else if il == -1 {
			il = i
		}
	}
	A[il-1] = (il-ir)/2 + (s-il)/2 + (il-ir)%2
	A[il] = (il-ir)/2 + (s-il)/2 + (s-il)%2
	for i, a := range A {
		if i == s-1 {
			fmt.Printf("%d\n", a)
		} else {
			fmt.Printf("%d ", a)
		}
	}
}

const _bufferSize = 1000000
var _sc = bufio.NewScanner(os.Stdin)
var _rd = bufio.NewReaderSize(os.Stdin, _bufferSize)

func nextInt() int {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return int(i)
}

func nextLine() string {
	_sc.Scan()
	return _sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, _bufferSize)
	for {
		l, p, _ := _rd.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2816
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

int gcd(int x, int y) {
  while (y != 0) {
    int r = x % y;
    x = y; y = r;
  }
  return x;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  int g = gcd(n, m);
  bool ok = 1;
  REP(i, 0, g) {
    if (s[n / g * i] != t[m / g * i]) {
      ok = false;
    }
  }
  if (not ok) {
    cout << -1 << endl;
  } else {
    cout << (ll) n / (ll) g * (ll) m << endl;
  }
}


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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    long long N;
    cin >> N;
    long long div1=1;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0) div1 = i;
    }
    long long div2=N/div1;
    long long temp = max(div1,div2);
    int ans = 0;
    while(1){
        temp/=10;
        ans++;
        if(temp==0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
// Problem : A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)
// Contest : AtCoder Beginner Contest 042
// URL : https://atcoder.jp/contests/abc042/tasks/abc042_a
// Memory Limit : 256.000000MB 
// Time Limit : 2000.000000milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

//1-1-20
#include<bits/stdc++.h>

#define Pi acos(-1.0)
#define U unsigned
#define ll long long
#define uu first
#define vv second
#define endl "\n"
#define scu(n) scanf("%u",&n)
#define scl(n) scanf("%d",&n)
#define scll(n) scanf("%lld",&n)

//Vector Macros
#define pb push_back
#define eb emplace_back
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c),0)

//Loop Macros
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define For(i,n) for(int i=0;i<n;i++)

//Debug Macros
#define deb(a) cout << #a << " : " << a << " ";
#define debln(a) cout<< #a <<" : " << a << endl;
#define open  freopen("input.txt","r",stdin);
#define close freopen ("output.txt","w",stdout);

//Print Macros
#define print(v)  for(auto x : v) {  cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v) { cout<<x.uu<<" "<<x.vv<<endl; }

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/

#define fastio  ios::sync_with_stdio(false); cin.tie(nullptr);

using namespace std;

int main()
{
    //open
    //close
    // fastio
	
	int a,b,c,f=0;
	cin>>a>>b>>c;
	
	if((a==5 && a==b && c==7) ||(a==5 && a==c && b==7)  || (b==5 && b==c && a==7) )
	f=1;
	
	puts(f==1 ? "YES" : "NO");
	
    return 0;
}





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

#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	char in_buffer[15] = {};
	int count[30] = {};
	for(int i = 0; i < n; i++) {
		scanf("%s", in_buffer);
		count[in_buffer[0]-'A']++;
	}
	
	priority_queue<int> pq;
	for(int i = 0; i < 26; i++) {
		if(count[i] != 0) {
			pq.push(count[i]);
		}
	}
	
	int used = 0;
	while(pq.size() >= k) {
		used += k;
		vector<int> temp;
		for(int i = 0; i < k; i++) {
			if(pq.top() > 1)
				temp.pb(pq.top()-1);
			pq.pop();
		}
		
		for(int i = 0; i < temp.size(); i++) {
			pq.push(temp[i]);
		}
		
	}
	printf("%d\n", used/k);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
template<typename T>
struct RectangleSum {
	vector<vector<T>>imos;

	RectangleSum(vector<vector<T>>in) :imos(in.size(), vector<T>(in.size(), 0)) {
		for (int i = 1; i < in.size(); i++) {
			for (int j = 1; j < in.size(); j++) {
				imos[i][j] = in[i][j] + imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1];
			}
		}
	}

	////xy平面を見て(p1,p2)が右上
	T GetRectangle(T p1, T p2, T q1, T q2) {
		return imos[p1][p2] - imos[q1 - 1][p2] - imos[p1][q2 - 1] + imos[q1 - 1][q2 - 1];
	}
};

int main() {
	cin >> N >> K;
	vector<vector<int>>recb(K + 1, vector<int>(K + 1, 0));
	vector<vector<int>>recw(K + 1, vector<int>(K + 1, 0));
	for (int i = 0; i < N; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if ((x / K + y / K) & 1) {
			if (c == 'B')recw[x%K + 1][y%K + 1]++;
			else recb[x % K + 1][y % K + 1]++;
		}
		else {
			if (c == 'B')recb[x%K + 1][y%K + 1]++;
			else recw[x%K + 1][y%K + 1]++;
		}
	}
	RectangleSum<int> b(recb);
	RectangleSum<int> w(recw);
	ans = max(b.GetRectangle(K, K, 1, 1), w.GetRectangle(K, K, 1, 1));
	for (int i = 1; i < K; i++) {
		ll tmp1 = b.GetRectangle(i, K, 1, 1) + w.GetRectangle(K, K, i + 1, 1);
		ll tmp2 = w.GetRectangle(i, K, 1, 1) + b.GetRectangle(K, K, i + 1, 1);
		ll tmp3 = b.GetRectangle(K, i, 1, 1) + w.GetRectangle(K, K, 1, i + 1);
		ll tmp4 = w.GetRectangle(K, i, 1, 1) + b.GetRectangle(K, K, 1, i + 1);
		ans = max(ans, max(max(tmp1, tmp2), max(tmp3, tmp4)));
	}
	for (int i = 1; i < K; i++) {
		for (int j = 1; j < K; j++) {
			ll tmp1 = b.GetRectangle(i, j, 1, 1) + b.GetRectangle(K, K, i + 1, j + 1) + w.GetRectangle(K, j, i + 1, 1) + w.GetRectangle(i, K, 1, j + 1);
			ll tmp2 = w.GetRectangle(i, j, 1, 1) + w.GetRectangle(K, K, i + 1, j + 1) + b.GetRectangle(K, j, i + 1, 1) + b.GetRectangle(i, K, 1, j + 1);
			ans = max(max(tmp1,tmp2), ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 20096
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=10000;i++){
		double num1=(double)i*0.08;
		double num2=(double)i*0.1;
		if((int)num1==a&&(int)num2==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<'\n';
  }
  else if(r<2800){
    cout<<"ARC"<<'\n';
  }
  else{
    cout<<"AGC"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
string s;
string  s1="";
cin >>s;
  
 for (int i=0;i < s.length();i++){
   if (s[i] == '?'){
     s1 += 'D';
   }else{
     s1 += s[i];
   }
 }
  cout << s1 << endl; 
}

Measured memory_bytes: 3924
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def dfs(now,N,sides,visited):

    all_visited = True

    if False in visited:
        all_visited = False

    if all_visited:
        return 1

    res = 0

    for i in range(N):
        if not sides[now][i]:
            continue
        if visited[i]:
            continue
        visited[i] = True
        res += dfs(i,N,sides,visited)
        visited[i] = False

    return res


def main():
    N,M = map(int,input().split())

    sides = [[False for j in range(N)] for i in range(N)]

    for i in range(M):
        A,B = map(int,input().split())
        sides[A-1][B-1] = sides[B-1][A-1] = True

    visited = [False for i in range(N)]
    visited[0] = True

    res = dfs(0,N,sides,visited)

    print(res)



main()


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

void output(int cnt, char c) {
	for (int i = 0; i < cnt; i++) {
		cout << c;
	}
}

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string ans = "";
	int dx = tx - sx, dy = ty - sy;

	output(dy, 'U');
	output(dx, 'R');
	output(dy, 'D');
	output(dx + 1, 'L');
	output(dy + 1, 'U');
	output(dx + 1, 'R');
	output(1, 'D');
	output(1, 'R');
	output(dy + 1, 'D');
	output(dx + 1, 'L');
	output(1, 'U');
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main(){
  int N;
  cin >> N;
  int a[110];
  for(int i=0;i<N;i++) cin >> a[i];
  int Alice=0;
  int Bob=0;
  sort(a,a+N,greater<int>());
  for(int i=0;i<N;i++){
    if(i%2==0) Alice += a[i];
    else Bob += a[i];
  }
  int ans = Alice-Bob;
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#define il inline
#define ri register
#define Size 524288
#define intmax 0x3f3f3f3f
using namespace std;
il void Max(int&,int);
struct segmentree{
	struct data{
		int l,r,d;
	}t[Size];int n1,con;
	il void build(int n,int c){
		for(n1=1;n1<=n;n1<<=1);
		for(int i(1);i<n1<<1;++i)
			t[i].d=-intmax;con=c;
	}il void change(int p,int v){
		t[p+=n1].d=v;
		while(p>>=1)
			t[p].d=max(t[p<<1].d,t[p<<1|1].d);
	}
	il int ask(int l,int r){
		int ans(con);if(l>r)return ans;
		for(l+=n1-1,r+=n1+1;l^r^1;l>>=1,r>>=1){
			if(~l&1)Max(ans,t[l^1].d);
			if(r&1)Max(ans,t[r^1].d);
		}return ans;
	}
}dp1[2];
int dp[Size][2],a[Size],n,
	a1[Size],a2[Size],a3[Size];
il void read(int&);
il bool deal(int,int,int,int,int);
int main(){
	//freopen("in","r",stdin);
	//freopen("out","w",stdout);
	read(n);
	for(int i(1);i<=n;++i)
		read(a[i]),a1[i]=max(a1[i-1],a[i]),
			a2[i]=a1[i]^a[i]?1:2;
	for(int i(n);i;--i)a3[i]=a3[i+1]+(a2[i]^2?0:1);
	dp1[0].build(n,0),dp1[1].build(n,-intmax);
	for(int i(n),j;i;--i)
		for(j=0;j<2;++j)
			dp[i][j]=dp1[j^a2[i]&1].ask(a[i]+1,n)+a2[i],
				dp1[j].change(a[i],dp[i][j]);
	if(!deal(0,0,1,0,0))return puts("-1"),0;
	for(int i(1),j,i1(0),i2(0),a(0),b(0);i<=n;++i){
		for(j=0;j<2;++j)dp1[j].change(::a[i],-intmax);
		deal(i2,max(i1,::a[i]),i+1,a+(i1<::a[i]),b)?
			(a+=i1<::a[i],Max(i1,::a[i]),putchar(48)):
			(b+=i2<::a[i],Max(i2,::a[i]),putchar(49));
	}return 0;
}
il bool deal(int v1,int v2,int p,int a,int b){
	int b1(a-b+a3[p]),b2(b-a+a3[p]);
	return b1>=0&&b1<=dp1[b1&1].ask(v1+1,n)
		||b2>=0&&b2<=dp1[b2&1].ask(v2+1,n);
}
il void read(int&x){
	x^=x;ri char c;while(c=getchar(),c<'0'||c>'9');
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
il void Max(int&x,int y){
	x=x>y?x:y;
}


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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int sum=0;
    while(n --){
        int a;
        cin>>a;
        if(abs(a-0)>abs(k-a))
            sum=sum+(2*(abs(k-a)));
        else
            sum=sum+(2*(abs(a-0)));
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def plecak_rozwiazanie_2(pojemnosc, lista_przedmitow):
    bez_przedmiotu = [0] + [10**18] * len(lista_przedmitow) * 1000
    for waga, wartosc in lista_przedmitow:
        z_przedmiotem = [None] * (len(lista_przedmitow) * 1000 +1)
        for i in range(len(z_przedmiotem)): 
            if wartosc > i: 
                z_przedmiotem[i] = bez_przedmiotu[i]
            else: 
                z_przedmiotem[i] = min(bez_przedmiotu[i-wartosc]+waga, bez_przedmiotu[i])
        bez_przedmiotu = z_przedmiotem
    for i in reversed(range(len(bez_przedmiotu))):
        if bez_przedmiotu[i] <= pojemnosc:
            return i

def plecak_2():
    N, W = wczytaj_liste()
    przedmioty = []
    for i in range(N): 
        waga, wartosc = wczytaj_liste()
        przedmioty.append((waga, wartosc))
    print (plecak_rozwiazanie_2(W,przedmioty))  
    
plecak_2()

Measured memory_bytes: 122316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;

ll dp[1010][1010]; // dp[i][j] ... 先頭からi文字目までで、呪文の先頭からj文字を、何個作れるか

int main() {
    string t, b;
    cin >> t >> b;
    int n = t.size(), m = b.size();
    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            if (t[i] == b[j - 1]) dp[i + 1][j] += dp[i][j - 1];
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 11096
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    ll n;
    cin >> n;
    ll arr[n];
    for (ll i=0;i<=n-1;i++)
    {
        cin >> arr[i];
    }

    ll ans=0;
    for (ll i=1;i<=n-1;i++)
    {
        if (arr[i]<arr[i-1])
        {
            ans=ans+arr[i-1]-arr[i];
            arr[i]=arr[i-1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
 
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

int main(void)
{
  ll A,B;
  ll ans = 0;

  cin >> A >> B;
  
  if(abs(A+B)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }else{
    ans = abs(A+B)/2;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int h, w;
	cin >> h >> w;
	int list[h][w];
	rep(i,h)rep(j,w) cin >> list[i][j];
	vector<pair<P, P>> p;
	rep(i,h)rep(j,w){
      if(j==w-1&&i==h-1) break;
		if(list[i][j]%2==0) continue;
		else{
			if(j==w-1){
				list[i][j]--;
				list[i+1][j]++;
				P a = P(i,j);
				P b = P(i+1,j);
				p.push_back(pair<P,P>(a,b));
			}else{
				list[i][j]--;
				list[i][j+1]++;
				P a = P(i,j);
				P b = P(i,j+1);
				p.push_back(pair<P,P>(a,b));
			}
		}
	}
	cout << p.size() << endl;
	rep(i,p.size()){
		cout << p[i].first.first+1 <<" "<<  p[i].first.second+1 << " " << p[i].second.first+1 << " " << p[i].second.second+1 << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  set<string> gacha;
  for (int i = 0; i < (n); i++){
    string s;
    cin >> s;
    gacha.insert(s);
  }
  cout << gacha.size();
}

Measured memory_bytes: 19140
def solve(n, as1, as2):
    for i in range(1, n):
        as1[i] += as1[i - 1]
        as2[n - 1 - i] += as2[n - i]
    return max(a1 + a2 for (a1, a2) in zip(as1, as2))

if __name__ == "__main__":
    n = int(input())
    as1 = [int(s) for s in input().split()]
    as2 = [int(s) for s in input().split()]
    print(solve(n, as1, as2))


Measured memory_bytes: 3060
class UnionFind():
    
    # 要素数を指定して作成 はじめは全ての要素が別グループに属し、親はいない
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    # xの根を返す
    def find(self, x):
        if self.parents[x] < 0:  return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    # xとyが属するグループを併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:  return
        if self.parents[x] > self.parents[y]:  x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    # xが属するグループの要素数
    def size(self, x):  return -self.parents[self.find(x)]
    
    # ｘとyが同じグループか否か
    def same(self, x, y):  return self.find(x) == self.find(y)
    
    # xと同じメンバーの要素
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    # 根の一覧
    def roots(self):  return [i for i, x in enumerate(self.parents) if x < 0]
    
    # グループ数
    def group_count(self):  return len(self.roots())
    
    # 可視化 [print(uf)]
    def __str__(self):  return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = list(map(int,input().split()))

G1 = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G1[a - 1].append(b - 1)
    G1[b - 1].append(a - 1)

G2 = [[] for _ in range(N)]
for i in range(K):
    a, b = map(int, input().split())
    G2[a - 1].append(b - 1)
    G2[b - 1].append(a - 1)
    
uf = UnionFind(N)
for i in range(N):
    for j in G1[i]:
        uf.union(i, j)
    
for i in range(N):
    ans = uf.size(i)  - len(G1[i]) - 1
    for j in G2[i]:
        if uf.same(i, j):  ans -= 1
    print(ans)

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

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

	int ichi = (n % 10);
	int hyaku = (n - (n % 100)) / 100;

	if (ichi == hyaku) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    rep(i, n) cin >> a[i];
    sort(ALL(a));
    int sum = 0;

    for (int i = 0; i < n;)
    {
        int cnt = 1;
        int num = a[i];
        while (a[i + cnt - 1] == a[i + cnt])
            cnt++;

        if (cnt < a[i])
            sum += cnt;
        else
            sum += cnt - a[i];

        i += cnt;
    }

    OP(sum);

    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

count = 0

flag = True
while flag:
    flag = False
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A[j-1], A[j] = A[j], A[j-1]
            flag = True
            count += 1

print(' '.join(map(str,A)))
print(count)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vii A(N);
  rep(i,0,M){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
  }
  vi F(N);
  F[0]=1;
  queue<pii> Q;
  Q.push(mp(0,0));
  while(Q.size()>0){
    int X=Q.front().first,Y=Q.front().second; Q.pop();
    int P=1-Y;
    rep(i,0,A[X].size()){
      int Z=A[X][i];
      bitset<2> B(F[Z]);
      if(!B.test(P)){
        F[Z]+=(1ll<<P);
        Q.push(mp(Z,P));
      }
    }
  }
  vi B(3);
  rep(i,0,N) B[F[i]-1]++;
  int ans=0;
  rep(i,0,N){
    if(F[i]==3){
      ans+=N-1-A[i].size();
    }
    else if(F[i]==2){
      ans+=B[0]+B[2]-A[i].size();
    }
    else{
      ans+=B[1]+B[2]-A[i].size();
    }
  }
  ans/=2;
  cout<<ans<<endl;
  }



Measured memory_bytes: 7424
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,Z,W;
    cin >> N >> Z >> W;
    ll a[2010];
    rep(i,0,N) cin >> a[i];
    if(N == 1){
        print(abs(a[0] - W));
    }else{
        ll ans = max(abs(a[N-2] - a[N-1]), abs(a[N-1] - W));
        print(ans);
    }

    

}

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

using ll=long long;
const ll INF=1LL<<60;
const int MOD=1e9+7;

const int MAX = 2e5+5;


ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD; 
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; 
        finv[i] = finv[i - 1] * inv[i] % MOD; 
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    ll n, k; cin >> n >> k;
    COMinit();
    ll res=0;
    for(int i=0; i<=min(n-1, k); i++){
        res=(res+COM(n, i)*COM(n-1, i)%MOD)%MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,m;
  cin>>n>>m;
  vector<ll> x(m);
  rep(i,m)cin>>x[i];
  sort(x.begin(),x.end());
  vector<ll> d;
  rep(i,m-1) {
    d.push_back(x[i+1]-x[i]);
  }
  if(n>=m) {
    cout << 0 << endl;
    return 0;
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  ll sum=accumulate(d.begin(),d.end(),0LL);
  rep(i,n-1) {
    sum-=d[i];
  }
  cout << sum << endl;
  return 0;
}


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

int main(void) {
    string n;
    cin >> n;
    int ans = 0, carry = 0;
    for (int i = n.length() - 1; i >= 0; i--) {
        int dg = n[i] - '0';
        dg += carry;
        if (dg < 5) {
            // I'll pay this
            ans += dg;
            carry = 0;
        }
        else if (dg == 5) {
            int ndg = (i == 0) ? carry : n[i - 1] - '0';
            if (ndg < 5) {
                // I'll pay this
                ans += 5;
                carry = 0;
            }
            else {
                // I should make clerk return
                ans += 5;
                carry = 1;
            }
        }
        else {
            // I should make clerk return
            ans += 10 - dg;
            carry = 1;
        }
    }
    ans += carry;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1412
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans1 = 0;
    int ans2 = 0;
    int ans3 = 0;
    int ans4 = 0;
    int x1 = x;
    int x2 = -1 * x;
    int y1 = y;
    int y2 = -1 * y;
    if (x1 <= y1) {
      ans1 = y1 - x1;
    } else {
      ans1 = Integer.MAX_VALUE;
    }
    if (x2 <= y1) {
      ans2 = y1 - x2 + 1;
    } else {
      ans2 = Integer.MAX_VALUE;
    }
    if (x1 <= y2) {
      ans3 = y2 - x1 + 1;
    } else {
      ans3 = Integer.MAX_VALUE;
    }
    if (x2 <= y2) {
      ans4 = y2 - x2 + 2;
    } else {
      ans4 = Integer.MAX_VALUE;
    }
    int ans = Math.min(Math.min(ans1, ans2), Math.min(ans3, ans4));
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[20][20], b[20];
int main(){
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);
    for (int i = 1; i <= n;i++){
        for (int j = 0; j <= m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int ans = 0x3f3f3f3f;
    for (int i = 1; i < (1 << (n + 1));i++){
        memset(b, 0, sizeof(b));
        for (int j = 0; j < n;j++){
            if(i&(1<<j)){
                for (int k = 0; k <= m;k++){
                    b[k] += a[j+1][k];
                }
            }
        }
        int flag = 1;
        for (int j = 1; j <= m;j++){
            if(b[j]<x){
                flag = 0;
                break;
            }
        }
        if(flag){
            ans = min(ans, b[0]);
        }
    }
    printf("%d",ans==0x3f3f3f3f?ans=-1:ans);
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
  string t,h;
  int n,pt=0,ph=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> t >> h;
    if(t==h)pt++,ph++;
    else if(t>h) pt+=3;
    else ph+=3;
  }
  cout << pt << " " << ph << endl;
}


Measured memory_bytes: 3148
import sys
myin = sys.stdin.readlines()

n = int(myin[0])
a = [int(x) for x in myin[1].split()]

cnt = [0] * (n+1)
for v in a:
    cnt[v] += 1

tmp = 0
for c in cnt:
    tmp += c * (c-1) // 2
for v in a:
    print(tmp - cnt[v] + 1)

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

int extgcd(int a,int b,int &x,int &y){
    int d;
    if(b==0){
        d=a;
        x=1;y=0;
    }
    else{
        d=extgcd(b,a%b,y,x);
        y-=a/b*x;
    }
    return d;
}

int main(){
    int a,b;cin>>a>>b;
    int x,y;extgcd(a,b,x,y);
    cout<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 1168
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
bc = q.times.map { gets.split.map(&:to_i) }

sum = a.sum
h = Hash.new { 0 }
a.each do |e|
  h[e] += 1
end

bc.each do |e|
  b = e[0]
  c = e[1]
  x = h[b]
  y = h[c]
  diff = (c - b) * h[b]
  h[b] = 0
  h[c] += x
  sum += diff
  puts sum
end


Measured memory_bytes: 27576
import java.util.*;

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

        int n = sc.nextInt();
        String s = sc.next();
        long ans;
        boolean pat;
        if(s.length() == 1){
            System.out.println(3);
            return;
        }
        if(s.charAt(0) == s.charAt(1)){
            ans = 6;
            pat = false;
        }else{
            ans = 3;
            pat = true;
        }

        for(int i = pat ? 1 : 2; i < s.length(); i++){
            if(i != s.length() - 1 && s.charAt(i) == s.charAt(i + 1)){
                if(pat){
                    ans *= 2;
                }else{
                    ans *= 3;
                }
                pat = false;
                i++;
            }else{
                if(pat){
                    ans *= 2;
                }
                pat = true;
            }
        }

        System.out.println(ans % 1000000007);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MAXN 20000005
typedef long long ll;
ll n, a[MAXN], v[MAXN];
ll resp;
int main(void) {
    resp = 0;
    cin >> n;

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

    for (int i = 1; i <= n; i++) {
        if (a[i] > 0) {
            resp += a[i] * (a[i] - 1) / 2;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << resp - a[v[i]] + 1 << endl;
    }
    return 0;
}


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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  REP(i, 1000){
    if(i&1){
      a-=d;
      if(a<=0){
        cout<<"No"<<'\n';
        return 0;
      }
    }
    else{
      c-=b;
      if(c<=0){
        cout<<"Yes"<<'\n';
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

int main(){
	string S;
	int flag = 1;
	cin >> S;
	int n = S.length();
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(S[i] != S[j]) continue;
			else {
				flag = 0;
				cout << "no" << endl;
				return 0;
			}
		}
	}
	if(flag != 0) cout << "yes" << endl;

}

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

int main() {
    long long x, ans, mod;
    cin >> x;
    ans = x / 11;
    mod = x % 11;
    ans *= 2;
    if (mod != 0) {
        if (mod <= 6) ans--;
        ans += 2;
    }
    cout << ans << endl;
}

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

int main(){
  int N, K, sum, x;
  cin >> N >> K;
  
  sum = 0;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(x <= (K/2))
      sum += (2 * x);
    else
      sum += ((K - x) * 2);
    
  }
  cout << sum << endl;
}

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

ll cnt = 0;
int P[8];
int Q[8];
ll a, b;
vector<ll> ans;

void bfs(bool used[], vector<int> array, int limit, int A[], ll &target)
{
    if (array.size() == limit)
    {
        cnt++;
        // 一致するか確認
        for (int i = 0; i < limit; i++)
        {
            if (array[i] != A[i])
            {
                return;
            }
        }
        target = cnt;
    }

    for (int i = 1; i <= limit; i++)
    {
        if (used[i] == false)
        {
            used[i] = true;
            array.push_back(i);
            bfs(used, array, limit, A, target);
            used[i] = false;
            array.pop_back();
        }
    }
}

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> Q[i];
    }

    // 順列を幅優先探索で作成
    for (int i = 1; i <= N; i++)
    {
        bool used[N + 1];
        fill_n(used, N + 1, false);
        vector<int> array;
        used[i] = true;
        array.push_back(i);
        bfs(used, array, N, P, a);
    }

    cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        bool used[N + 1];
        fill_n(used, N + 1, false);
        vector<int> array;
        used[i] = true;
        array.push_back(i);
        bfs(used, array, N, Q, b);
    }

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  char c;
  cin >> c;

  cout << as[c-'a'+1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll A,B,N;
    cin>>A>>B>>N;
    ll ans=(A*N)/B-A*(N/B);
    if(N>=B-1){
        if(A%B==0){
            ans=max(ans,A-A/B);
        }else{
            ans=max(ans,A-A/B-1);
        }   
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;
const int MAXN = 100;

int n;

int a[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

int m;

int val[MAXN + 5];

inline void discrete()
{
	m = 0;
	for(int i = 1; i <= n; ++i) val[++m] = a[i];
	sort(val + 1, val + m + 1), m = unique(val + 1, val + n + 1) - (val + 1);
	for(int i = 1; i <= n; ++i) a[i] = lower_bound(val + 1, val + m + 1, a[i]) - val;
}

inline int fpm(int base, int exp)
{
	int res = 1;
	for(; exp; exp >>= 1, base = (LL) base * base % MOD) if(exp & 1) res = (LL) res * base % MOD;
	return res;
}

inline void solve()
{
	discrete();

	static int f[MAXN + 5][MAXN + 5] = {0};

	f[0][0] = 1;
	for(int i = 1; i <= n; ++i)
	{
		f[i][0] = f[i - 1][0] * 2 % MOD;
		for(int j = a[i] + 1; j <= a[i - 1]; ++j) (f[i][0] += f[i - 1][j] * 2 % MOD) %= MOD;

		int coef = a[i] <= a[i - 1] ? 1 : fpm(2, val[a[i]] - val[a[i - 1]]);
		for(int j = min(a[i], a[i - 1]); j; --j) f[i][j] = (LL) f[i - 1][j] * coef % MOD;

		for(int j = a[i - 1] + 1; j <= a[i]; ++j)
		{
			coef = (j == 1 ? fpm(2, val[j]) - 2 : fpm(2, val[j] - val[j - 1] + 1) - 2) % MOD;
			(f[i][j] += (LL) f[i - 1][0] * coef % MOD * fpm(2, val[a[i]] - val[j]) % MOD) %= MOD;
		}
	}

	int ans = 0;
	for(int i = 0; i <= a[n]; ++i) (ans += f[n][i]) %= MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
	input();
	solve();

	return 0;
}



Measured memory_bytes: 256