akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int result[1000010] = {};
	int odd_result[1000010] = {};
	fill(result, result + 1000000, 1000000);
	fill(odd_result, odd_result + 1000000, 1000000);
	int trangular_sum = 0, tetrahedral_sum = 0;
	result[0] = 0;
	odd_result[0] = 0;
	for(int i = 1; i < 1000001; i++){
		trangular_sum += i;
		tetrahedral_sum += trangular_sum;
		if(tetrahedral_sum > 1000000) break;
		// result[trangular_sum] = 1;
		result[tetrahedral_sum] = 1;
		if(tetrahedral_sum % 2 == 1) odd_result[tetrahedral_sum] = 1;
		for(int j = tetrahedral_sum + 1; j < 1000001; j++){
			result[j] = min(result[j], result[j - tetrahedral_sum] + 1);
			if(tetrahedral_sum % 2 == 1) odd_result[j] = min(odd_result[j], odd_result[j - tetrahedral_sum] + 1);
		}
	}
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		cout << result[n] << " " << odd_result[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8980
#include <iostream>
using namespace std;
int main(void) {
    int n, m;
    cin >> n >> m;
    
    int left = 0, right = 1000001;

    int l, r;
    for(int i = 0; i < m; i++) {
        cin >> l >> r;
        if(left < l) {
            left = l;
        }
        if(r < right) {
            right = r;
        }
    }

    int ans = right - left + 1;
    if(ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;

int digits(ll n){
  int d=0;
  for(ll n_=n;n_>0LL;n_/=10LL) d++;
  return d;
}

int main(){ _;
  ll n;cin>>n;
  ll m=1;
  for(ll p=2;;p++){
    if(p*p>n)break;
    if(n%p==0){
      m=p;
    }
  }
  cout<<max(digits(m),digits(n/m))<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<climits>
using namespace std;
int main()
{
    int n, m, a[50], b[50], c[50], d[50];
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int j = 0; j < m; j++){
        cin >> c[j] >> d[j];
    }
    for(int i = 0; i < n; i++){
        int mindis = INT_MAX;
        int ans;
        for(int j = 0; j < m; j++){
            int jdis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(jdis < mindis){
                mindis = jdis;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll N, T;
	cin >> N >> T;
	vll t(N);
	rep(i, N) cin >> t[i];
	ll ans = 0;
	fori(i, 1, N) {
		ans += min(T, t[i] - t[i - 1]);
	}
	cout << ans + T << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    rep(i, 0, N) rep(j, 0, 2) {
        cin >> D[i][j];
    }
    rep(i, 0, N - 2) {
        bool is_ok = true;
        rep(j, 0, 3) {
            is_ok &= (D[i + j][0] == D[i + j][1]);
        }
        if (is_ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    # print(ans)
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = (j - i) + j
            if k >= n:
                # print(i, j, k)
                break

            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
import java.io.*;
import java.util.*;

// Solution class
class Solution {
    public Solution() { }
    private static final InputReader scan = new InputReader();
    // solve method
    public void solve() throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        // code goes here...
        int a = scan.nextInt();
        int b = scan.nextInt();

        int area = a * b;
        int perimeter = 2 * (a + b);
        out.println(area + " " + perimeter);

        out.close();
    }
}

// InputReader class
class InputReader {
    private final BufferedReader br;
    private StringTokenizer st = new StringTokenizer("");
    public InputReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    public String next() throws IOException {
        while (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ie) { ie.printStackTrace(); }
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException ie) { ie.printStackTrace(); }
        return str;
    }
    public int nextInt() throws IOException { return Integer.parseInt(next()); }
    public long nextLong() throws IOException { return Long.parseLong(next()); }
    public double nextDouble() throws IOException { return Double.parseDouble(next()); }
}

// Main class
public class Main {
    public Main() { }
    // driver method
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}



Measured memory_bytes: 24264
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2005;
struct node{
    int u,v,nxt;
}edge[N*2];
int head[N],mcnt;
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
int n,k;
int du[N];
int deep[N];
void dfs(int u,int fa,int d){
    deep[u]=d;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa)
            continue;
        dfs(v,u,d+1);
    }
}
int main()
{
    //freopen("shorten.in","r",stdin);
    //freopen("shorten.out","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
        du[u]++;
        du[v]++;
    }
    int ans=n;
    if(k&1)
        for(int u=1;u<=n;u++)
            for(int i=head[u];i;i=edge[i].nxt){
                int v=edge[i].v;
                if(v<u)
                    continue ;
                dfs(u,v,0);
                dfs(v,u,0);
                int cnt=0;
                for(int j=1;j<=n;j++)
                    if(deep[j]>k/2)
                        cnt++;
                ans=min(ans,cnt);
            }
    else
        for(int u=1;u<=n;u++){
            dfs(u,0,0);
            int cnt=0;
            for(int j=1;j<=n;j++)
                if(deep[j]>k/2)
                    cnt++;
            ans=min(ans,cnt);
        }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
import itertools
import copy

h,w,k = map(int,input().split())
c = [list(input()) for _ in range(h)]

A = [0,1]
h1 = list(itertools.product(A, repeat=h))
w1 = list(itertools.product(A, repeat=w))

ans = 0

for i in h1:
    for j in w1:
        c1 = copy.deepcopy(c)
        for ii in range(h):
            if i[ii]:
                for jjj in range(w):
                    c1[ii][jjj] = '.'
        for jj in range(w):
            if j[jj]:
                for iii in range(h):
                    c1[iii][jj] = '.'

        tmp = 0
        for ii in range(h):
            for jj in range(w):
                if c1[ii][jj] == '#':
                    tmp += 1
        if tmp == k:
            ans += 1

print(ans)


Measured memory_bytes: 72500
from collections import deque
from collections import defaultdict
import math
t = int(input())
def solve(n):
    if dist[n] != float('inf'):
        return dist[n]
    if n == 0:
        return 0
    if n == 1:
        return d
    ans = float('inf')
    for x,cost in ([5,c],[3,b],[2,a]):
        e = 0
        if n%x:
            e = 1 
        y = n%x
        ans = min(ans,solve(n//x) + cost + (e*d*y))

        if e ==1:
            ans = min(ans,solve(n//x+1) + cost + ((x-y)*d))
    dist[n] = min(ans,n*d)   
    return dist[n]

for i in range(t):
    n,a,b,c,d, = list(map(int,input().split()))
    dist = defaultdict(lambda: float('inf'))
    print(solve(n))


Measured memory_bytes: 11340
use std::io::*;

fn main(){
    let n : usize = input();
    let l : isize = input();
    let mut a : Vec<isize> = Vec::new();
    for i in 0..n{
        a.push(l + i as isize);
    }
    let ans = a.iter().fold(0, |sum, x| sum + x) - a.iter().min_by_key(|b| b.abs()).unwrap();
    println!("{}", ans);
}
fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
using namespace std;



int main(){
    int N; cin>> N;
    vector<int> V(N);
    for (int i = 0;i < N;i++){
        cin >> V[i];
    }
    sort(V.begin(),V.end());
    
    double ans = 0.0;
    ans += (double)V[0];
    for (int i = 1; i <N;i++){
        ans += (double)V[i];
        ans = (double) ans/2;
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <cmath>

using namespace std;

#define ll long long
const int maxn = 1e5 + 100;
const int mod = 998244353;

struct point{
    int x,y;
}e[maxn];

ll ans=0;

ll pow_mod(ll a,ll b){
    ll ret = 1;
    while (b){
        if(b&1) ret = ret*a%mod;
        a = a*a%mod;
        b >>=1;
    }
    return ret;
}

bool check(point a,point b,point c){
    a.x-=c.x,a.y-=c.y;
    b.x-=c.x,b.y-=c.y;
    if(a.x*b.y-a.y*b.x==0)
        return 1;
    return 0;
}

int main() {
   // freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>e[i].x>>e[i].y;
    }
    ans = pow_mod(2,n)-n-1;
    //cout<<pow_mod(2,n)<<endl;
    //cout<<ans<<endl;
   // cout<<ans<<endl;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int d=0;
            for (int k = j+1; k < n; ++k) {
                if(check(e[i],e[j],e[k]))
                    d++;
            }
            ans = (ans -pow_mod(2,d)+mod)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
ll P[101010];
char S[101010][10];
ll mk[101010];
ll i, j,acpt,pena;
int main(){
    scanf("%lld%lld", &N, &M);
    fornum(i,0,M){
        scanf("%lld%s", &P[i], S[i]);
        if(mk[P[i]]>=0){
            if(S[i][0]=='A'){
                pena += mk[P[i]];
                mk[P[i]] = -1;
                ++acpt;
            }else{
                ++mk[P[i]];
            }
        }
    }
    printf("%lld %lld", acpt, pena);

    return 0;
}

Measured memory_bytes: 2816
/****************************************
  "Temp not a desperate man."
                    -William Shakespeare
 ****************************************/

/*****************************
 PRASANNA_K_ROY (prasanna2425)
 *****************************/

#include <bits/stdc++.h>
using namespace std;

#define __AcHiLlEs ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define __AnAkLuSmOs freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define accio cin
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define i_64 long long
#define d_64 long double
#define u_64 unsigned long long

int solve() {
    i_64 n, x, res(0);
    cin >> n;
    std::map<i_64, i_64> m;
    i_64 a[n];
    for (i_64 &i: a) {
        cin >> i;
        m[i]++;
    }
    for (auto i : m) {
        if (i.second <= 1) {
            continue;
        }
        res += (i.second * (i.second - 1)) / 2;
    }
    for (i_64 &i: a) {
        cout << res - m[i] + 1 << "\n";
    }
	return 0;
}

int main() {
    /*auto start=std::chrono::steady_clock::now();
    #ifndef ONLINE_JUDGE
        __AnAkLuSmOs
    #endif*/

    __AcHiLlEs
    
    int t(1);
    //accio >> t;
    while (t--) {
        solve();
    }
    
    /*auto end = std::chrono::steady_clock::now();
        double elapsed=double (std::chrono::duration_cast < std::chrono::nanoseconds> (end-start).count());
    std::cout << endl << "Terminated\n"<< elapsed/1e9;*/
    return 0;
}

Measured memory_bytes: 11136
#include"bits/stdc++.h"
using namespace std;
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  int k; cin>>k; int ld=k%10; 
  if(k==1){ cout<<1<<"\n"; return 0; }
  if(ld%2==0){ cout<<-1<<"\n"; return 0; }
  int res=7;  if(res%k==0){ cout<<1<<"\n"; return 0;}
  for(int i=2;i<=100000000;i++)
  { 
   res=(10*res+7)%k; if(res==0){ cout<<i<<"\n"; return 0; }  
  }
  cout<<-1<<"\n"; return 0; 
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define pb push_back
#define int long long
#define pi pair<int , int>
#define mp make_pair
vector<int> edges[N];
bool visited[N];
bool arr[N];
int dp[N];
int parent[N];
int find(int x){
 if(parent[x] == -1){
 return x;
 }
 return find(parent[x]);
}
int n ,m;
void dfs(int st , int par){
	visited[st] = true;
	int ans = 0;
  int f = 0;
  for(auto it:edges[st]){
    f= 1;
      if(!visited[it]){
	    dfs(it , st);
	    }
	    ans = max(ans , dp[it]);
	}
   dp[st] = max(dp[st] , ans+f);
}
int32_t main(){
	cin>>n>>m;
	for(int i = 0 ; i < m;i++){
	   int x , y;
	   cin>>x>>y;
	   edges[--x].pb(--y);
	}
	memset(dp , 0 , sizeof(dp));
	memset(visited , false , sizeof(visited));
	for(int i = 0 ;i < n ;i++){
	   if(!visited[i]){
	     dfs(i , i);
	   }
	}
	int maxi = -1;
	for(int i =0; i < n; i++){
	    maxi = max(maxi , dp[i]);
	}
	cout<<maxi<<endl;
	
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u) a--;
  else b--;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
struct edge{
	int to, next;
}e[200005];
int head[100005], tot, n, k, x, y, mod = 1000000007;
ll ans;
void add(int u, int v)
{
	e[tot].to = v, e[tot].next = head[u],  head[u] = tot++;
}
void dfs(int x, int fa, int dep)
{
	int num = 0;
	for (int u = head[x]; ~u; u = e[u].next)
	{
		int v = e[u].to;
		if (v == fa)	continue;
		dfs(v, x, dep + 1);
		
		if (dep == 0)
		{
			ans = ans * (k - num - 1) % mod;
			if (k - num - 1 <= 0)	ans = 0;
		}
		else
		{
			ans = ans * (k - num - 2) % mod;
			if (k - num - 2 <= 0)	ans = 0;
		}	
		num++;
	}
}
signed main(){
	while (~scanf("%d%d", &n, &k))
	{
		ans = k;
		memset(head, -1, sizeof(head));
		for (int i = 0; i < n - 1; i++)
		{
			scanf("%d%d", &x, &y);
			add(x, y), add(y, x);
		}
		dfs(1, -1, 0);
		printf("%lld\n", ans);
	}
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

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


Measured memory_bytes: 640
import heapq

def dijkstra(s):  #スタート
    hq = [(0, s)]  #(距離,地点)
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


n,x,y=map(int,input().split())
e=[[] for i in range(n)]
for i in range(1,n):
  a,b=i,i+1
  e[a-1].append((1,b-1))
  e[b-1].append((1,a-1))

e[x-1].append((1,y-1))
e[y-1].append((1,x-1))

ans=[0]*(n-1)

for i in range(n):
  xxx=dijkstra(i)
  for j in xxx:
    ans[j-1]+=1

ans[-1]=0

for i in ans:
  print(i//2)

Measured memory_bytes: 81532
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b){return *(int*)a-*(int*)b;}
int n, m, i, f;
int *d, *t;

int main(void){
	scanf("%d", &n);
	d = calloc(n, sizeof(int));
	for(i=0; i<n; i++){
		scanf("%d", d+i);
	}
	scanf("%d", &m);
	t = calloc(m, sizeof(int));
	for(i=0; i<m; i++){
		scanf("%d", t+i);
	}
	qsort(d, n, sizeof(int), compare_int);
	qsort(t, m, sizeof(int), compare_int);
	f=0;
	for(i=0; i<m; i++){
		while(d[f]<t[i]){f++;}
		if(d[f]==t[i]){
			f++;
		}else{
			goto bad;
		}
	}
	puts("YES");
	return 0;
	bad:
	puts("NO");
}


Measured memory_bytes: 2556
N = gets.to_i
D = readlines.map {|s| s.split.map(&:to_i) }

cnt = 0
D.each do |a,b|
  if a == b
    cnt += 1
  else
    cnt = 0
  end
  break if cnt == 3
end
puts cnt < 3 ? "No" : "Yes"

Measured memory_bytes: 14348
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int main()
{
	ll fact[500001],ifact[500001],inv[500001];
	fact[0]=1,ifact[0]=1,inv[0]=1;
    ll m=1e9+7;
	inv[1] = 1;
for(int i = 2; i < 500001; ++i)
    inv[i] = (m - (m/i) * inv[m%i] % m) % m;
    
    for(ll i=1;i<500001;i++)
    {
    	fact[i]=(i*fact[i-1])%m;
    	ifact[i]=(inv[i]*ifact[i-1])%m;
	}
	ll n,mi;
	cin>>n>>mi;
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		ll temp=1;
		temp=(temp*fact[mi-i])%m;
		temp=(temp*ifact[mi-n])%m;
		temp=(temp*temp)%m;
		temp=(temp*fact[i])%m;
		temp=(temp*fact[mi])%m;
		temp=(temp*fact[n])%m;
		temp=(temp*ifact[i])%m;
		temp=(temp*ifact[i])%m;
		temp=(temp*ifact[mi-i])%m;
		temp=(temp*ifact[n-i])%m;
    //  cout<<temp<<"\n";
		if(i%2==0)
		ans=(ans+temp)%m;
		else
		ans=(ans+m-temp)%m;		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15348
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  unsigned long long int n,k,cycleLength=0,startPos=1,offset=1,offsetLength=0,currPos;
  cin>>n>>k;
  vector<unsigned long long int> towns(n+1);
  for(unsigned long long int i = 1;i<n+1;i++){
    cin>>towns[i];
  }
  //threr must be cylce
  if(k>n){
    vector<bool> visited(n+1);
    while(!visited[towns[startPos]]){;
      visited[towns[startPos]]=true;
      startPos=towns[startPos];
    }
    while(towns[offset]!=startPos){
      offset=towns[offset];
      offsetLength++;
    }
    offsetLength++;
    currPos=startPos;
    while(towns[currPos]!=startPos){
      currPos=towns[currPos];
      cycleLength++;
    }
    cycleLength++;
    k-=offsetLength;
    k%=cycleLength;  
  }
  while(k-->0){
    startPos=towns[startPos];
  } 
  cout<<startPos<<"\n";   
  return 0; 
}

Measured memory_bytes: 4784
///Water Hyacinth
///Hakuna Matata
///WAKE THE FUCK UP SAMURAI;WE HAVE A CODE TO RUN <3
///Any Verdict
///(Aes)  Dekhe (Tic) lagche = Aesthetic <3
///**********************************************************///

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define De double

int main()
{
    int a,b ,c;
    cin >> a >> b >>c;
    if(b+c>a)
        cout << ((b+c)-a) << endl;
    else
        cout << "0" << endl;

    return 0;
}

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

using namespace std;

int main(){
    long long sum = 0;
    string s;
    cin >> s;
    int l = s.size();
    for(int i=1;i<=l;i++){
        for(int j=0;j<=l-i;j++){
            long long ll = atoll(s.substr(j,i).c_str());
            int L = j;
            int R = l - i - j;
            if(L>0) L--;
            if(R>0) R--;
            long long lll = (long long)(1<<L) * (long long)(1<<R);
            sum += ll * lll;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,s,cou=0;
cin>>k>>s;
//if(3*k==s)cout<<"1"<<endl;
//else{

  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
    if(s-i-j>=0&&s-i-j<=k)cou++;
  	}
  }
	cout<<cou<<endl;
//}
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for _ in range(n):
    tmp = input()
    if tmp[0] in ["M", "A", "R", "C", "H"]:
        d[tmp[0]] += 1

li = list(combinations(d.keys(), 3))

ans = 0
for a, b, c in li:
    ans += d[a] * d[b] * d[c]

print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int height = sc.nextInt();
		int width = sc.nextInt();
		
		char[][] board = new char[height][width];
		
		for (int i = 0; i < height; i++) {
			String sCurr = sc.next();
			for (int j = 0; j < width; j++) {
				board[i][j] = sCurr.charAt(j);
			}
		}
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (!(board[i][j] == '#')) {
					boolean iLess = false;
					boolean iMore = false;
					boolean jLess = false;
					boolean jMore = false;
					int tempVal = 0;
					if (i - 1 >= 0) {
						iLess = true;
					} 
					if (i + 1 < board.length) {
						iMore = true;
					}
					if (j - 1 >= 0) {
						jLess = true;
					}
					if (j + 1 < board[0].length) {
						jMore = true;
					}
					if (iLess) {
						if (board[i - 1][j] == '#') {
							tempVal++;
						}
					}
					if (iMore) {
						if (board[i + 1][j] == '#') {
							tempVal++;
						}
					}
					if (jLess) {
						if (board[i][j - 1] == '#') {
							tempVal++;
						}
					}
					if (jMore) {
						if (board[i][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jLess) {
						if (board[i - 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jMore) {
						if (board[i - 1][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jLess) {
						if (board[i + 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jMore) {
						if (board[i + 1][j + 1] == '#') {
							tempVal++;
						}
					}
					board[i][j] = Integer.toString(tempVal).charAt(0);
				}
			}
		}
		for (int i = 0; i < height; i++) {
			String printString = "";
			for (int j = 0; j < width; j++) {
				printString += board[i][j];
			}
			System.out.println(printString);
		}
	}

}


Measured memory_bytes: 23892
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll bit[500005];

void add(int i, ll x) {
  while(i<500005) {
    bit[i] += x;
    i += i&-i;
  }
}

ll get(int i) {
  ll ans = 0;
  while(i>0) {
    ans += bit[i];
    i -= i&-i;
  }
  return ans;
}

int main() {
  int N, Q;
  cin>>N>>Q;
  ll tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    add(i+1, tmp);
  }
  int t, x1, x2;
  vector<ll> ans;
  for(int i=0;i<Q;++i) {
    cin>>t>>x1>>x2;
    if(t==0) {
      add(x1+1, x2);
    }
    else {
      ans.push_back(get(x2)-get(x1));
    }
  }
  for(int i=0;i<ans.size();++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 10256
#include <stdio.h>

int main(void){
  int price,sum=0,n,i,max=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&price);
    sum += price;
    if(max < price){
      max = price;
    }
  }

  max /= 2;
  printf("%d\n",sum-max);
  return 0;
}


Measured memory_bytes: 128
n, m, c=map(int, input().split())
b=list(map(int, input().split()))
ac=0
for _ in range(n):
  ans=c
  a=list(map(int, input().split()))
  for i in range(m):
    ans+=a[i]*b[i]
  if ans>0:
    ac += 1
print(ac)

Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>
int main(void)
{
    int N,K,i;
    char S[50];
  
    scanf("%d%d",&N,&K);
    scanf("%s",S);
  
    S[K-1]=tolower(S[K-1]);
  
    for(i=0;i<N;i++)
      printf("%c",S[i]);
        printf("\n");
  
    return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int p[100010];
int main(){
    int N;
    cin >> N;
    int inp;
    REP(i,N){
        cin >> inp;
        p[i] = inp-1;
    }

    int num = 0;
    REP(i,N){
        if(p[i] == i){
            num++;
            if(i+1 < N && p[i+1] == i+1){
               i++; 
            }
        }
    }
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,l;
int a[100100];
int main(){
	cin>>n>>l;
	FOR(i,1,n+1)cin>>a[i];
	int t=-1;
	FOR(i,1,n){
		if(a[i]+a[i+1]>=l){
			t=i;
			break;
		}
	}
	if(t==-1){
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;
	for(int i=n-1;i>t;i--){
		cout<<i<<endl;
	}
	for(int i=1;i<t;i++){
		cout<<i<<endl;
	}
	cout<<t<<endl;
	return 0;
}


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

int main() {
  int n,k,cnt=1;
  cin >> n >> k;
  int t=k;
  for(int i=1;i<100;i++){
    if(n - t >=0){
      t *=k;
      cnt++;
    }
    else break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

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

signed main() {
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    rep(i, n) cin >> a[i + 1];
    vector<int> sum(n + 1, 0);
    set<int> s;
    for (int i = n; i; i--) {
        if (a[i] == sum[i] % 2)
            continue;
        else {
            s.insert(i);
            auto v = divisor(i);
            for (auto j : v)
                sum[j]++;
        }
    }
    cout << s.size() << endl;
    for (auto i = s.begin(); i != s.end(); i++)
        cout << *i << endl;
    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string s;
    cin >> s;

    int ans = 0;
    if (s == "SUN") ans = 7;
    else if (s == "MON") ans = 6;
    else if (s == "TUE") ans = 5;
    else if (s == "WED") ans = 4;
    else if (s == "THU") ans = 3;
    else if (s == "FRI") ans = 2;
    else if (s == "SAT") ans = 1;

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import math
k = int(input())
#gcd_ls = []
sub = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        mn = math.gcd(a, b)
        for c in range(1, k+1):
            sub+=math.gcd(mn, c)
print(sub)


Measured memory_bytes: 9168
import itertools
n=int(input())

a=[0]*n
b=[]
for i in range(1,101):
    b.append(i)
lst=list(itertools.product(b,repeat=3))

for i in range(len(lst)):
    x,y,z=lst[i][0],lst[i][1],lst[i][2]
    c=(x+y+z)**2-(x*y+y*z+z*x)
    if c<=n:
        a[c-1]+=1
    
for i in range(n):
    print(a[i])


Measured memory_bytes: 80588
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    S=[0]*N
    for _ in range(M):
        a,b=MI()
        a-=1
        b-=1
        if a==0 or b==0:
            S[a+b]+=1
        if a==N-1 or b==N-1:
            S[a+b-(N-1)]+=1
            
    f=0
    for i in range(N):
        if S[i]==2:
            f=1
            
    if f==1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
        

main()


Measured memory_bytes: 48216
#include <iostream>
using namespace std;
int main(){
	int x, y, z, temporariness;
	cin >> x >> y >> z;
	if (x > y){
		temporariness = x;
		x = y;
		y = temporariness;
	}
	if (y > z){
		temporariness = y;
		y = z;
		z = temporariness;
	}
	if (x > y){
		temporariness = x;
		x = y;
		y = temporariness;
	}
	cout << x << " " << y << " " << z << endl;
	return 0;
}

Measured memory_bytes: 1164
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll n, m;
	scanf("%lld%lld", &n, &m);
	vector<int> a(n + 1);
	ll b, ans = 0;
	map<ll, ll> mp;
	++mp[0];
	rep(i, n) {
		scanf("%lld", &b);
		a[i + 1] = a[i] + b;
		a[i + 1] %= m;
		ans += mp[a[i + 1]];
		++mp[a[i + 1]];
	}
	printf("%lld\n", ans);

	Please AC;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,w;
  cin>>n>>w;
  long long int arr[n][2];
  for(int idx = 0;idx<n;idx++){
    cin>>arr[idx][0]>>arr[idx][1];
  }
  long long int result[n+1][w+1];
 
  for(int val = 0;val<=n;val++){
    for(int W = 0;W<=w;W++){
    	if(val==0 || W==0)
    	{
    		result[val][W]=0;
    	}
     else if(W>=arr[val-1][0]){
        result[val][W]=max(result[val-1][W],arr[val-1][1]+result[val-1][W-arr[val-1][0]]);
        }
          else
               result[val][W]=result[val-1][W];
     }
   }
         
   cout<<result[n][w];
      return 0;
                                                                  }                                 
                                                                  
                                                                  
  


Measured memory_bytes: 79232
#include <stdio.h>

int main(void)
{
	int h,w,a,b;
	while(1){
	scanf("%d %d",&h,&w);
if(h==0)
if(w==0)
{	break;}
		
	for(a=0;a<h;a++){
	for(b=0;b<w;b++){
if((a+b)%2==1)
printf(".");
else printf("#");
}
	printf("\n");
	}
	printf("\n");
}
	return 0;
}
    

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <algorithm>
#define F first
#define S second
using namespace std;

int Q = 1e6, h1, h2, cut = 100;
int n, s, D, l, r, up, mx, a[30], b[400][30], la[400], u[400], ans[400];
pair<int, int> c[400][30];
bool v[400][26];

int f(int p, int q1, int q2) {
	int sz = q2 - q1 + 1;
	return p * sz * (sz + 1) / 2;
}

int main()
{
	int i, j, t, x, t1, t2;
	srand(time(NULL));
	cin >> D;
	for (i = 0; i < 26; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 1; i <= D; i++) {
		for (j = 0; j < 26; j++) {
			scanf ("%d", &b[i][j]);
			c[i][j].F = b[i][j];
			c[i][j].S = j;
		}
		sort(c[i], c[i] + 26);
		ans[i] = u[i] = c[i][25].S;
	}
//	for(i = 1; i <= D; i++) {
//		printf("%d\n", ans[i]);
//	}
	for (i = 1; i <= D; i++){
//		scanf ("%d", &t);
		t = u[i] - 1;
		s += b[i][t];
		la[t] = i;
		for (j = 0; j < 26;j++) {
			s -= a[j] * (i - la[j]);
		}
		v[i][t] = 1;
	}
//	cout << s << endl;
//	cin >> Q;
	for (i =0; i < 26; i++) {
		v[0][i] = 1;
		v[D + 1][i] = 1;
	}
	mx = s;
	while (Q--) {
//		scanf ("%d %d", &t1, &t2);
		t1 = rand() % D + 1;
		t2 = rand() % 26;
		if (u[t1] == t2) t2 = (t2 + 1) % 26;
		x = u[t1];
		s -= b[t1][x];
		v[t1][x] = 0;
		v[t1][t2] = 1;
		u[t1] = t2;
		s += b[t1][t2];
		for (l = t1 - 1; l >= 0; l--) if (v[l][x]) break;
		for (r = t1 + 1; r <= D + 1; r++) if (v[r][x]) break;
		s += f(a[x], l + 1, t1 - 1);
		s += f(a[x], t1 + 1, r - 1);
		s -= f(a[x], l + 1, r - 1);
		for (l = t1 - 1; l >= 0; l--) if (v[l][t2]) break;
		for (r = t1 + 1; r <= D +1; r++) if (v[r][t2]) break;
		s += f(a[t2], l + 1, r - 1);
		s -= f(a[t2], l + 1, t1 - 1);
		s -= f(a[t2], t1 + 1, r - 1);
		if (s > mx) {
			up = 0;
			for (i = 1; i <= D; i++) {
				ans[i] = u[i];
			}
			mx = s;
		} else up++;
		if (up == cut) {
			up = 0;
			for (i = 1; i <= D; i++) {
				u[i] = ans[i];
			}
			s = mx;
		}
	}
	for (i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
    return 0;
}


Measured memory_bytes: 3948
package main

import (
	"fmt"
)

func main() {
	var a1,a2,a3 int
	fmt.Scan(&a1,&a2,&a3)

	if a1 <= a2 && a2 <= a3 {
		fmt.Println(a2 - a1 + a3 - a2)
	} else if a2 <= a1 && a1 <= a3 {
		fmt.Println(a1 - a2 + a3 - a1)
	} else if a1 <= a3 && a3 <= a2 {
		fmt.Println(a3 - a1 + a2 - a3)
	} else if a2 <= a3 && a3 <= a1 {
		fmt.Println(a3 - a2 + a1 - a3)
	} else if a3 <= a1 && a1 <= a2 {
		fmt.Println(a1 - a3 + a2 - a1)
	} else if a3 <= a2 && a2 <= a1 {
		fmt.Println(a2 - a3 + a1 - a2)
	}
}

Measured memory_bytes: 512
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();
			if(N<M){
				System.out.println("0");
			}else{
				System.out.println("10");
			}
		}
 
	}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddx[4] = {1,0,-1,0};
const int ddy[4] = {0,1,0,-1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}

int x[100005];
int ans[100005];

int main(){
	//in_o();
	int n; 
	cin>>n;
	FOR(i,1,n+1){
		cin>>x[i];
	}
	int sum=0;
	FOR(i,0,n+1){
		sum+=abs(x[i+1]-x[i]);
	}
	FOR(i,1,n+1){
		ans[i]=sum-abs(x[i]-x[i-1])-abs(x[i+1]-x[i])+abs(x[i-1]-x[i+1]);
	}
	FOR(i,1,n+1){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>

int main() {
	char A[101];
	char B[101];
	char C[101];
	scanf("%s %s %s", &A, &B, &C);
	if (A[(strlen(A)-1)] == B[0] && B[(strlen(B)-1)] == C[0] ) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[8];

int main(){
   int a,b;
   cin>>a>>b;
   if(a+b>=10)cout<<"error"<<endl;
   else cout<<a+b<<endl;
   
}

Measured memory_bytes: 256
n, x = map(int, input().split())
if (x > n // 2 and n % 2 == 0) or (x > (n + 1) // 2 and n % 2 == 1):
    x = n - x

A = n - x
B = x
k = 0
m = -1
ans = n
while m != 0:
    k = A // B
    m = A % B
    ans += B * k * 2
    if m == 0:
        ans -= B
    A = B
    B = m

print(ans)

Measured memory_bytes: 3064
#!/usr/bin/ruby
#encoding: utf-8

s = gets.chomp
ary = Array.new(26,0)

(0..s.size-1).each do |i|
  ary[s[i].ord - "a".ord] += 1
end

(0..25).each do |i|
  if ary[i] == 0
    puts (i+"a".ord).chr
    exit
  end
end

puts "None"

Measured memory_bytes: 1916
local n = io.read()
local w = {}
local flag = true
for i=1,n do
	w[i] = io.read()
end

for i = 1, n-1 do
	if string.sub(w[i],-1,-1) ~= string.sub(w[i+1],1,1) then
	flag = false
	end
end

for i = 1,n-1 do
	for j=i+1,n do
		if w[i] == w[j] then
		    flag = false
		end
	end
end

if flag then
	print("Yes")
else
	print("No")
end
--#17024844 | kachidoki's solution for [AtCoder-4252] [Problem B]

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

int main() {
	init();

	int N; cin >> N;
	int left = 0, right = 0;
	deque<char>ans;
	string S;
	rep(i, 0, N) {
		char ch; cin >> ch;
		S.push_back(ch);
		ans.push_back(ch);
	}
	rep(i, 0, S.size()) {

		if (S[i] == '(')left++;
		else {
			right++;
			if (left < right) {
				ans.push_front('(');
				left++;
			}
		}
	}
	deque<char>str = ans;
	left = 0; right = 0;
	rREP(i, 0, ans.size()) {
		if (ans[i] == ')')right++;
		else {
			left++;
			if (left > right) {
				str.push_back(')');
				right++;
			}
		}
	}
	ans = str;
	rep(i, 0, ans.size())cout << ans[i];
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, a[309][309], p[309], c[309]; bool used[309];
int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> a[i][j]; a[i][j]--;
		}
	}
	int ret = N;
	for (int i = 0; i < M; i++) {
		fill(c, c + M, 0);
		for (int j = 0; j < N; j++) c[a[j][p[j]]]++;
		int ptr = max_element(c, c + M) - c;
		ret = min(ret, c[ptr]);
		used[ptr] = true;
		for (int j = 0; j < N; j++) {
			while (used[a[j][p[j]]]) p[j]++;
		}
	}
	cout << ret << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

bool is_prime(ll n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }
 
    for (ll i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

void solve() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    auto c = [&](char a) {
        if (a == 'r') return p;
        else if (a == 's') return r;
        else return s;
    };
    vector<bool> w(n, false);
    int ans = 0;
    REP(i, n) {
        if (i < k) {
            ans += c(t[i]);
            w[i] = true;
        } else {
            if (!(w[i - k] && t[i] == t[i - k])) {
                ans += c(t[i]);
                w[i] = true;
            }
        }
    }
    cout << ans << EOL;
}
 

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int main(void){
	vector<int> data;
	priority_queue<int,vector<int>,greater<int> > pq;
	int i,n,size;
	for(i=0;i<3;i++){
		cin>>n;
		pq.push(n);
	}
	size=pq.size();
//	sort(data.begin(),data.end());
	for(i=0;i<size-1;i++){
		cout<<pq.top()<<' ';
		pq.pop();
	}
	cout<<pq.top()<<endl;
	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>
int main(void) {

	char str1[4] = { '\0' };
	char str2[4] = { '\0' };
	//char str1[3];
	//char str2[3];
	scanf("%s %s", str1, str2);
	//printf("%s", str1);
	int flag = 0;
	for (int i = 0; i < 3; i++) {
		if (str1[i] != str2[2 - i]) {
			flag = 1;
			break;
		}
	}
		if (flag == 0) {
			printf("%s", "YES");
		}
		else
		{
			printf("%s", "NO");
		}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n,i,j,k;
  char s[100],t[100],ans[200];
  cin>>n;
  cin>>s>>t;
  for(i=0; i<n; i++){
    cout<<s[i]<<t[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256