akhauriyash/Code-Regression huggingface dataset:
using System;

class Program {
    static void Main (string[] args) {
        long K = long.Parse (Console.ReadLine ());
        long ans = 0;
        for (long x = 1; x <= K; x++) {
            for (long y = x; y <= K; y++) {
                for (long z = y; z <= K; z++) {
                    long gcd = Gcd (Gcd (x, y), z);
                    if (x == y && y == z) {
                        ans += gcd;
                    } else if (x == y || y == z || z == x) {
                        ans += 3 * gcd;
                    } else {
                        ans += 6 * gcd;
                    }
                }
            }
        }

        Console.WriteLine (ans);
    }

    public static long Gcd (long a, long b) {
        if (a < b) {
            return Gcd (b, a);
        }
        while (b != 0) {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}

Measured memory_bytes: 27480
N = input()
a = list(map(int, input().split()))

point = 1
count = 0
ans = -1

if N == 1 and a[0] == 1:
  ans = 0
else:
  for i in a:
    if i == point:
      count += 1
      point += 1
      
if count == 0:
  print(ans)
else:
  print(len(a)-count)

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, N-1) if(A[i] == A[i+1]){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

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

long long solve(int &N, vector<int> &A) {
  long long ways = 1LL;
  for(int i = 1; i <= N; ++i)
    ways = ways * 3LL;
  long long sum = 1LL;
  for(int i = 0; i < N; ++i)
    if(A[i] % 2 == 0)
      sum = sum * 2LL;
  return ways - sum;
}

int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.resize(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  cout << solve(N, A) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main(){int N=IN(),count=0;rep(i,N-1){count+=(N-1)/(i+1);}return OUT(count),0;}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    rep(i,0,n){
    	cin>>arr[i];
    }
    mii m;
    m[1]=0;
    ll pos=1;
    ll prev=1;
    ll kahase;
    ll diff;
    while(true){
    	if (m.find(arr[prev-1])==m.end()){
	    	m[arr[prev-1]]=pos;
	    	pos++;
	    	prev=arr[prev-1];
	    }
	    else{
	    	diff=pos-m[arr[prev-1]];
	    	kahase=m[arr[prev-1]];
	    	break;
	    }
    }
    if (k>kahase){
    	ll meow=(k-kahase)%diff;
    	k=kahase+meow;
    }
    ll acha=1;
    rep(i,0,k){
    	acha=arr[acha-1];
    }
    cout<<acha<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 17508
func sReadLine() -> [String] {
    return readLine()!.characters.split(" ").map{String($0)}
}
func sReadInt() -> [Int] {
    let strs = sReadLine()
    return strs.map{Int($0)!}
}
func readInt() -> Int {
    return Int(readLine()!)!
}
/************** main *****************/
let n = readInt()
var sparr: [(String, Int, Int)] = (1...n).map { i in
    let sp = sReadLine()
    return (sp[0], Int(sp[1])!, i)
}
for ssp in sparr.sort({$0.0 == $1.0 ? $0.1 > $1.1 : $0.0 < $1.0}) {
    print(ssp.2)
}


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,p;cin>>a>>p;
  cout << (a*3+p)/2 << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

int f(int num) {
	int cnt = 0;
	while (num%100==0) {
		cnt++;
		num /= 100;
	}
	return cnt;
}

signed main() {
	int D, N;
	cin >> D >> N;
	int i = 1;
	int n = 0;
	while (n != N) {
		if (f(i) == D) {
			n++;
			if (n == N)break;
		}
		i++;
	}
	cout << i;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin >>s>>t;
    int a,b;
	cin >>a>>b;
	string u;
	cin>>u;
	if(u==s)a--;
	else{b--;}
    cout <<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

fn main() {
    input!{
        s: chars,
        t: chars,
    }

    let mut match_point = None;
    's: for (i, s_t) in s.windows(t.len()).enumerate() {
        't: for (&s_c, &t_c) in s_t.iter().zip(t.iter()) {
            if s_c != t_c && s_c != '?' {
                continue 's;
            }
        }

        match_point = Some(i);
    }

    let answer = if let Some(match_start) = match_point {
        let mut answer = String::new();
        let mut t_i = 0;
        for (i, &s_c) in s.iter().enumerate() {
            answer.push(
                if t_i < t.len() && i == match_start + t_i {
                    let t_c = t[t_i];
                    t_i += 1;
                    t_c
                } else if s_c == '?' {
                    'a'
                } else {
                    s_c
                }
            );
        }
        answer
    } else {
        "UNRESTORABLE".to_string()
    };

    println!("{}", answer);
}


Measured memory_bytes: 4352
def examB():
    A, B, K = LI()
    ans = []
    for i in range(K):
        low = min(B,A+i); up = max(B-i,A)
        if low not in ans:
            ans.append(low)
        if up not in ans:
            ans.append(up)
    ans.sort()
    for v in ans:
        print(v)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    
    vector<int> a(n);
    
    for (int &x : a)
    {
        cin >> x;
    }
    
    sort(a.begin(), a.end(), greater<int>());
    
    long long x = 0, y = 0;
    
    for (int i = 0; i + 1 < n; i++)
    {
        if (a[i] == a[i + 1])
        {
             if (x == 0)
                x = a[i];
             else if(y == 0)
                y = a[i];
            i++;
        }
    }
    
    cout << 1LL * x * y;
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,ans;

int main()
{
  cin>>N>>M;
  
  ans=N*(N-1)+M*(M-1);
  ans=ans/2;
  
  cout<<ans;
}

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

using namespace std;
int main(void){
    int A,B,K;
    cin >> A >> B >> K;
    
    int divide[110] = {};
    
    int j=0;
    int limit;
    limit = min(A,B);
    for(int i=limit;i>=1;i--){
        if(A%i==0 and B%i==0){
            K--;
            if(K==0) {
                cout << i;
                return 0;
            }
        }
    }
    
  //  cout << divide[K-1];

    return 0;
    
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
const int lim = 100005;
int main(){
    int n;
    cin >> n;
    vector<int> a(lim, 0);
    for(int i = 0; i < n; i++){
        int a1;
        cin >> a1;
        a[a1]++;
    }
    for(int i = 0; i < lim; i++){
        if(a[i] != 0){
            a[i] = 2-a[i]%2;
        }
    }
    
    int twonum = 0;
    int ans = 0;
    for(int i = 0; i < lim; i++){
        if(a[i] == 2) twonum++;
        if(a[i] != 0) ans++;
    }

    if(twonum % 2) ans--;
    cout << ans << endl;
    return 0;
}

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

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//sを繋げて新たな"AB"ができるのは末尾がAの文字列と先頭がBの文字列を繋げた場合で、
/*
*/

int main() {
   int N;
   cin >> N;
   vector<string> s(N);
   rep(i,N){
       cin >> s[i];
   }

   int cAB = 0;//(B,A)型の数
   int cA = 0;//(0,A)型の数
   int cB = 0;//(B,0)型の数
   rep(i,N){
       if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') cAB++;
       if(s[i][0] != 'B' && s[i][s[i].size()-1] == 'A') cA++;
       if(s[i][0] == 'B' && s[i][s[i].size()-1] != 'A') cB++;
   }
   ll ans = 0;
   //各sの内側にある"AB"の個数をカウント
   for(int i = 0;i<N;i++){
       for(int j = 0;j<s[i].size()-1;j++){
           if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
       }
   }
  // cout << ans << endl;

   if(cA == 0 && cB == 0){
       ans += max(cAB-1,0);
   }
  else ans += (cAB + min(cA,cB));


   cout << ans << endl;
   //cout << cAB << " " << cA << " " << cB << endl;
 }

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N,M,X;
  cin>>N>>M>>X;
  ll right=0,left=0;
  ll A[M];
  for(ll i=0; i<M; ++i){
    cin>>A[i];
    if(X<A[i]){right++;}
    if(X>A[i]){left++;}}
  cout<<min(right,left)<<endl;
}
  




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int i,a[10000];
	for(i=0;i<10000;i++){
		scanf("%d",&a[i]);
		
		if(a[i]==0){
		break;}
	}
	for(i=0;i<10000;i++){
		if(a[i]==0){
		break;}
		printf("Case %d: %d\n",i+1,a[i]);
	}
	return 0;
}

Measured memory_bytes: 632
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 2 << 25;
	int n,k;
	int[][] map;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			k = sc.nextInt();
			if((n|k) == 0) break;
			map = new int[n][n];
			for(int[] a: map) fill(a, INF);
			for(int i=0;i<n;i++) map[i][i] = 0;
			boolean updated = false;
			for(int i=0;i<k;i++) {
				int f = sc.nextInt();
				if( f == 0 ) {
//					if( !updated ) wf(0,0);
					updated = true;
					int a = sc.nextInt()-1;
					int b = sc.nextInt()-1;
					if( map[a][b] == INF) System.out.println(-1);
					else System.out.println(map[a][b]);
				}
				else {
					int c = sc.nextInt()-1;
					int d = sc.nextInt()-1;
					int e = sc.nextInt();
					map[c][d] = map[d][c] = min(e, map[c][d]);
					wf(new int[] {c, d});
					updated = false;
				}
			}
		}
	}
	
	void wf(int a[]) {
		for (int k=0;k<a.length;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++){
			map[i][j] = min(map[i][j], map[i][a[k]] + map[a[k]][j]);
		}
	}

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

Measured memory_bytes: 13000
#include <stdio.h>

int main()
{
    int m = 0, f = 0, r = 0, m1;
    do
    {
        scanf("%d %d %d", &m, &f, &r);
        m1 = m + f;
        if (m != -1 || f != -1 || r != -1)
        {
            if (m == -1 || f == -1)
            {
                printf("F\n");
            }
            else if (m1 >= 80)
            {
                printf("A\n");
            }
            else if (m1 >= 65 && m1 < 80)
            {
                printf("B\n");
            }
            else if (m1 >= 50 && m1 < 65)
            {
                printf("C\n");
            }
            else if (m1 >= 30 && m1 < 50)
            {
                if (r >= 50)
                {
                    printf("C\n");
                }
                else
                {
                    printf("D\n");
                }
            }
            else
            {
                printf("F\n");
            }
        }
    } while (m != -1 || f != -1 || r != -1);
}


Measured memory_bytes: 2036
count=int(raw_input())
ans =[]
for i in range(0,count):
    a,b,c=map(int,raw_input().split())
    if pow(a,2)+pow(b,2)==pow(c,2):
        ans.append("YES")
    elif pow(a,2)+pow(c,2)==pow(b,2):
        ans.append("YES")
    elif pow(b,2)+pow(c,2)==pow(a,2):
        ans.append("YES")
    else:
        ans.append("NO")

for i in range(0,count):
    print ans[i]

Measured memory_bytes: 4684
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(a:u32, b:u32, c:u32, d:u32) -> u32 {
    use std::cmp::min;

    min(a,b) + min(c,d)
}

fn main() {
    let a = parse_line!(u32);
    let b = parse_line!(u32);
    let c = parse_line!(u32);
    let d = parse_line!(u32);
    println!("{}", solve(a,b,c,d));
}

#[test]
fn solve_test() {
    assert_eq!(solve(600, 300, 220, 420), 520);
    assert_eq!(solve(555,555,400,200), 755);
    assert_eq!(solve(549,817,715,603), 1152);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main() {
	int r, D, x_2000;
	cin >> r >> D >> x_2000;
	int ans = x_2000;

	for(int i = 0; i < 10; i++){
		ans = r * ans - D;
		cout << ans <<  endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,p,i,j,k,l,m,o,q,r,s,t,pre[200001],ss[20000]={0};
    string a;
    cin>>n>>p;
     pre[0]=1%p;

    cin>>a;
    if(p==2)
    {
        m=0;
       for(i=0;i<n;i++)
       {
           if(a[i]=='2'||a[i]=='0'||a[i]=='6'||a[i]=='8'||a[i]=='4')
           {
               m+=(i+1);
           }
       }
       k=m; 
    }
    else if(p==5)
    {
        m=0;
       for(i=0;i<n;i++)
       {
           if(a[i]=='5'||a[i]=='0'||a[i]=='5'||a[i]=='0'||a[i]=='5')
           {
               m+=i+1;
           }
       }
       k=m;
    }
     else 
     {
         for(i=1;i<=200000;i++)
     {
         pre[i]=(10*pre[i-1])%p;
     }
     m=0;
     s=0;
     for(i=0;i<n;i++)
     {
          o=a[i]-'0';
          s+=((pre[n-1-i]*o)%p);
          ss[s%p]++;
     }
     for(i=0;i<=10000;i++)
     {
         m=ss[i];
         if(i==0)
         k+=(m*(m-1))/2+m;
         else 
         k+=(m*(m-1))/2;
     }
     }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 2308
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MOD 2019

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

	int N;
	vector<int> A, B;

	cin >> N;
	for(int i=0; i<N; i++){
		int  a;
		cin >> a;
		A.push_back(a);
		B.push_back(a);
	}

	sort(B.begin(), B.end());

	for(int i=0; i<N; i++){
		if(A[i] == B[N - 1]){
			cout << B[N - 2] << endl;
		}
		else{
			cout << B[N - 1] << endl;
		}
	}
	return 0;
}

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

int main()
{
    char S[4];
    int count=0;
    int i, j;

    cin >> S[0] >> S[1] >> S[2] >> S[3];

    for (j = 0; j < 3; j++) {
        for (i = 1; i < 4-j; i++) {
            if (S[j] == S[j+i])
            {
                count++;
            }
        }
    }

    string answer;


    if (count == 2) {
        answer = "Yes";
    }
    else {
        answer = "No";
    }

    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    forn(i, n){
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int j = 0; j < 3; ++j) {
            scanf("%d", &c[j]);
        }
        for(int k = 0; k < 3; ++k){
        for(int j = 0; j < 3; ++j){
            if(k != j){
                    new_dp[j] = max(new_dp[j], dp[k] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d", max({dp[0], dp[1], dp[2]}));
}

Measured memory_bytes: 384
i = raw_input().strip().split()

l = [int(i[0]),int(i[1]),int(i[2])]
tmp = 0

for j in range(3):
    for k in range(3):
        if l[k] > l[j]:
            tmp = l[j]
            l[j] = l[k]
            l[k] = tmp

print str(l[0])+" "+str(l[1])+" "+str(l[2])

Measured memory_bytes: 6428
#include <iostream> 
#include<vector>
#include<algorithm>
using namespace std; 
int main() {
	int n;
	int cnt = 10000000;
	while (cin >> n, n != 0) {
		vector <int> vec(n);
		for (int i = 0; i < n; i++) {
			cin >> vec.at(i);
		}
		sort(vec.begin(), vec.end());
		for (int j = 0; j < n-1; j++) {
			cnt = min(cnt, vec.at(j + 1) - vec.at(j));
		}
		cout << cnt << endl;
		cnt = 10000000;
	}
}



Measured memory_bytes: 3148
#解説より
cost=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=sorted(map(int,input().split()))[::-1]
dp=[0]
for i in range(1,N+1):
    l=[dp[i-cost[a]]for a in A if i>=cost[a]]
    if len(l)==0:dp+=[-1]
    else:dp+=[max(l)+1]
S=''
Sum=0
for i in range(dp[N]):
    for a in A:
        if N-Sum-cost[a]>=0 and dp[N-Sum-cost[a]]==dp[N]-1-i:
            S+=str(a)
            Sum+=cost[a]
            break
print(S)

Measured memory_bytes: 3316
import java.util.Scanner;

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

        long sum = 100;
        long year = 0;
        while(sum < x) {
            year++;
            sum *= 1.01;
        }
        
        System.out.println(year);
    }
}

Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
int a[100010],dp[100010],n;
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    fill(dp,dp+100005,1000000001);
    dp[1]=0;
    for(int i=1;i<=n;i++){
        dp[i+1]=min(abs(a[i+1]-a[i])+dp[i],dp[i+1]);
        dp[i+2]=min(abs(a[i+2]-a[i])+dp[i],dp[i+2]);
    }
    cout<<dp[n];
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("FORM MAU.inp","r",stdin);
    //freopen("FORM MAU.out","w",stdout);

    //srand(time(0));

    //int t;cin>>t;while(t--)
    //cout << setprecision(2) <<fixed;
    solve();
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';


const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ull MOD = 1e9 + 7;
const int N = (int)(5e5) + 1;


ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, k, w[101], v[101];
ll dp[N][101];

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

	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", w + i, v + i);
	}
	ll ans = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if(j - w[i] >= 0)
				dp[j][i] = max(dp[j][i - 1], dp[j - w[i]][i - 1] + v[i]);

			dp[j][i] = max(dp[j][i], dp[j][i - 1]);

		}
	}

	printf("%lld", dp[k][n]);
}

Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n;
ll f[1000005];
int main(){
	scanf("%d",&n);
	f[1]=n;
	f[0]=1;
	ll sum=0;
	for(int i=2;i<=n;i++){
		f[i]=(sum+f[i-1]+1LL*(n-1)*(n-1)+(n-i+1))%mod;
		sum=(sum+f[i-2])%mod;
	}
	printf("%lld",f[n]);
	return 0;
}

Measured memory_bytes: 8064
p = list(map(int, input().split()))
ps = list(zip(p[::2], p[1::2]))

ans = ""
for _ in range(2):
  v = list(map(lambda x, y: x - y, ps[1], ps[0]))
  v = [-v[1], v[0]]
  ps = [ps[1], list(map(lambda x, y: x + y, ps[1], v))]
  ans += " " + " ".join(map(str, ps[1]))

print(ans[0:])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";

const int MAX = 1000001;
vector<long long >isprime(MAX , true); 
vector<long long >prime; 
vector<long long >SPF(MAX); 
void Seive(int N) 
{ 
    isprime[0] = isprime[1] = false ; 
   
    for (long long int i=2; i<N ; i++) 
    { 
        if (isprime[i]) 
        { 
            prime.push_back(i);  
            SPF[i] = i; 
        } 
  
        for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) 
        { 
            isprime[i*prime[j]]=false; 
   
            SPF[i*prime[j]] = prime[j] ; 
        } 
    } 
} 

ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0) 
        return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 

void solve(){
	int n,we;
	cin>>n>>we;
	vector<ll>val(n),weight(n);
	for(int i=0;i<n;i++) cin>>weight[i]>>val[i];
	vector<vector<ll>>dp(we+1,vector<ll>(n+1));
	for(int i=0;i<=we;i++){
		for(int j=0;j<=n;j++){
			if(i==0 || j==0){ dp[i][j] = 0; continue;}
			if(i-weight[j-1]>=0)
			dp[i][j] = max(val[j-1] + dp[i-weight[j-1]][j-1],dp[i][j-1]);
			else
			dp[i][j] = dp[i][j-1];
		}
	}
	cout << *max_element(dp[we].begin(),dp[we].end());
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}

return 0;
}

Measured memory_bytes: 100840
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll absdif(ll a, ll b) {
    return (a >= b) ? (a - b) : (b - a);
}
int main() {
    int n, z, w;
    cin >> n >> z >> w;
    ll a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    if ((n == 1) || (absdif(a[n], a[n - 1]) < (absdif(a[n], w)))) {
        cout << absdif(a[n], w) << endl;
    }
    else {
        cout << absdif(a[n], a[n - 1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
memo = [{} for _ in range(n+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i>=1:
            t[i-1],t[i] = t[i],t[i-1]
        if "".join(t).count("AGC")>=1:
            return False
    return True


def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur==n:
        return 1
    ret = 0
    for c in "ACGT":
        if ok(last3+c):
            ret = (ret + dfs(cur+1,last3[1:]+c))%MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0,'TTT'))

Measured memory_bytes: 3884
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 枚数取得
int
fGetCnt(
	int *pipMCnt				// <O> １万円の枚数
	, int *pipGCnt				// <O> ５千円の枚数
	, int *pipSCnt				// <O> 千円の枚数
)
{
	int i, j;
	char lc1Buf[1024];

	// 初期化
	*pipMCnt = -1;
	*pipGCnt = -1;
	*pipSCnt = -1;

	// 枚数・合計取得
	int liCnt, liSum;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &liCnt, &liSum);

	// 合計を1/1000
	liSum /= 1000;

	// １万円の最大枚数
	int liMCnt = liSum / 10;

	// １万円の枚数でループ
	for (i = liMCnt; i >= 0; i--) {

		// 残額
		int liRest = liSum - 10 * i;

		// ５千円の最大枚数
		int liGCnt = liRest / 5;

		// ５千円の枚数でループ
		for (j = liGCnt; j >= 0; j--) {

			// 千円の枚数
			int liSCnt = liRest - 5 * j;

			// 枚数
			if (i + j + liSCnt == liCnt) {
				*pipMCnt = i;
				*pipGCnt = j;
				*pipSCnt = liSCnt;
				return 0;
			}
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 枚数取得
	int liMCnt, liGCnt, liSCnt;
	fGetCnt(&liMCnt, &liGCnt, &liSCnt);

	// 結果セット
	sprintf(lc1Out, "%d %d %d\n", liMCnt, liGCnt, liSCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim 1e5
using namespace std;

const lld mod=1e9+5;

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

	lld n;
	cin>>n;
	std::vector<lld> v(n);

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

	lld dp[n+1][n+1];

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
			dp[i][j]=mod;
	}

	for(lld L=n-1;L>=0;L--)
	{
		for(lld R=L;R<n;R++)
		{
			if(L==R)
				dp[L][R]= v[L];
			else
				dp[L][R] = max(v[L]-dp[L+1][R] , v[R]-dp[L][R-1]);
		}
	}


	cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main(){
	int R,G,B,N,count=0,k;
	scanf("%d%d%d%d",&R,&G,&B,&N);
	for(int i=0;i<N/R+1;i++){
		if (i*R==N){
			count++;
			continue;
		}

		for(int j=0;j<N/G+1;j++){
			if(i*R+j*G==N){
				count++;
				continue;
			}
			k=(N-i*R-j*G)/B;
			if(k<0)continue;
			if(i*R+j*G+k*B==N){count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec: Vec<usize> = vec![];
    for _ in 1..N {
        vec.push(read::<usize>() - 1);
    }
    let mut ans_vec: Vec<usize> = vec![0; N];
    for v in vec {
        ans_vec[v] += 1;
    }
    for v in ans_vec {
        println!("{}", v);
    }
}


Measured memory_bytes: 4992
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        // スペース区切りの整数の入力
        int m = sc.nextInt();
        int l_max =  sc.nextInt();
        int r_min =  sc.nextInt();;

        for(int i = 0; i < m - 1; i++){
            l_max = Math.max(l_max, sc.nextInt());
            r_min = Math.min(r_min, sc.nextInt());
        }

        int ans;
        if(r_min - l_max >= 0){
            ans = r_min - l_max + 1;
        }else{
            ans = 0;
        }

        // 出力
        System.out.println(ans);

    }

}

Measured memory_bytes: 62596
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b%a == 0){
			System.out.println(a + b);
		}else{
			System.out.println(b - a);
		}
	}
}



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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(p);
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 38720
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a; str t; cin>>a>>t;
    if(a>=3200) cout<<t;
    else cout<<"red";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin>>a[i];
  sort(a.begin(),a.end());
  int aa[100010]={};
  for(int i=0;i<N;i++){
    aa[a[i]]++;
  }
  int ans=0;
  for(int i=0;i<100000;i++){
    ans=max(ans,aa[i]+aa[i+1]+aa[i+2]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = 998244353
INF=float('inf')

n,x,m=mdata()
d=dd(int)
d[x]=0
l=[x]
ans=x
for i in range(n-1):
    x**=2
    if x%m in d:
        x%=m
        ans+=sum(l[d[x]:])*((n-1-i)//(len(l)-d[x])) + sum(l[d[x]:d[x]+((n-1-i)%(len(l)-d[x]))])
        break
    else:
        x%=m
        ans+=x
        d[x]=i+1
        l.append(x)
out(ans)

Measured memory_bytes: 83280
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        String a,b;

        a = sc.next();
        b = sc.next();
        int a2=0,b2=0;
        if(a.equals("A")) a2 = 10;
        else if(a.equals("B")) a2 =11;
        else if(a.equals("C")) a2 = 12;
        else if(a.equals("D")) a2=13;
        else if(a.equals("E")) a2=14;
        else if (a.equals("F"))a2 =15;

        if(b.equals("A")) b2 = 10;
        else if(b.equals("B")) b2 =11;
        else if(b.equals("C")) b2 = 12;
        else if(b.equals("D")) b2=13;
        else if(b.equals("E")) b2=14;
        else if(b.equals("F")) b2 =15;

        if(a2>b2) System.out.println(">");
        else if(a2<b2) System.out.println("<");
        else if(a2==b2) System.out.println("=");
    }
}


Measured memory_bytes: 22100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;

int W, H;

const int MAX_H = 50;
const int MAX_W = 50;
bool isblack[MAX_H][MAX_W];
bool iswhite[MAX_H][MAX_W];
char field[MAX_H][MAX_W];

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

void get(int x, int y, bool black) {
    if(!(0 <= x && x < W && 0 <= y && y < H)) return;
    if(field[y][x] != '.') return;

    if(black) {
        if(isblack[y][x]) return;
        isblack[y][x] = true;
    }
    else {
        if(iswhite[y][x]) return;
        iswhite[y][x] = true;
    }

    for(int i = 0; i < 4; i++) {
        get(x + dx[i], y + dy[i], black);
    }
}

int main() {
    for(; scanf("%d%d", &W, &H), W || H; ) {
        memset(isblack, 0, sizeof(isblack));
        memset(iswhite, 0, sizeof(iswhite));

        for(int i = 0; i < H; i++) scanf(" %s", field[i]);


        for(int y = 0; y < H; y++) {
            for(int x = 0; x < W; x++) {
                if(field[y][x] == 'B') {
                    for(int i = 0; i < 4; i++) {
                        get(x + dx[i], y + dy[i], true);
                    }
                }

                if(field[y][x] == 'W') {
                    for(int i = 0; i < 4; i++) {
                        get(x + dx[i], y + dy[i], false);
                    }
                }
            }
        }

        int b = 0;
        int w = 0;
        for(int y = 0; y < H; y++) {
            for(int x = 0; x < W; x++) {
                if(isblack[y][x] && !iswhite[y][x]) b++;
                if(!isblack[y][x] && iswhite[y][x]) w++;
            }
        }

        printf("%d %d\n", b, w);
    }
}

Measured memory_bytes: 1088
#include <iostream>
#include <vector>

using namespace std;

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

    int a=0;
    int b=0;
    int current_start = 0;
    int last_height = 0;
    int height = 0;
    cin >> last_height;

    for(int i=1; i<N; i++)
    {
        cin >> height;
        if(height <= last_height)
        {
            if(i - current_start > b-a)
            {
                a = current_start;
                b = i;
            } 
        }
        else //height > last_height
        {
            current_start = i;
        }
        last_height = height;
    }

    cout << b-a << endl;


    return 0;
}

Measured memory_bytes: 256
# AOJ 0201: Wrought Gold Master
# Python3 2018.6.26 bal4u

INF = 0x7fffffff

def calc(t):
	ans = INF
	if len(mono[t][1]) > 0:
		ans = 0
		for i in mono[t][1]: ans += calc(i)
	return min(ans, mono[t][0])

while True:
	n = int(input())
	if n == 0: break
	mono = {}
	for i in range(n):
		s, p = input().split()
		mono[s] = (int(p), [])
	m = int(input())
	for i in range(m):
		a = input().split()
		s, p = a[0], INF
		if s in mono: p = mono[s][0]
		mono[s] = (p, a[2:])
	print(calc(input()))



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

long index_10(int x) {
  int n=1;
  for (int i=0;i<x;i++) {
    n = n*10;
  }
  return n;
}

int main() {
  long N;
  cin >> N;
  
  vector<int> d(10);
  d.at(0) = N%10;
  int sum=d.at(0);
  for (int i=1;i<10;i++) {
    d.at(i) = (N%index_10(i+1)-N%index_10(i))/index_10(i);
    sum += d.at(i);
  }
  
  if (N%sum==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  string S;

  cin >> N >> S;

  int size = S.size();

  for (int i = 0; i < size; i++) {
    S[i] = (S[i] - 'A' + N) % 26 + 'A';
  }

  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <sstream>

using namespace std;
string bubble_sort(string str, int ary_size, int &counter);
string intArrayToString(int* ary, int ary_size);

int main()
{
	string str;
	getline(cin, str);
	int num;
	stringstream num_ss(str);
	num_ss >> num;

	getline(cin, str);
	int counter = 0;


	cout << bubble_sort(str, num, counter) << endl;
	cout << counter << endl;
	return 0;
}

string bubble_sort(string str, int ary_size, int &counter) {
	int* ary = new int[ary_size];
	stringstream ss(str);
	string buff;
	int cnt = 0;
	while (getline(ss, buff, ' ')) {
		stringstream tss(buff);
		tss >> ary[cnt];
		cnt++;
	}

	// main.
	for (int j = ary_size - 2; j >= 0; j--) {
		for (int i = 0; i <= j; i++) {
			if (ary[i + 1] < ary[i]) {
				int tmp = ary[i];
				ary[i] = ary[i + 1];
				ary[i + 1] = tmp;
				counter++;
			}
		}
	}
	return intArrayToString(ary, ary_size);
}

string intArrayToString(int* ary, int ary_size) {
	string str = "";
	for (int i = 0; i < ary_size; i++) {
		if (i == ary_size - 1) {
			str += to_string(ary[i]);
		}
		else {
			str += to_string(ary[i]) + " ";
		}
	}
	return str;
}

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

int main(void) {
    int n, copy_n, sum = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    copy_n = n;
    while (copy_n >= 1) {
        sum += copy_n % 10;
        copy_n /= 10;
    }

    cout << (n % sum == 0? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int N, H, a, b;
    long int atop = -1;
    cin >> N >> H;
    long int B[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        atop = max(atop, a);
        B[i] = b;
    }
    sort(B, N+B, std::greater<int>() );
    long int ans = ceil((double)H / (double)atop);
    long int cnt = 0;
    double tmp, c;
    for (int i = 0; i < N; i++)
    {
        H -= B[i];
        cnt++;
        c = ceil((double)H / (double)atop);
        tmp = max(0.0, c);
        ans = min(ans, cnt + (long int)tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int C =sc.nextInt();
		int[][] ar=new int[C][100001];
		for(int i = 0; i<n; i++){
			int s = sc.nextInt()-1;
			int t = sc.nextInt()-1;
			int c = sc.nextInt()-1;
			for(int j=s; j<=t; j++){
				ar[c][j]=1;
			}
		}
		int ans=0;
		for(int i = 1; i<100001; i++){
			int max=0;
			for(int j = 0; j<C; j++){
				max+=ar[j][i];
			}
			ans=Math.max(ans,max);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 110940
n = int(input())
list1 = list(map(int,input().split()))

list2 = [0]*(max(list1)+1)

for i in range(len(list1)):
    list2[list1[i]] += 1

if list1[0] != 0:
    print(0)
    exit()

#根が2個あるならexit
if list2[0] != 1:
    print(0)
    exit()
#枝が繋がっていないならexit
if 0 in list2:
    print(0)
    exit()

count = 1
for i in range(1,len(list2)):
    count *= list2[i-1]**list2[i]
    count %= 998244353

print(count)

Measured memory_bytes: 52824
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
int main(){
	cin >> N >> K;
	double ans = 0.0;
	for(int i=1;i<=N;i++){
		int k = 0;
		int cur = i;
		while(cur<K){
			cur *= 2;
			k++;
		}
		double res = 1.0/(double)N;
		for(int j=0;j<k;j++)res *= 0.5;
		ans += res;
	}
	printf("%.12f\n",ans);
	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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int A,B;
	cin>>A>>B;
	if(A==1)A=14;
	if(B==1)B=14;
	string ans = "Bob";
	if(A>B)ans = "Alice";
	else if(A==B)ans ="Draw";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (a<1000)
            System.out.println("ABC");
        else
            System.out.println("ABD");
    }
}


Measured memory_bytes: 35572
#!/usr/bin/env python3
#ABC128 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
v = LI()
ans = -inf
for l in range(min(n,k)+1):
    for r in range(min(n,k)+1 - l):
        lst = v[:l] + v[n-r:]
        lst.sort()
        m = len(lst)
        s = sum(lst)
        t = k - (r + l)
        for i in range(min(m,t)):
            if lst[i] < 0:
                s -= lst[i]
        ans = max(ans,s)
print(ans)

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

int main()
{
    int N;
    std::cin >> N;
    long long ans = 0LL;

    for(int A=1; A<N; A++)
    {
        int B = (N-1) / A;
        ans += B;
    }
    

    std::cout << ans << std::endl;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  int ct = 0, cx = 0, cy = 0;
  for(int i = 0; i < n; i++){
    int t, x, y;
    cin >> t >> x >> y;

    int d = abs(x-cx) + abs(y-cy);
    if(d > t or d%2 != (t-ct)%2){
      cout << "No" << endl;
      return 0;
    }

    ct = t;
    cx = x;
    cy = y;
  }

  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";


    return 0;
}

Measured memory_bytes: 256