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

using namespace std;

const int maxn = 100010;

int n,fa[maxn],sizee[maxn];
set<int> S[maxn];
map<pair<int,int>,int> M;
queue <pair<int,int> >q;

int find(int x)
{
    if (x == fa[x])
        return x;
    return fa[x] = find(fa[x]);
}

int main()
{
    scanf("%d",&n);
    for (int i = 1; i <= n; i++)
    {
        fa[i] = i;
        sizee[i] = 1;
    }
    for (int i = 1; i <= 2 * (n - 1); i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if (x > y)
            swap(x,y);
        S[x].insert(y);
        S[y].insert(x);
        if (M.count(make_pair(x,y)))
            q.push(make_pair(x,y));
        M[make_pair(x,y)] = 1;
    }
    while (n >= 2)
    {
        n--;
        if (q.empty())
        {
            puts("NO");
            exit(0);
        }
        pair<int,int> u = q.front();
        q.pop();
        int x = u.first,y = u.second;
        x = find(x),y = find(y);
        if (S[x].size() > S[y].size())
            swap(x,y);
        fa[x] = y;
        for (set<int>::iterator it = S[x].begin();it != S[x].end(); ++it)
        {
            int v = (*it);
            v = find(v);
            if (v == y)
                continue;
            S[v].insert(y);
            S[y].insert(v);
            if (v > y)
            {
                if (M.count(make_pair(y,v)))
                    q.push(make_pair(y,v));
                M[make_pair(y,v)] = 1;
            }
            else
            {
                if (M.count(make_pair(v,y)))
                    q.push(make_pair(v,y));
                M[make_pair(v,y)] = 1;
            }
            S[v].erase(S[v].find(x));
        }
        S[y].erase(S[y].find(x));
        S[x].clear();
    }
    puts("YES");

    return 0;
}


Measured memory_bytes: 39168
import sys
import copy
import math
import itertools
import numpy as np
import re

N = int(input())
s = [int(input()) for c in range(N)]
ans = sum(s)
s = [c for c in sorted(list(set(s))) if c%10 != 0]

if ans % 10 ==0:
    if len(s) > 0:
        print(ans-s[0])
        sys.exit(0)
    else:
        print(0)
        sys.exit(0)
else:
    print(ans)
    sys.exit(0)

print(0)

Measured memory_bytes: 27100
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int a[5],k,i;
  for (i = 0; i < 5; i++)
    cin >> a[i];
  cin >> k;

  if ((a[4] - a[0]) > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
string to_s(int n){
      string res="";
      while(n>0){
            res+=(char)(n%10+'0');
            n/=10;
      }
      reverse(ALL(res));
      return res;
}
int main(){
      string s;
      int n;
      while(cin>>n&&n){
            cin>>s;
            while(n--){
                  string tmp="";
                  int i=0;
                  while(i<s.size()){
                        int cnt=0,k=i;
                        while(s[k]==s[i]){
                              i++;
                              cnt++;
                        }
                        tmp+=to_s(cnt)+s[k];
                  }
                  s=tmp;
            }
            cout<<s<<endl;
      }
}

Measured memory_bytes: 1344
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = []
    for i in range(m):
        bc.append(list(map(int, input().split())))

    bc.sort(key=lambda x: x[1], reverse=True)
    a.sort()

    bcn = 0
    for i in range(n):
        if(a[i] < bc[bcn][1]):
            a[i] = bc[bcn][1]
            bc[bcn][0] -= 1
            if(bc[bcn][0] == 0):
                bcn += 1
                if(bcn == m):
                    break

    print(sum(a))


Measured memory_bytes: 32960
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string o,e;
  cin >> o >> e;

  rep(i, o.size()){
    cout << o[i];
    if(i==e.size())break;
    cout << e[i];
  }
  cout << endl;
  return 0;
} 

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main(){
    /* code */ 
    string S;cin >> S;
    REP(i, S.size()){
        cout << 'x';
    }
    cout << endl;
    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin>>a[i];
    n-=a[i];
  }
  if(n<0){
    cout<<"-1"<<endl;
  }
  else {
    cout<<n<<endl;
  }
}

Measured memory_bytes: 3660
//C - pushpush: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;



int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x;
    bool swtc;
    cin >> n;
    deque<int> seq;
    if(n % 2 == 0) swtc = true;
    else swtc = false;
    cin >> x;
    seq.pb(x);
    n--;
    while(n--) {
        cin >> x;
        if(swtc) {
            seq.push_front(x);
            swtc = false;
        } else {
            seq.pb(x);
            swtc = true;
        }
    }
    for(auto x : seq) {
        cout << x << " ";
    } cout << "\n";
}

Measured memory_bytes: 3072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    vector<int>vec3(3);
    for (int i=0; i<3; i++)cin >> vec3[i];
    sort(all(vec3));
    if (vec3 == vector<int>{5,5,7} ){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  while (N > 0) {
    int n = N % 10;
    if (n == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3616
from operator import itemgetter
N, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for j in range(N)]
ab = sorted(ab, key=itemgetter(0))
for row in ab:
    K -= row[1]
    if K <= 0:
        print(row[0])
        break

Measured memory_bytes: 23712
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let s: String = sc.input();
    let chs: Vec<char> = s.chars().collect();

    let (red, green, blue): (usize, usize, usize) = chs
        .iter()
        .fold((0, 0, 0), |(r, g, b), &ch| {
            match ch {
                'R' => (r + 1, g, b),
                'G' => (r, g + 1, b),
                'B' => (r, g, b + 1),
                _ => unreachable!(),
            }
        });

    let sum: usize = red * green * blue;
    let mut sub: usize = 0;
    for i in 0..n - 2 {
        for j in i + 1..n - 1{
            if chs[i] == chs[j] {
                continue;
            }

            let k = j * 2 - i;
            if k >= n || chs[k] == chs[i] || chs[k] == chs[j] {
                continue;
            }
            sub += 1;
        }
    }
    println!("{}", sum - sub);
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

void print(vector<int> v, char mark)
{
  for (int i = 1; i < 14; ++i) {
    if (!v[i]) {
      fprintf(stdout, "%c %d\n", mark, i);
    }
  }
}

int main()
{
  vector<int> spade(14, 0), heart(14, 0), club(14, 0), dia(14, 0);
  int n;
  fscanf(stdin, "%d\n", &n);
  for (int i = 0; i < n; ++i) {
    char mark;
    int num;
    fscanf(stdin, " %c %d", &mark, &num);
    if (mark == 'S') { spade[num] = 1; }
    else if (mark == 'H') { heart[num] = 1; }
    else if (mark == 'C') { club[num] = 1; }
    else if (mark == 'D') { dia[num] = 1; }
  }
  print(spade, 'S');
  print(heart, 'H');
  print(club, 'C');
  print(dia, 'D');
  return 0;
}

Measured memory_bytes: 1208
X,K,D = map(int,input().split())
X = abs(X)
a=X//D
if(a<=K):
    X=X-(D*a)
    K=K-a
    if(K%2==0):
        print(X)
    else:
        print(min(abs(X-D),abs(X+D)))
else:
    print(X-(D*K))

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  if(a >= b){
    cout << "delicious" << endl;
  }
  else if(x >= b - a){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}


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

int main(){
  int n, ans = 0;  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++)  cin >> l[i];
  sort(l.begin(), l.end());

  for(int i=0; i<n-2; i++)
    for(int j=i+1; j<n-1; j++)
      ans += max(0, (int)(lower_bound(l.begin()+j, l.end(), l[i]+l[j])-l.begin()) - 1 - j);

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


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	string s,t;
	cin >> s >> t;
	int cnt = 0 ;
	for(int i = 0; i < s.size(); i++){
		cnt += (s[i] != t[i]);
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 3824
def sin(): return input()
def ssin(): return input().split()
def nin(): return int(input())
def lin(): return list(map(int, ssin()))

N, K = lin()
p = [n*(n+1)/2/n for n in lin()]    

t = sum(p[:K])    
ans = t
l, r = 0, K-1

for i in range(N-K):
    t = t - p[l] + p[r+1]
    r += 1; l += 1
    ans = max(ans, t)
    
print(ans)

Measured memory_bytes: 25376
import java.util.*;

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

        String[] list = new String[N];
        for(int i=0; i<N; i++){
            list[i] = sc.next();
        }
        int[] array = new int[4];
        for(String s :list){
            if(s.equals("AC")){
                array[0] = array[0]+1;
            }else if(s.equals("WA")){
                array[1] = array[1]+1;
            }else if(s.equals("TLE")){
                array[2] = array[2]+1;
            }else if(s.equals("RE")){
                array[3] = array[3]+1;
            }
        }
        String[] ans = {"AC x ","WA x ","TLE x ","RE x " };
        for(int i=0;i<4; i++){
            System.out.println(ans[i] + array[i]);
        }
    }
}


Measured memory_bytes: 64144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll MOD = 1000000007;
ll n, m;
ll fact[100005];

void setFact() {
	for (int i = 1; i < 100005; i++) {
		fact[i] = fact[i-1] * i % MOD;
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	ll ans = 1;
	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	else if (n == m) ans *= 2;
	
	fact[0] = 1;
	setFact();

	ans = ans * fact[n] % MOD;
	ans = ans * fact[m] % MOD;

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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

ll N, H;
ll B[MAXN];

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

	cin >> N >> H;

	ll maxA = 0;
	for (int a = 0; a < N; a++) {
		ll A;
		cin >> A >> B[a];
		maxA = max(maxA, A);
	}
	sort(B, B + N);
	reverse(B, B + N);

	ll ans = (H + maxA - 1) / maxA;
	for (int a = 0; a < N; a++) {
		H -= B[a];
		ans = min(ans, max(0LL, (H + maxA - 1) / maxA) + a + 1);
	}
	cout << ans;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static int countPrime(int n){
		int cnt = 0;
		boolean flag = true;
		if(n <= 1)return cnt;
		if(n == 2){
			cnt++;
			return cnt;
		}
		cnt++;
		for(int i = 3; i <= n; i += 2){
			for(int j = 3; j <= Math.sqrt(i); j += 2){
				if(i % j == 0){
					flag = false;
					break;
				}
			}
			if(flag)cnt++;
			else flag = true;
		}
		return cnt;
	}

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			int cnt = 0;
			int n = scan.nextInt();
			cnt = countPrime(n);
			list.add(cnt);
		}
		for(int n : list){
			System.out.printf("%d\n", n);
		}
	}
}

Measured memory_bytes: 26440
/*********************************   
 *   @author: I_Love_Thuy_Linh   *
 *                               *
 *   0-1 BFS                     *
 ********************************/
#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
int H, W;
int Ch,Cw,Dh,Dw;
vector<vector<char>> S;
int dx[] = {0,0,-1,1},
    dy[] = {-1,1,0,0};

// 0-1 BFS, because weight's graph is 0 - 1 

int inside(int u,int v){
    return (u >= 0 && v >= 0 && u < H && v < W && S[u][v] == '.');
}

int BFS(int su,int sv){
    vector<vector<int>> dis(H,vector<int> (W,INF));
    deque<pair<int,int>> dq;

    dis[su][sv] = 0;
    dq.push_front(make_pair(su,sv));
    while (!dq.empty()){
        pair<int,int> u = dq.front();
        dq.pop_front();
        //cout << u.first << ' ' << u.second << ' ' << dis[u.first][u.second] << '\n';
        if (u == make_pair(Cw,Dw)) return dis[Cw][Dw];

        // Weight = 0
        for (int k = 0; k < 4; k++){
            int vx = u.first + dx[k];
            int vy = u.second + dy[k];
            if (inside(vx,vy) && dis[u.first][u.second] < dis[vx][vy]){
                dis[vx][vy] = dis[u.first][u.second];
                dq.push_front(make_pair(vx,vy));
            }
        }

        // Weight = 1
        for (int r = -2; r <= 2; r++)
            for (int c = -2; c <= 2; c++)
                if (!(r == 0 && c == 0)){
                    int vx = u.first + r;
                    int vy = u.second + c;
                    if (inside(vx,vy) && dis[u.first][u.second]  + 1 < dis[vx][vy]){
                        dis[vx][vy] = 1 + dis[u.first][u.second];
                        dq.push_back(make_pair(vx,vy));
                    }
                }
    }


    return -1;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> H >> W;
    cin >> Ch >> Dh;
    cin >> Cw >> Dw;
    Ch--, Dh--;
    Cw--, Dw--;

    S.assign(H,vector<char> (W,'.'));
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) cin >> S[i][j];

    
    cout << BFS(Ch,Dh);    
    return 0;
}


Measured memory_bytes: 8588
count = 0
for i in range(int(input())):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
        count += 1
    elif l[0] != l[1]:
        count = 0
    if count >= 3:
        print("Yes")
        break
if count < 3:
    print("No")


Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    vector<int>a(x);
    for (int i=0; i<x; i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    for (int i=0; i<x; i++)
    {
        for (int j=i+1; j<x; j++)
        {
            int m=a[i]+a[j];
            int idx=lower_bound(a.begin(),a.end(),m)-a.begin();
            ans+=idx-j-1;
        }
    }
    cout<<ans;
    return 0;
}


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

int a[MAXN], n, ans, k;
int lb, ub;

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(k == 2){
        cout << n - 1 << endl;
        return 0;
    }
    k--;
    ans += n / k;
    if(n % k > 1){
        ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
			int N=sc.nextInt();
			ArrayList<String> cc = new ArrayList<>(N);
			String w;
			boolean x=true;
			char past=0;
			for(int i=0;i<N;i++) {
				w=sc.next();
				if(cc.contains(w)) {
					x=false;
					continue;
				}else {
					cc.add(w);
				}
				if(i==0)past=w.charAt(w.length()-1);
				else if(past==w.charAt(0)) {
					past=w.charAt(w.length()-1);
				}else {
					x=false;
					continue;
				}
			}
		
			if(x)p("Yes");
			else p("No");
			
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;

int main() {
	int n;
	cin >> n;
	double ans = 0;
	for (int i = 0;i < n;++i) {
		double x;
		cin >> x;
		string s;
		cin >> s;
		if (s == "JPY")ans += x;
		if (s == "BTC")ans += x *380000.0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
static int p[13];
int main(void) {
    while ((*p = getchar()) - '\n')
        if (*p - 'B') {
            *(p + 2 + *(p + 1)) = *p;
            ++*(p + 1);
        } else
            if (*(p + 1))
                --*(p + 1);
    *(p + 1) = *(p + 2 + *(p + 1)) = 0;
    while (*p = *(p + 2 + *(p + 1))) {
        putchar(*p);
        ++*(p + 1);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 128
N, T = gets.chomp.split.map(&:to_i)

cost_min = (0...N).inject (1001) { |res, i|
    c, t = gets.chomp.split.map(&:to_i)
    res = t <= T ? [res, c].min : res
}

puts cost_min > 1000 ? "TLE" : cost_min

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

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

  int sum= 0;
  int Lmax= -1;
  for(int i=0; i<N; i++){
    cin >> buf;

    sum+= buf;
    Lmax= max(Lmax, buf);
  }

  string ans= (sum > 2*Lmax) ? "Yes"
                             : "No";
  cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

ll ans = 0;

void countdigit(ll i){
    ll n = i,cnt = 0;
    while(n>0){
        cnt++;
        n /= 10;
    }
    if(cnt%2==1) ans++;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    REP(i,1,n+1){
        countdigit(i);
    }
    cout << ans << endl;
    return 0;
}

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

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

	string s;
	char e;
	bool flag = true;
	vector<string> words;
	for(int i = 0; i < n; i++){
		cin >> s;
		if(i != 0) {
			if(s[0] != e)
				flag = false;
			auto itr = find(words.begin(), words.end(), s);
			if(itr != words.end())
				flag = false;
		}
		words.push_back(s);
		e = s[s.length()-1];
	}

	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a,b,A,v,ans,dp[51][51];
map<int,int> m;
bool f=true;

signed main() {
    dp[0][0] = 1;
    rep1(i,50) rep(j,i+1) {
        if (!j) dp[i][j] = 1;
        else dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
    }
    cin >> n >> a >> b;A = a;
    rep(i,n) cin >> v,m[v]++;
    auto itr = m.end();--itr;
    while(true) {
        if (a <= itr->se) {
            int cnt=0;
            ans += itr->fi * a;
            cout << setprecision(20) << (double)ans/(double)A << endl;
            if (f) {
                repo(i,a,min(b,itr->se)+1) cnt += dp[itr->se][i];
                cout << cnt << endl;
            } else cout << dp[itr->se][a] << endl;
            return 0;
        }
        a -= itr->se;
        b -= itr->se;
        ans += itr->fi * itr->se;
        --itr;
        f=false;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);

int a,b,c,d;
int main(){ _;
  cin>>a>>b>>c>>d;
  if ((abs(b-a)<=d && abs(c-b)<=d) || abs(c-a)<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  for (int i = N; i > 0; i--)
  {
    if (sqrt(i) == floor(sqrt(i))){
      cout << i << endl;
      return 0;
    }
 
  }
  
}

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

void dfs(vector<vector<int>> const& adj, vector<vector<int64_t>> const& costs, int k, int v, vector<int64_t>& result)
{
    for (int ichild = 0; ichild < (int) adj[v].size(); ++ichild) {
        int child = adj[v][ichild];
        int64_t cost = costs[v][ichild];
        if (!result[child] && child != k) {
            result[child] = result[v] + cost;
            dfs(adj, costs, k, child, result);
        }
    }
}

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

    int n;
    cin >> n;
    vector<vector<int>> adj(n);
    vector<vector<int64_t>> costs(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y; int64_t cost;
        cin >> x >> y >> cost; --x; --y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        costs[x].push_back(cost);
        costs[y].push_back(cost);
    }
    vector<int64_t> result(n);
    int q, k;
    cin >> q >> k; --k;
    dfs(adj, costs, k, k, result);
    for (int i = 0; i < q; ++i) {
        int x, y;
        cin >> x >> y; --x; --y;
        cout << result[x] + result[y] << "\n";
    }
}


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

public class Main {
  Scanner sc;
  int INF = 1 << 28;

  int ex(int v, int r) {
    return ( v * ( 100 + r ) ) / 100;
  }

  void run() {
    for ( ;; ) {
      int x = ni();
      int y = ni();
      int s = ni();

      if ( ( x | y | s ) == 0 )
        break;

      int max = 0;
      for ( int i = 1; i <= s; ++i ) {
        for ( int j = s - i; 1 <= j; --j ) {
          int bef = ex( i, x ) + ex( j, x );
          if ( bef == s ) {
            max = Math.max( max, ex( i, y ) + ex( j, y ) );
          }
        }
      }

      System.out.println( max );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

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

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] v = new int[N];
		Arrays.fill(v, -1);

		for (int i = 0; i < M; i++) {
			int s = sc.nextInt() - 1; // 配列に合わせる
			int c = sc.nextInt();

			if (v[s] < 0) {
				v[s] = c; // 入力された値で更新
			} else if (v[s] != c) {
				// 同じ桁で違う値はNG
				System.out.println("-1");
				sc.close();
				return;
			}
		}
		// 2桁以上で1桁目が0はNG
		if (N > 1 && v[0] == 0) {
			System.out.println("-1");
			sc.close();
			return;
		}
		for (int i = 0; i < N; i++) {
			if (v[i] >= 0) {
				System.out.print(v[i]);
			} else {
				if (i == 0) {
					if (N == 1) {
						System.out.print("0");
					} else {
						System.out.print("1");
					}
				} else {
					System.out.print("0");
				}
			}
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    long int n,k,i,p[1005],j,swap,sum=0;
    scanf("%ld%ld",&n,&k);
    for(i=0;i<n;i++)
        scanf("%ld",&p[i]);
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(p[j]>p[j+1])
            {
                swap=p[j];
                p[j]=p[j+1];
                p[j+1]=swap;
            }
        }
    }
    for(i=0;i<k;i++)
        sum=sum+p[i];
    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 1716
input()
input_line = input()
plist = list(map(int, input_line.split(' ')))

count = 0
flag = False
for i in range(len(plist)):
	if flag == True:
		flag = False
		continue
	if i + 1 == plist[i]:
		count += 1
		flag = True

print(count)

Measured memory_bytes: 14584
#include<bits/stdc++.h>
    using namespace std;
    int n,num[200005],dp[200005];
    int main() {
    	cin>>n;
    	for (int i=1;i<=n;i++) cin>>num[i];
    	dp[1]=0;
    	dp[2]=dp[1]+fabs(num[1]-num[2]);
    	for (int i=3;i<=n;i++) 
    		dp[i]=min(dp[i-1]+fabs(num[i-1]-num[i]),
    		dp[i-2]+fabs(num[i-2]-num[i]));
    	cout<<dp[n]<<endl;
    	return 0;
    } 

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

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

int n[2];
int star[2][2][1000];
bool flag;

bool serach(int x, int y) {
	REP(i, n[1]) {
		if (x == star[1][0][i] && y == star[1][1][i]) {
			return true;
		}
	}
	return false;
}

int main() {
	while (1) {
		cin >> n[0];
		if (n[0] == 0) break;
		REP(i, n[0]) scanf("%d %d", &star[0][0][i], &star[0][1][i]);
		cin >> n[1];
		REP(i, n[1]) scanf("%d %d", &star[1][0][i], &star[1][1][i]);

		//star [0:??? 1:?????¨][0:x 1:y][i]
		REP(i, n[1]) {
			int dx = star[1][0][i] - star[0][0][0];
			int dy = star[1][1][i] - star[0][1][0];

			flag = true;
			REP(j, n[0]) {
				if (!serach(star[0][0][j] + dx, star[0][1][j] + dy))
					flag = false;
			}
			if (flag) {
				printf("%d %d\n", dx, dy);
				break;
			}
		}
	}
	return 0;
}

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

int main(void){
	int N,M,X;
	cin >> N>>M>>X;
	int A[N+1];
	for(int i = 1; i < N; i++)A[i]=0;
	A[0] = 0;
	A[X]=0;
	A[N] = 0;
	for(int i = 0; i < M; i++){
		int tmp;
		cin >> tmp;
		A[tmp] = 1;
	}
	int t1,t2;
	t1 = 0;
	t2 = 0;
	for(int i = X; i <= N; i++){
		if(A[i]!=0)t1++;
	}
	for(int i = 0; i <= X; i++){
		if(A[i]!=0)t2++;
	}
	cout << min(t1,t2);
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc120/tasks/abc120_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
const int UF_SIZE = 1e5;

int par[UF_SIZE];
int rnk[UF_SIZE];
ll siz[UF_SIZE];

void union_find_init(int n) {
  REP(i, n) {
    par[i] = i;
    rnk[i] = 0;
    siz[i] = 1LL;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
    siz[y] += siz[x];
  } else {
    par[y] = x;
    siz[x] += siz[y];
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}


//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int M_MAX = 1e5;

int N, M;
int A[M_MAX];
int B[M_MAX];

ll c[M_MAX];


void solve() {
  union_find_init(N);

  for (int i = M - 1; i >= 0; i--) {
    int a = A[i] - 1;
    int b = B[i] - 1;
    if (same(a, b) ) {
      c[i] = 0;
    } else {
      c[i] = siz[find(a)] * siz[find(b)];
      unite(a, b);
    }
  }

  ll ans = 0;
  REP(i, M) printf("%lld\n", ans += c[i]);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) scanf("%d%d", A + i, B + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

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

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

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

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

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

vi get_primes(int n){
    vi res;
    int x = 2;
    while(n >= x*x){
        while(n % x == 0){
            n /= x;
            res.push_back(x);
        }
        x++;
    }
    if(n != 1) res.push_back(n);
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    map<int,int> mp;
    REP(i,1,n+1){
        auto primes = get_primes(i);
        for(auto prime : primes) ++mp[prime];
    }
    int c2=0,c4=0,c14=0,c24=0,c74=0;
    for(auto p : mp){
        int cnt = p.se;
        if(cnt >= 2) c2++;
        if(cnt >= 4) c4++;
        if(cnt >= 14) c14++;
        if(cnt >= 24) c24++;
        if(cnt >= 74) c74++;
    }

    int ans = 0;
    if(c4 >= 2 && c2 >= 3) ans += c4*(c4-1)/2 * (c2-2);
    if(c14 >= 1 && c4 >= 2) ans += c14 * (c4-1);
    if(c24 >= 1 && c2 >= 2) ans += c24 * (c2-1);
    if(c74 >= 1) ans += c74;
    cout << ans << endl;
    return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

long long dist[MAX] ;

vector< vector< pair<int , long long> > >adj(MAX) ;

void dfs(int node , int par , long long d)
{
	dist[node] = d ;
	for(auto &child : adj[node])
	{
		if(child.first == par)
			continue ;
		dfs(child.first , node , d + child.second) ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		long long z ;
		cin>>x>>y>>z ;
		adj[x].push_back({y , z}) ;
		adj[y].push_back({x , z}) ;
	}
	int q , k ;
	cin>>q>>k ;
	dfs(k , -1 , 0) ;
	while(q--)
	{
		int x , y ;
		cin>>x>>y ;
		long long ans = dist[x] + dist[y] ;
		cout<<ans<<"\n" ;
	}
	return 0 ;
}

Measured memory_bytes: 14336
#include<stdio.h>

int main(void)
{
    int n, i, num, S[14]={0}, H[14]={0}, C[14]={0}, D[14]={0};
    char mark;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%c", &mark);
        scanf("%c %d", &mark, &num);
        switch(mark){
          case 'S' : S[num]=1;   break;
          case 'H' : H[num]=1;   break; 
          case 'C' : C[num]=1;   break; 
          case 'D' : D[num]=1;   break;
          default :              break;
        }
    }
    
    for(i=1; i<=13; i++){
        if(S[i]==0){
            printf("S %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(H[i]==0){
            printf("H %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(C[i]==0){
            printf("C %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(D[i]==0){
            printf("D %d\n", i);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    vll h(11, 0);
    h[a]++; h[b]++; h[c]++;
    (h[5] == 2 && h[7] == 1) ? cout << "YES\n" : cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if(s.Length<=k){
                Console.WriteLine(s);
                return;
            }
            for(int i=0; i<k; i++){
                Console.Write(s[i]);
            }
            Console.WriteLine("...");
            return;
        }
    }
}


Measured memory_bytes: 27476
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>

using namespace std;

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

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

int main(int argc, const char * argv[]) {

    // source code
    // char s[4];
    int r, D, X;
    cin >> r >> D >> X;
    int i = 0;
    while (i < 10){
      X = r*X -D;
      cout << X <<endl;
      i++;
    }
    // if (A >= 13) {
    //   cout << B <<endl;
    // }else if (A >= 6 ){
    //   cout << B/2 <<endl;
    // }else{
    //   cout << 0 <<endl;
    // }


    return 0;
}

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            var split = Console.ReadLine().Split(' ');
            var x = int.Parse(split[0]);
            var y = int.Parse(split[1]);
            var absX = Math.Abs(x);
            var absY = Math.Abs(y);
            var absDiff = Math.Max(absX, absY) - Math.Min(absX, absY);

            var results = new List<int>(4);

            // 連打
            if (y >= x) results.Add(y - x);

            // 反転して足す
            if (y == -x + absDiff) results.Add(1 + absDiff);

            // 足してから反転
            if (y == -(x + absDiff))
                results.Add(1 + absDiff);

            // 反転して足して反転
            if (y == -(-x + absDiff))
                results.Add(2 + absDiff);

            Console.WriteLine(results.Min());
        }
    }
}


Measured memory_bytes: 2776
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        
        int start =0;
        int end =0;
        boolean j1 = false;
        
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i) == 'A' && j1 == false){
                start = i;
                j1 = true;
            }
            
            else if(S.charAt(i) == 'Z'){
                end = i;
            }
        }
        
        int answer = end - start +1;
        
        System.out.println(answer);
        
    }
}


Measured memory_bytes: 26628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Program
{
    private int N;
    private int[] A1, A2;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A1 = new int[N];
        A2 = new int[N];
        for (int i = 0; i < N; i++)
        {
            A1[i] = sc.NextInt();
        }
        for (int i = 0; i < N; i++)
        {
            A2[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        Scan();
        for(int i=1;i<N;i++)
        {
            A1[i] += A1[i - 1];
            A2[N - i - 1] += A2[N - i];
        }
        int max = -1;
        for(int i=0;i<N;i++)
        {
            max = Math.Max(A1[i] + A2[i], max);
        }
        Console.WriteLine(max);
    }

    static public void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,a[105];
double cnt;
int ans,ansn=0x7f7f7f7f; 
int main()
{
	fast;
	cin>>n;
	for (int i=0;i<n;i++)
	   cin>>a[i],cnt+=a[i];
	cnt/=n;
	for (int i=0;i<n;i++)
	   if (abs(a[i]-cnt)<abs(ansn-cnt))
	   {
	   	   ans=i;
	   	   ansn=a[i];
	   }
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int X; cin >> X;
	if (X == 3 || X == 5 || X == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
using lint=int64_t;
using namespace std;

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

	map<lint,lint> indexof;
	map<lint,lint> valueof;
	for(lint i=1;i<=N;i++)
	{
		lint val;
		cin >> val;
		indexof[val]=i;
		valueof[i]=val;
	}
	valueof[0]=valueof[1];
	valueof[N+1]=valueof[N];

	multiset<lint> ipool;
	ipool.insert(0);
	ipool.insert(0);
	ipool.insert(N+1);
	ipool.insert(N+1);
	
	lint ans=0;
	for(lint i=N;i>=1;i--)
	{
		lint l2,l1,r1,r2;
		auto itr=ipool.lower_bound(indexof[i]);
		r1=*itr;
		++itr;
		r2=*itr;
		--itr;--itr;
		l1=*itr;
		--itr;
		l2=*itr;

		ans+=(indexof[i]-l1)*(r2-r1)*i;
		ans+=(l1-l2)*(r1-indexof[i])*i;

		ipool.insert(indexof[i]);
	}

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



Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,a,b;
  	cin>>n>>a>>b;
  	long long  sho,amari,sum=0;
  if(a+b==0){
  	cout<<0<<endl;
  }
  else{
  	sho=n/(a+b);
  	sum=sum+sho*a;
  	amari=n%(a+b);
  	if(amari>=a){
    	sum=sum+a;
    }
  	else{
    	sum=sum+amari;
    }
  	cout<<sum<<endl;
  }
}

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

int main(){
  string a,b,c;
  
  cin>>a>>b>>c;
  
  cout<<char(a[0]+'A'-'a')<<char(b[0]+'A'-'a')<<char(c[0]+'A'-'a')<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n;
    cin >> n;
    
    ll sum = 0;
    rep3(i, 1, 100000) {
        sum += i;
        if (sum >= n) {
            cout << i << endl;
            return 0;
        }
    }
}


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

int main(){
  ll n,m; cin >>n >>m;
  ll ans = 0;
  if(n==1 && m==1) ans = 1;
  else if(n==1 && m!=1) ans = m-2;
  else if(m==1 && n!=1) ans = n-2;
  else ans = (n-2)*(m-2);
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3592