akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
const int INF=2e9;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  string s,t;
  cin>>s>>t;

  int ans=INF;
  int ofmax=s.length()-t.length();
  rep(of,ofmax+1){
    int d=0;
    rep(j,t.length()) if(t[j]!=s[of+j]) d++;
    chmin(ans,d);
  }

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}
//cout << fixed << setprecision(10);

int main(){
  ll n,ans=0; cin>>n;
  vector<ll>v(5);
  rep(i,n){
    string s; cin>>s;
  if(s[0]=='M') v[0]++;
     else if(s[0]=='A') v[1]++;
     else if(s[0]=='R') v[2]++;
     else if(s[0]=='C') v[3]++;
    else if(s[0]=='H') v[4]++;
  }
  for(ll i=0;i<3;i++){
  for(ll k=i+1;k<4;k++){
  for(ll l=k+1;l<5;l++){
  ans+=v[i]*v[k]*v[l];
  }
  }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// 入力関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 以下main
fn main() {
    let x: Vec<u32> = read_vec();
    let n = x[0] as usize;
    let q = x[1];
    let s: String = read();

    let side: Vec<Vec<usize>> = read_vec2(q);

    let editted = &s.replace("AC", "ac");
    let word: Vec<char> = editted.chars().collect();

    let mut count: u32 = 0;
    let mut count_vec: Vec<u32> = Vec::new();

    for i in 0..n {
        if word[i] == 'c' {
            count += 1;
        }
        count_vec.push(count);
    }

    for i in 0..q {
        let itr = i as usize;
        let ans = count_vec[side[itr][1] - 1] - count_vec[side[itr][0] - 1];
        println!("{}", ans);
    }
}


Measured memory_bytes: 11004
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt

    val evs =
      (0 until n).map { _ =>
        val a = in.readLine().toInt
        (0 until a).map { _ =>
          in.readLine().split("\\s+").map(_.toInt) match {
            case Array(x, y) => Array(x - 1, y)
          }
        }
      }

    System.out.println(
      (0 until (1 << n)).map { i =>
        if (evs.zipWithIndex.filter {
          case (ev, evIndex) => ((i >> evIndex) & 1) == 1
        }.forall {
          case (ev, evIndex) =>
            ev.forall { e =>
              ((i >> e(0)) & 1) == e(1)
            }
        }) {
          countBit(i)
        } else {
          0
        }
      }.max
    )
  }

  def countBit(n: Int): Int = {
    if (n == 0) {
      0
    } else {
      countBit(n / 2) + n % 2
    }
  }
}


Measured memory_bytes: 49052
package main

import (
	"fmt"
)

func myPow(a, n int) (b int) {
	b = 1
	for n > 0 {
		b *= a
		n--
	}
	return
}

func myMax(nums ...int) (max int) {
	max = nums[0]
	for i := 0; i < len(nums); i++ {
		if nums[i] > max {
			max = nums[i]
		}
	}
	return
}

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	max := myMax(a, b, c)
	fmt.Println(a + b + c - max + max*myPow(2, k))
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int i=0;
	int a,b;
	while(1){
		i++;
		scanf("%d %d",&a,&b);
		if(a==0&&b==0){break;}
		
		printf("%d %d\n",a<b?a:b,a<b?b:a);
	}
	return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> ans(N,0);
  int j;
  for (int i=0; i<2*M; i++){
    cin >> j;
    ans.at(j-1)++;
  }
  for (int i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [isize;n],
    }

    let mut ans = 0;
    l.sort();
    for i in 0..l.len() {
        for j in i + 1..l.len() {
            let ret = lower_bound(&l, l[i] + l[j], |x, y| x >= y);
            ans += ret - j as isize - 1;
        }
    }

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

fn lower_bound(v: &Vec<isize>, key: isize, compare: fn(isize, isize) -> bool) -> isize {
    let mut ng = -1;
    let mut ok = v.len() as isize;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if compare(v[mid as usize], key) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok
}


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

using namespace std;

int main()
{
  long long int n,k=0;
  cin>>n;
  while(n)
  {
    k++;
    n/=2;
  }
  // k=(1<<k);
  // cout<<k<<'\n';
  cout<<(long long)pow(2,k)-1<<'\n';
  
  
}


Measured memory_bytes: 256
#include <stdio.h>;

int main() {
        int i=1,k,l;

        while(1){
            for(k=1;k<10;++k){
                l=i*k;
                printf("%dx%d=%d\n",i,k,l);
            }
            if(i==9){
                break;
            }
            i=i+1;
        }
    return 0;
}

Measured memory_bytes: 1652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int size = s.size();
    string a = "abcdefghijklmnopqrstuvwxyz";
    int idx = 0;
    char nxt = a[idx];
    if (s[0] != nxt) {
        cout << nxt << "\n";
        return 0;
    }
    for(int i = 0; i < size; i++){
        if (s[i] != nxt){
            idx++;
            nxt = a[idx];
            if (s[i] != nxt) {
                cout << nxt << "\n";
                return 0;
            }
        }
    }
    if (nxt == 'z'){
        puts("None");
    }
    else {
        cout << a[idx+1] << "\n";
    }
    
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  int ans = 0;
  rep(i, n) {
    if (h <= a[i] && w <= b[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.to_i
if A == 0 && N % 500 != 0 then
	puts "No"
elsif A == 0 && N % 500 == 0 then
	puts "Yes"
elsif A != 0 && N % 500 <= A then
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// vector< int64_t > divisor(int64_t n) {
//   vector< int64_t > ret;
//   for(int64_t i = 1; i * i <= n; i++) {
//     if(n % i == 0) {
//       ret.push_back(i);
//       if(i * i != n) ret.push_back(n / i);
//     }
//   }
//   sort(begin(ret), end(ret));
//   return (ret);
// }

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


ll calcLcm(ll a, ll b) {
    ll x = a * b;
 
    if (a < b){
        ll tmp = a;
        a = b;
        b = tmp;
    }
   
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return x / b;
}


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll lcm = calcLcm(C, D);

    ll c_div = 0, d_div = 0, lcm_div = 0;
    ll beg, end;
    beg = (A%C != 0) ? A/C + 1 : A/C;
    end = B/C;
    c_div = end - beg + 1;
    //DEBUG(c_div);
    beg = (A%D != 0) ? A/D + 1 : A/D;
    end = B/D;
    d_div = end - beg + 1;
    //DEBUG(d_div);

    beg = (A%lcm != 0) ? A/lcm + 1 : A/lcm;
    end = B/lcm;
    lcm_div = end - beg + 1;
    //DEBUG(lcm_div);

    cout << B - A + 1 - c_div - d_div + lcm_div;

    return 0;
}



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

int main(void) {
	string N;
	cin >> N;
	int S = 0;
	for (int i = 0; i < (int)N.size(); i++) {
		S += (N[i] - '0');
	}
	int num = atoi(N.c_str());
	if (num % S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	// r g b
	// b > g > r

	int r,g,b,k;
	cin>>r>>g>>b>>k;	

	while(g<=r && k){
		g<<=1;
		k--;
	}

	while(b<=g && k){
		b<<=1;
		k--;
	}

	if(r<g && g<b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3656
x, y = map(int, input().split())
a = [4, 6, 9, 11]
b = [1, 3, 5, 7, 8, 10, 12]
if x == 2 or y == 2:
    print("No")
elif x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// C++ program to count number of triangles that can be 
// formed from given array 
#include <bits/stdc++.h> 
using namespace std; 

/* Following function is needed for library function 
qsort(). Refer 
http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/ */
int comp(const void* a, const void* b) 
{ return *(int*)a > *(int*)b ; } 

// Function to count all possible triangles with arr[] 
// elements 
int findNumberOfTriangles(int arr[], int n) 
{ 
	// Sort the array elements in non-decreasing order 
	qsort(arr, n, sizeof( arr[0] ), comp); 

	// Initialize count of triangles 
	int count = 0; 

	// Fix the first element. We need to run till n-3 
	// as the other two elements are selected from 
	// arr[i+1...n-1] 
	for (int i = 0; i < n - 2; ++i) 
	{ 
		// Initialize index of the rightmost third 
		// element 
		int k = i + 2; 

		// Fix the second element 
		for (int j = i + 1; j < n; ++j) 
		{ 
			// Find the rightmost element which is 
			// smaller than the sum of two fixed elements 
			// The important thing to note here is, we 
			// use the previous value of k. If value of 
			// arr[i] + arr[j-1] was greater than arr[k], 
			// then arr[i] + arr[j] must be greater than k, 
			// because the array is sorted. 
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k; 

			// Total number of possible triangles that can 
			// be formed with the two fixed elements is 
			// k - j - 1. The two fixed elements are arr[i] 
			// and arr[j]. All elements between arr[j+1]/ to 
			// arr[k-1] can form a triangle with arr[i] and arr[j]. 
			// One is subtracted from k because k is incremented 
			// one extra in above while loop. 
			// k will always be greater than j. If j becomes equal 
			// to k, then above loop will increment k, because arr[k] 
			// + arr[i] is always greater than arr[k] 
			if(k > j) 
			count += k - j - 1; 
		} 
	} 

	return count; 
} 

// Driver code 
int main() 
{ 
	int n,m;
	int arr[100001];
       cin>>n;
   for(int i=0;i<n;i++)
    cin>>arr[i];	   
	//int size = sizeof( arr ) / sizeof( arr[0] ); 

	cout<<findNumberOfTriangles( arr, n ); 

	return 0; 
} 



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var MOD = 1000000007;
        var prime = Calculation.PrimeList(num);
        var dic = new Dictionary<int, long>();
        for(var i = 2; i <= num; i++)
        {
            for(var j = 0; j < prime.Count; j++)
            {
                var p = prime[j];
                if (p > i * i) break;
                var ia = i;
                var count = 0;
                while (ia % p == 0)
                {
                    count++;
                    ia /= p;
                }
                if (count != 0)
                    if (dic.ContainsKey(p))
                        dic[p] += count;
                    else dic[p] = count;
            }
        }

        var result = 1L;
        foreach (var d in dic.Values)
        {
            result *= d + 1;
            result %= MOD;
        }
        WriteLine(result);
    }
}

public class Calculation
{
public static List<int> PrimeList(int length)
    {
        var primeList = new List<int> { 2 };
        for (int i = 3; i <= length; i += 2)
        {
            var isPrime = true;
            for (var j = 1; j * j < i; j++)
            {
                var prime = primeList[j - 1];
                if (i % prime == 0) { isPrime = false; break; }
            }
            if (isPrime) primeList.Add(i);
        }
        return primeList;
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A = N / 100;
  int B = N % 100;
  if(B <= 5 * A){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)

int main() {
    double R;
    cin >> R;
    cout << 2 * R * 3.14159265 << endl;
}

Measured memory_bytes: 3788
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if p[i - 1] > p[i] and p[i] > p[i + 1]:
        ans += 1
    if p[i - 1] < p[i] and p[i] < p[i + 1]:
        ans += 1
print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>

using namespace std;

int main() {
    string s;
    cin >> s;
    
    int n = s.size();
    vector<int> ans(n, 0);
    int tmp = 0;
    for(int i = 1; i < n; i++) {
        tmp++;
        if(s[i - 1] == 'R' && s[i] == 'L') {
            ans[i] += tmp / 2;
            ans[i - 1] += (tmp / 2) + (tmp % 2);
            int index = 0;
            while(i + index < n && s[i + index] == 'L') {
                index++;
            }
            ans[i] += (index / 2) + (index % 2);
            ans[i - 1] += index / 2;
            
            i += index;
            tmp = 0;
        }
    }
    
    for(int i = 0; i < n; i++) {
        if(i == n - 1) {
            cout << ans[i] << endl;
        }
        else {
            cout << ans[i] << " ";
        }
    }
    
    return 0;
}



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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    deque<int> deq;

    int q;
    cin>>q;
    while(q--)
    {
        int m;
        cin>>m;
        switch(m)
        {
        case 0:
            int d,x;
            cin>>d>>x;
            if(!d)
                deq.push_front(x);
            else
                deq.push_back(x);
            break;
        case 1:
            int p;
            cin>>p;
            cout<<deq[p]<<endl;
            break;
        case 2:
            int d2;
            cin>>d2;
            if(!d2)
                deq.pop_front();
            else
                deq.pop_back();

        }
    }
}



Measured memory_bytes: 4592
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1e9+7;
int dp[3];
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    cin >> n;
    ll sana = 1;
    for(i=1;i<=n;i++)
    {
        cin >> curr;
        int index = 0;
        int cnt = 0;
        for(j=0;j<3;j++)
        {
            if(dp[j] == curr)
            {
                index = j;
                cnt++;
            }
        }
        sana = (sana*1LL*cnt) % mod;
        dp[index]++;
    }
    printf("%lld\n",sana);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  if(n==m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int n, m;
  cin >> n >> m;

  vi a(n+1, 0);
  vi err(n+1, 0);
  int acc=0, bad=0;

  rep(i,0,m) {
    int p;
    string s;
    cin >> p;
    cin >> s;
    if (s == "WA") {
      if (a[p] == 0) {
        ++err[p];
      }
    } else if (s == "AC") {
      a[p] = 1;
    }
  }
  rep(i,1,n+1) if (a[i]) bad += err[i];

  rep(i,1,n+1) if (a[i]) ++acc; 
  cout << acc << ' ' << bad << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int x(int s, int t, char u);
int main(){
  vector<int> n(4);
  while(cin >>n[0]>>n[1]>>n[2]>>n[3],n[0]||n[1]||n[2]||n[3]){
    sort(n.begin(),n.end());
    vector<char> a(3),b(3),c(3);
    bool f = false;
    a[0] = b[0] = c[0] = '+';
    a[1] = b[1] = c[1] = '-';
    a[2] = b[2] = c[2] = '*';
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    do{
      do{
	do{
	  do{
	    if(x(x(x(n[0],n[1],a[0]),n[2],b[0]),n[3],c[0]) == 10){cout <<"((("<<n[0]<<" "<<a[0]<<" "<<n[1]<<") "<<b[0]<<" "<<n[2]<<") "<<c[0]<<" "<<n[3]<<")"<<endl;f = true;}
	    else if(x(x(n[0],n[1],a[0]),x(n[2],n[3],c[0]),b[0]) == 10){cout <<"(("<<n[0]<<" "<<a[0]<<" "<<n[1]<<") "<<b[0]<<" ("<<n[2]<<" "<<c[0]<<" "<<n[3]<<"))"<<endl;f = true;}
	    else if(x(x(n[0],x(n[1],n[2],b[0]),a[0]),n[3],c[0]) == 10){cout <<"(("<<n[0]<<" "<<a[0]<<" ("<<n[1]<<" "<<b[0]<<" "<<n[2]<<")) "<<c[0]<<" "<<n[3]<<")"<<endl;f = true;}
	    else if(x(n[0],x(x(n[1],n[2],b[0]),n[3],c[0]),a[0]) == 10){cout <<"("<<n[0]<<" "<<a[0]<<" (("<<n[1]<<" "<<b[0]<<" "<<n[2]<<") "<<c[0]<<" "<<n[3]<<"))"<<endl;f = true;}
	    else if(x(n[0],x(n[1],x(n[2],n[3],c[0]),b[0]),a[0]) == 10){cout <<"("<<n[0]<<" "<<a[0]<<" ("<<n[1]<<" "<<b[0]<<" ("<<n[2]<<" "<<c[0]<<" "<<n[3]<<")))"<<endl;f = true;}
	    if(f) break;
	  }while(next_permutation(a.begin(),a.end()));
	  if(f) break;
	}while(next_permutation(b.begin(),b.end()));
	if(f) break;
      }while(next_permutation(c.begin(),c.end()));
      if(f) break;
    }while(next_permutation(n.begin(),n.end()));
    if(!f) cout <<"0"<<endl;
  }
  return 0;
}
int x(int s, int t, char u){
  if(u == '+') return s+t;
  if(u == '-') return s-t;
  return s*t;
}

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

#define fi first
#define se second
#define ll long long

const int N = 100100;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int h[N];
long long d[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> h[i];
        }
        for(int i = 2; i <= n; i++){
                int cost1 = d[i - 1] + abs(h[i] - h[i - 1]);
                int cost2 = d[i - 2] + abs(h[i] - h[i - 2]);
                if(i == 2){
                        cost2 = 1e9;
                }
                d[i] = min(cost1, cost2);
        }
        cout << d[n] << "\n";
}


Measured memory_bytes: 1408
k, n = gets.split("\s").map(&:to_i)
a = gets.split("\s").map(&:to_i)

max_dist = 0

n.times do |i|
  dist = (a[i] - a[i-n+1]).abs
  if dist > k/2
    dist = k - dist
  end
  
  next if max_dist >= dist
  
  max_dist = dist
end

print k - max_dist

Measured memory_bytes: 17412
n = gets.chop.to_i
a_list = gets.chop.split.map(&:to_i)
ans = -1

is_continue = true
while is_continue
  a_list.count.times do |i|
    if a_list[i].even?
      a_list[i] /= 2
    else
      is_continue = false
      break
    end
  end
  ans += 1
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s,t;
  int q=0,w=-1,r=1,a;
  cin>>a>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[0]){
      q=0;
      r=1;
      for(int j=i;j<s.size();j++){
        if(s[j]!=t[q]) r=0;
        ++q;
      }
      if(w==-1&&r==1){w=i;}
    }
  }
  if(w==-1) w=t.size();
  cout<<s.size()+w<<"\n";
}

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

using namespace std;

static int sumb[2002][2002], sumw[2002][2002], k;

int solveb (int i, int j)
{
    int cntb=sumb[i-1][j-1]+(sumb[2*k][j-1]-sumb[i+k-1][j-1])+(sumb[i+k-1][j+k-1]-sumb[i+k-1][j-1]-sumb[i-1][j+k-1]+sumb[i-1][j-1]);
    cntb+=(sumb[2*k][2*k]-sumb[2*k][j+k-1]-sumb[i+k-1][2*k]+sumb[i+k-1][j+k-1])+(sumb[i-1][2*k]-sumb[i-1][j+k-1]);
    int cntw=(sumw[i+k-1][j-1]-sumw[i-1][j-1])+(sumw[2*k][j+k-1]-sumw[i+k-1][j+k-1]-sumw[2*k][j-1]+sumw[i+k-1][j-1]);
    cntw+=(sumw[i-1][j+k-1]-sumw[i-1][j-1])+(sumw[i+k-1][2*k]-sumw[i+k-1][j+k-1]-sumw[i-1][2*k]+sumw[i-1][j+k-1]);
    return (cntb+cntw);
}

int solvew(int i, int j)
{
    int cntw=sumw[i-1][j-1]+(sumw[2*k][j-1]-sumw[i+k-1][j-1])+(sumw[i+k-1][j+k-1]-sumw[i+k-1][j-1]-sumw[i-1][j+k-1]+sumw[i-1][j-1]);
    cntw+=(sumw[2*k][2*k]-sumw[2*k][j+k-1]-sumw[i+k-1][2*k]+sumw[i+k-1][j+k-1])+(sumw[i-1][2*k]-sumw[i-1][j+k-1]);
    int cntb=(sumb[i+k-1][j-1]-sumb[i-1][j-1])+(sumb[2*k][j+k-1]-sumb[i+k-1][j+k-1]-sumb[2*k][j-1]+sumb[i+k-1][j-1]);
    cntb+=(sumb[i-1][j+k-1]-sumb[i-1][j-1])+(sumb[i+k-1][2*k]-sumb[i+k-1][j+k-1]-sumb[i-1][2*k]+sumb[i-1][j+k-1]);
    return (cntb+cntw);
}

int main()
{
    int n, x, y, ans=0;
    char c;
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>x>>y>>c;
        x++; y++;
        if (x%(2*k)==0) x=2*k;
        else  x%=(2*k);
        if (y%(2*k)==0) y=2*k;
        else y%=(2*k);
        if (c=='B') sumb[x][y]++;
        else sumw[x][y]++;
    }
    for (int i=1; i<=k*2+1; i++)
    {
        for (int j=1; j<=k*2+1; j++)
        {
            sumb[i][j]+=sumb[i][j-1];
            sumw[i][j]+=sumw[i][j-1];
        }
    }
    for (int i=1; i<=k*2+1; i++)
    {
        for (int j=1; j<=k*2+1; j++)
        {
            sumb[i][j]+=sumb[i-1][j];
            sumw[i][j]+=sumw[i-1][j];
        }
    }
    for (int i=1; i<=k; i++) for (int j=1; j<=k; j++) ans=max(ans, max(solveb(i, j), solvew(i, j)));
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 31616
#XorではなくAND
#上の桁優先、不可能なら無視
import bisect
n,k=map(int, input().split())
a_ = list(map(int, input().split()))

a = []

for i in range(n):
    a_sm = a_[i]
    a.append(a_sm)
    for j in range(i+1,n):
        a_sm+=a_[j]
        a.append(a_sm)

a.sort()
#print(a)
ans = 0
for j in range(41,-1,-1):##10**9を1000個足すので30では足りない
    x = 1<<j
    t = bisect.bisect_left(a,x)
    if t<=len(a)-k:###
        ans+=x
        a = a[t:]
        """
        for i in range(len(a)):
            a[i]&=(x-1)
        print(a)
        """
    for i in range(len(a)):
        a[i]&=(x-1)
        
    a.sort()
print(ans)
   


Measured memory_bytes: 66496
from heapq import heappop, heappush
 
N, K = map(int, input().split())
td = sorted([list(map(int, input().split()))
             for _ in range(N)], key=lambda x: x[1], reverse=True)

q = []
v = set()
count = 0
for t, d in td[:K]:
    count += d
    if t in v:
        heappush(q, d)
    else:
        v.add(t)
count += len(v) ** 2
ans = count
for t, d in td[K:]:
    if t not in v and len(q) != 0:
        x = heappop(q)
        count += d + 2 * len(v) + 1 - x
        v.add(t)
        ans = max(ans, count)
        
print(ans)

Measured memory_bytes: 30848
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

char A[105][105],B[105][105];

int N,M;
bool check(int sy,int sx)
{
	for(int i=0;i<M;i++)
		for(int j=0;j<M;j++)
			if(A[sy+i][sx+j]!=B[i][j])
				return false;
	return true;
}

int main()
{
	scanf("%d%d\n",&N,&M);
	for(int i=0;i<N;i++)
		scanf("%s",A[i]);
	for(int i=0;i<M;i++)
		scanf("%s",B[i]);
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(check(i,j))
			{
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    int d[N]{};
    vector<int> l;
    vector<int> v;
    int u = 0;

    while (d[u] < 2) {
        v.push_back(u + 1);
        d[u]++;
        if (d[u] >= 2) {
            l.push_back(u + 1);
        }
        u = A[u];
    }
    if (K < v.size()) {
        cout << v[K] << "\n";
    } else {
        cout << l[(K - v.size()) % l.size()]<< "\n";
    }
    return 0;
}

Measured memory_bytes: 7872
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=MAXN-1;

int n;
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM];

int dfs(int at,int par) {
	int ret=0;
	for(int x=ghead[at];x!=-1;x=gnxt[x]) {
		int to=gto[x]; if(to==par) continue;
		ret^=1+dfs(to,at);
	}
	return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,n) ghead[i]=-1;
	REP(i,n-1) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		gnxt[2*i+0]=ghead[a],ghead[a]=2*i+0,gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b],ghead[b]=2*i+1,gto[2*i+1]=a;
	}

	int res=dfs(0,-1);
	printf("%s\n",res!=0?"Alice":"Bob");
}

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


Measured memory_bytes: 6912
#include <stdio.h>

int main(void)
{
    int n;
    int d;
    int num;

    scanf("%d %d", &n, &d);

    num = 1;

    while(n / ((d * 2 + 1) * num) != 0){
        if(n / ((d * 2 + 1) * num) == 1 && n % ((d * 2 + 1) * num) == 0){
            break;
        }
        num++;
    }

    printf("%d\n", num);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main(void){
  int n, i, j, e, sum;
  /**/
  int u,v;
  int M[MAX][MAX],d[MAX],k[MAX],p[MAX];  //k:key
  /**/
  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  /**/
  for(i=0;i<n;i++){
    p[i]=-1;
    k[i]=INFTY;
        d[i]=0;
  }
  k[0]=0;
  while(1){
    u=-1;
    v=INFTY;
    
        for(i=0;i<n;i++){
	  if(v>k[i] && (d[i]==0)){
	    u=i;
	    v=k[i];
	  }
        }
	
        if(u==-1)break;
        d[u]=1;
	
        for(i=0;i<n;i++){
	  if(k[i]>=M[u][i] && (d[i]==0)){
	    p[i]=u;
	    k[i]=M[u][i];
	  }
        }
  }
  /**/
  sum = 0;
  
  for (i=0;i<n;i++){
    if (p[i]!=-1) {
      sum+=M[i][p[i]];
    }
  }
  
  printf("%d\n", sum);
  
  return 0;
}

Measured memory_bytes: 804
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b = il()
    print((b-a)*(b-a+1)//2 - b)


if __name__ == '__main__':
    main()


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

public static class Program {
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        long[]a=Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[,]sum=new long[n+1,n+1];
        for(int i=0;i<n;i++){
            sum[i,i+1]=a[i];
            for(int j=i+2;j<=n;j++){
                sum[i,j]=sum[i,j-1]+a[j-1];
            }
        }
        long[,]dp=new long[n+1,n+1];
        for(int i=0;i<n;i++){
            dp[i,i+1]=0;
            for(int j=i+2;j<=n;j++){
                dp[i,j]=long.MaxValue;
            }
        }
        for(int len=2;len<=n;len++){
            for(int l=0;l+len<=n;l++){
                int r=l+len;
                for(int i=l+1;i<=r-1;i++){
                    Chmin(ref dp[l,r], dp[l,i]+dp[i,r]);
                }
                dp[l,r]+=sum[l,r];
            }
        }
        Console.WriteLine(dp[0,n]);
    }
    public static void Chmin(ref long x, long y){
        x=Math.Min(x,y);
    }
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
ll a,b;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b;
    cout<<lcm(a,b)<<newl;
}


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

int main() {
  long long K, A, B;
  cin >> K >> A >> B;

  if (B - A <= 2 || K < A - 1) {
    cout << K + 1 << endl;
    return 0;
  } else {
    long long ans = A;
    long long cnt = K - A + 1;
    if (cnt % 2 == 1) ans++, cnt--;
    ans += (cnt / 2) * (B - A);
    cout << ans << endl;
  }
}


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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int ans;
	cin >> ans;
	for (int i = 0; i < n-1; i++)
	{
		int k;
		cin >> k;
		ans = __gcd(ans, k);
	}

	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    for (const char c : s)
    {
        if (c == ',')
        {
            std::cout << ' ';
        }
        else
        {
            std::cout << c;
        }
    }
    std::cout << std::endl;

    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);
typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

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

int main()
{
    ll n;
    cin >> n;
    if(n == 1){
        cout << "Yes" << endl;
        return 0;
    }

    bool ans = false;
    REP(i,1,n){
        if(n % i == 0 && i < 10 && n / i < 10)ans = true;
    }

    cout << ((ans)?"Yes" : "No") << endl;
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

struct Segment {
  Point p1, p2;
};

typedef Point Vector;

// 内積
double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
};

// 外積
double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
};

// 直交判定
bool isOrthogonal(Vector a, Vector b) {
  return equals(dot(a, b), 0.0);
};

// 並行判定
bool isParallel(Vector a, Vector b) {
  return equals(cross(a, b), 0.0);
};

// 射影
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
};

int main() {
  int sx1, sy1, sx2, sy2;
  int q;
  cin >> sx1 >> sy1 >> sx2 >> sy2 >> q;
  int x0, y0;
  Segment seg = { Point(sx1, sy1), Point(sx2, sy2) };
  Point p;
  rep(i, 0, q) {
    cin >> x0 >> y0;
    p = Point(x0, y0);
    Point ansp = project(seg, p);
    printf("%.10f %.10f\n", ansp.x, ansp.y);
  }
};



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

using namespace std;

int main(){
	char str[21];
	int count=0;
	
	scanf("%s", str);
	
	while( str[count] != '\0' ) ++count;
	
	for(int i=count-1; i>=0; --i)
		printf("%c", str[i]); 
	printf("\n");

	return 0;
}

Measured memory_bytes: 1096
n,x=map(int,input().split())
X=[int(i) for i in input().split()]

def f(m,n):
  if min(m,n)<0:
    return f(abs(m),abs(n))
  elif m<n:
    return f(n,m)
  elif m%n==0:
    return n
  else:
    return f(n,m%n)
ans=abs(X[0]-x)
for i in range(1,n):
  ans=f(ans,X[i]-x)
print(ans)

Measured memory_bytes: 14252
n,m=map(int,input().split())
lrd=[]
es=[[] for i in range(n)]
for i in range(m):
    l,r,d=map(int,input().split())
    lrd.append((l-1,r-1,d))
    es[l-1].append((d,r-1))
    es[r-1].append((-d,l-1))

from collections import deque
que=deque([])
dist=[float('inf')]*n

for i in range(n):
    if dist[i]==float('inf'):
        dist[i]=int(0)
        que.append(i)
        while que:
            p=que.popleft()
            for d, j in es[p]:
                if dist[j]==float('inf'):
                    dist[j]=int(dist[p]+d)
                    que.append(j)

for l,r,d in lrd:
    if dist[l]-dist[r]!=-d:
        print('No')
        exit()
print('Yes')


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

#define gc getchar()
inline int read(){
	int x=0;int f=0;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return f?-x:x;
}
#define io read()

#define maxn 200005
int h,w,n;
struct pt{
	int x,y;
	inline friend bool operator<(pt a,pt b){
		return a.x<b.x||a.x==b.x&&a.y<b.y;
	}
}a[maxn];
map<pt,int> mp;

inline void init(){
	h=io;w=io;n=io;
	for(int i=1;i<=n;++i){
		a[i].x=io;
		a[i].y=io;
		mp[a[i]]=1;
	}
	sort(a+1,a+n+1);
}

int rt[maxn];
inline void solve(){
	pt p={1,1};int cur=0;
	while(1){
		if(!cur){
			rt[p.x]=p.y;
			++p.x;
			if(p.x>h||mp.count(p))break;
		}else{
			++p.y;
			if(p.y>w||mp.count(p))--p.y;
		}
		cur=!cur;
	}
	
	int ans=h;
	for(int i=1;i<=n;++i){
		pt p=a[i];--p.x;
		if(p.y>rt[p.x])continue;
		ans=min(ans,p.x);
	}
	printf("%d\n",ans);
}

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

Measured memory_bytes: 15104
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    cin >> N;
    int A[N+10];
    int B[N+10];
    
    for( int ni = 1 ; ni <=N ; ni++ ){
        cin >> A[ni];
    }
    A[N+1]=0;
    B[N+1]=0;

    int sum;
    int cnt;
    int M=0;
    for( int ni = N ; ni >=1 ; ni-- ){
        sum = 0;
        cnt = 2;
        while(cnt * ni <= N){
            sum += B[cnt * ni];
            cnt++;
        }
        B[ni] = ( sum + A[ni] ) % 2;
        M+=B[ni];
    }
    cout << M << endl;
    for( int ni = 1 ; ni <=N ; ni++ ){
        if(B[ni]==1) cout << ni << endl;;
    }



}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;

int main(){
 int A,B,M;
 cin >> A >> B >> M;
 int priceA[A],priceB[B];
 int minA = 100001;
 int minB = 100001;
 for (int i =0 ; i< A; i++){
   cin >> priceA[i];
   minA=min(minA,priceA[i]);
 }
 for (int i =0 ; i< B; i++){
   cin >> priceB[i];
   minB=min(minB,priceB[i]);
 }
 int ans=minA+minB; //割引を使用しない場合の最小値

 int x,y,c;
 for (int i=0;i < M;i++){
   cin >> x >> y >> c;
   ans=min(ans,priceA[x-1]+priceB[y-1]-c);
 }
 cout << ans;
return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

typedef pair<int, int> P;

// const int INF = 1001001001;
// long long max => LLONG_MAX

vector<int> graph[100005];
map<P, int> color;
int k;

void dfs(int _v, int _pr, int _c){
    int cl = 1;
    for(int nv : graph[_v]){
        if(nv == _pr) continue;
        if(cl == _c) cl++;
        color[make_pair(nv, _v)] = cl;
        color[make_pair(_v, nv)] = cl;
        dfs(nv, _v, cl);
        cl++;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<P> tor(n-1);
    vector<int> p(n);

    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        tor[i].first = a;
        tor[i].second = b;
        p[a]++;
        p[b]++;
    }
    sort(p.rbegin(), p.rend());
    k = p[0];

    dfs(0, -1, -1);

    cout << k << endl;
    for(int i = 0; i < n-1; i++){
        int a = tor[i].first;
        int b = tor[i].second;
        cout << color[make_pair(a,b)] << endl;
    }

    return 0;
}


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

int main(){
    const int N=1e7;
    vector<bool> is_prime(N+1, 1);
    for (int p = 2; p <= N; p++) {
        if (!is_prime[p]) continue;
        for (int k = 2*p; k <= N; k += p) is_prime[k] = false;
    }

    vector<int> dp(N+1, -1);
    for(int i=13; i<=N; i++){
        if(is_prime[i] && is_prime[i-2] && is_prime[i-6] && is_prime[i-8]){
            dp[i]=i;
        }else{
            dp[i]=dp[i-1];
        }
    }
    while(1){
        int n; cin >> n;
        if(n==0) break;
        cout << dp[n] << endl;
    }
}


Measured memory_bytes: 43040
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
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 N=1e5, M = 1e5;
ll dp[100000][3];
ll a[100000][3];
const ll INF = 1LL << 60;


int main() {
	ll S, W;
	cin >> S >> W;

	bool can = true;

	if (W >= S) can = false;

	if (can) cout << "safe" << endl;
	else cout << "unsafe" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mx 1000000
using namespace std;

int main() {
  ios
  int t = 1;
  // cin>>t;
  while(t--) {
    int x,y;
    cin>>x>>y;
    int a = y-(x<<1);
    int b = (x<<2)-y;
    if(a==0 && b==0) {
      cout<<"No";
      return 0;
    }
    if(a >= 0 && b >= 0) {
      if(!(a&1) && !(b&1)) {
        cout<<"Yes";
        return 0;
      }
    }
    cout<<"No";
    cout<<'\n';
  }
  return 0;
}

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

int gcd(int a, int b)
{
    return b ? gcd(b, a%b) : a;
}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> lgcd(n, 0), rgcd(n, 0);
    for (int i = 1; i < n; i++) {
        lgcd[i] = gcd(lgcd[i-1], a[i-1]);
        rgcd[n-i-1] = gcd(rgcd[n-i], a[n-i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, gcd(lgcd[i], rgcd[i]));
    }

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

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

int main() {
    ll a,b,c,d;
    cin >>a>>b>>c>>d;
    bool judge=true;
    while(judge){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632