akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void)
{
    int n, x;
    int i, j, k;
    int count;
     
    while(1){
        scanf("%d%d", &n, &x);
        if(!n&&!x){
            break;
        }
        count = 0;
        for(i=1; i<n-1; i++){
            for(j=i+1; j<n; j++){
                for(k=j+1; k<=n; k++){
                    if(i+j+k==x){
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
     
    return 0;
}

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

using namespace std;
typedef long long ll;


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

  vector<int> a(n), b(n);
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    maxa = max(maxa, a[i]);
  }
  sort(b.begin(), b.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < n && h > 0 && b[i] > maxa; i++) {
    h -= b[i];
    ans++;
  }
  if (h > 0) ans += (h + maxa - 1) / maxa;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp;

fn main() {
    input!(n: usize, k: usize);

    let mut count: i64 = 0;
    for i in 1..(n + 1) {
        if i * k <= n {
            count += 1;
        }
    }

    let count2: i64 = if k % 2 == 0 {
        let mut count = 0;
        let sk = k / 2;
        for i in 0..(n + 1) {
            if i * k + sk <= n {
                count += 1;
            }
        }
        count
    } else {
        0
    };
    println!("{}", count.pow(3) + count2.pow(3));
}

// a + b = xk, b = xk -a
// a + c = yk, c = yk -a
// b + c = (x+y)k - 2 * a


Measured memory_bytes: 4352
n=gets.to_i
pts=n.times.map{gets.split.map(&:to_i)}

even_flag=pts.all?{|x,y|(x+y).even?}

unless pts.all?{|x,y|(x+y).odd?} || even_flag
  puts -1
  exit
end

d=[1]
38.times{
  d << d.last*2
}

if even_flag
  pts.map!{|x,y|[x-1,y]}
end


d.reverse!
ans=[]

pts.each{|x,y|
  s=""
  d.each{|_d|
    if x.abs>y.abs
      if x>0
        x-=_d
        s+=?R
      else
        x+=_d
        s+=?L
      end
    else
      if y>0
        y-=_d
        s+=?U
      else
        y+=_d
        s+=?D
      end
    end
  }
  ans << s
}

suffix=""

if even_flag
  suffix=?R
  d << 1
end

puts d.size
puts d.join(" ")
ans.each{|s|
  puts s+suffix
}

Measured memory_bytes: 2300
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n, m;
vector<int> edge[100000];
int g[100000];


void dfs(int u, int id) {
	if (g[u])return;
	g[u] = id;
	for (int v: edge[u]) {
		dfs(v, id);
	}
}


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

	cin >> n >> m;
	rep(i,m) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;

		edge[x].push_back(y);
		edge[y].push_back(x);
	}

	int cnt = 0;
	rep(i, n) {
		if (g[i] == 0) {
			cnt++;
			dfs(i, cnt);
		}
	}
	cout << cnt << endl;



	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
using namespace std;

const int SIZE = 1e7 + 1;

int arr[SIZE];

int main(){
	for(int i = 1; i < SIZE; i++){
		for(int j = i; j < SIZE; j += i){
			arr[j]++;
		}
	}
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		ans += (long long)arr[i] * i;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 42692
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [1e9 for _ in range(n)]
dp[0] = 0
for i in range(1, n):
  if(i < k):
    for j in range(i):
      dp[i] = min(dp[0] + abs(h[i] - h[0]), dp[i])
  else:
    for j in range(k):
      dp[i] = min(dp[i+j-k] + abs(h[i] - h[i+j-k]), dp[i])
print(dp[n-1])


Measured memory_bytes: 58976
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    vector<int> as(n);

    map<int, ll> mp;
    rep(i, n) {
        int a;
        cin>>a;
        mp[a]++;
        as[i] = a;
    }

    ll s = 0;
    for (auto i : mp) {
        s += i.second * (i.second - 1) / 2;
    }

    rep(i, n) {
        ll ans = s - mp[as[i]] * (mp[as[i]] - 1) / 2 + (mp[as[i]] - 1) * (mp[as[i]] - 2) / 2;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 11392
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(A - 1, max(D, C)):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(B - 2, D + 1):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	final static int NO_MATCHING = -1;//??¬??§??????????????????
	final static int ROUNDNESS = 0;//?????¬??§,()
	final static int ANGULAR = 1;//?§???¬??§,[]
	Scanner s;
	int caret;
	void run(){
		s = new Scanner(System.in);
		while(true){
			String str = s.nextLine();
			caret = 0;
			if(".".equals(str))return;
			if(searchBalance(str,-1)){
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}
	}

	boolean searchBalance(String str,int type){
		while(true){
			if(caret >= str.length()){
				str = s.nextLine();
				caret = 0;
			}
			char ch = str.charAt(caret);
			caret++;
			switch(ch){
			case '(':
				if(!searchBalance(str,0)){
					return false;
				}
				break;
			case '[':
				if(!searchBalance(str,1)){
					return false;
				}
				break;
			case ')':
				if(type == ROUNDNESS){
					return true;
				}else{
					return false;
				}
			case ']':
				if(type == ANGULAR){
					return true;
				}else{
					return false;
				}
			default:
				break;
			}
			if(ch == '.')break;
		}
		if(type == -1){
			return true;
		}else{
			return false;
		}
	}


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

Measured memory_bytes: 41228
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int a[110];
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int d=a[n-1]-a[0];
  cout<<d;

}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

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

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int c=0;
        int m=-1;
        for(int i=0;i<n-1;i++){
        	if(a[i]>=a[i+1]){
        		c++;
        	}
        	else{
        		m=max(m,c);
        		c=0;
        	}
        }
        m=max(m,c);
        cout<<m<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    char x, y; cin >> x >> y;
    if(x<y) cout << "<" << endl;
    else if(x==y) cout << "=" << endl;
    else cout << ">" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(all(a));
	int l=0;
	int ans=0;
	for(int r=0;r<n;r++){
		while(l<r&&a[l]<a[r]-2)l++;
		chmax(ans,r-l+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#define ll long long
ll n,a[2005],s[2005][2005],x,ans=1e18;
ll min(long long x,long long y){return x<y?x:y;}
int main(){
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i){
		s[i][0]=a[i];
		for(int k=1;k<n;++k) s[i][k]=min(s[i][k-1],a[i-k>0?i-k:n+i-k]);
	}
	for(int k=0;k<n;++k){
		ll tot=0;
		for(int i=1;i<=n;++i) tot+=s[i][k];
		ans=min(ans,tot+x*k);
	}
	printf("%lld\n",ans);
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]D - Knapsack 1
            var line = ReadLine();
            int N = line[0];
            int W = line[1];

            var dp = new long[W + 1];
            var copy = new long[W + 1];

            for (int i = 0; i < N; i++)
            {
                line = ReadLine();
                int w = line[0];
                int v = line[1];

                if (dp[w] < v)
                {
                    copy[w] = v;
                }

                for(int j = 1; j <= W; j++)
                {
                    if (dp[j] > 0)
                    {
                        if (w + j <= W)
                        {
                            if (dp[w + j] < v + dp[j])
                            {
                                copy[w + j] = v + dp[j];
                            }
                        }
                    }
                }

                Array.Copy(copy, dp, W + 1);
            }

            Console.WriteLine(dp.Max());
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 14688
#include<stdio.h>
#include<math.h>
int a[1000006];
int p[1000006],pt=0;
int main()
{
	long long n;
	scanf("%lld",&n);
	int ans=0;
	for(int i=2;i<=1000001;i++)
	{
		if(a[i]==0)
		{
			p[pt++]=i;
			for(int j=2;j*i<1000001;j++)
			{
				a[i*j]=1;
			}
		}
	}
	for(int i=0;i<pt;i++)
	{
		int f=0;
		while(n%p[i]==0)
		{
			f++;
			n/=p[i];
		}
		for(int j=1;j<=f;j++)
		{
			f-=j;
			ans++;
		}
	}
	if(n>1000000)
	ans++;
	printf("%d",ans);
}

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



int main()
{
    ll t,c=0;
    //cin>>t;
    //while(t--){
        ll n;
        cin>>n;
        ll l1[n+1];
        for(int i=1;i<=n;i++){
            cin>>l1[i];
        }
        sort(l1+1,l1+n+1,greater<int>());
        
        cout<<l1[1]-l1[n]<<endl;
    //}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



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

	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	int m = max(x, max(y, z));
	int sum = x + y + z;
	if (m % 2 != sum % 2) m++;
	printf("%d\n", (3 * m - sum) / 2);

	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))
now = 1

while K:
  if K & 1:
    now = A[now]
  nex = [0] * (N + 1)
  for i in range(N + 1):
    nex[i] = A[A[i]]
  A = nex
  K >>= 1
  
print(now)

Measured memory_bytes: 169128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,m;
  cin >> a >> b >> m;
  vector<int>aa(a);
  vector<int>bb(b);
  int i;
  for(i=0;i<a;i++)cin>>aa[i];
  for(i=0;i<b;i++)cin>>bb[i];
  vector<int>x(m);
  vector<int>y(m);
  vector<int>c(m);
  for(i=0;i<m;i++){
    cin >> x[i]>>y[i]>>c[i];
    x[i]--;
    y[i]--;
  }
  int maxx=1<<30;
  int ans = 0;
  for(i=0;i<a;i++){
    if(maxx>aa[i])maxx=aa[i];
  }
  ans+=maxx;
  maxx=1<<30;
  for(i=0;i<b;i++){
    if(maxx>bb[i])maxx=bb[i];
  }
  ans+=maxx;
  maxx=0;
  for(i=0;i<m;i++){
    if(aa[x[i]]+bb[y[i]]-c[i]<ans)ans=aa[x[i]]+bb[y[i]]-c[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	vector<ll>count(s.size());
	if (s[0] == 'I') {
		count[0] =1;
	}
	else {
		count[0] = - 1;
	}
	for (ll i = 1; i < s.size(); i++) {
		if (s[i] == 'I') {
			count[i]=count[i-1]+1;
		}
		else {
			count[i]=count[i-1]-1;
		}
	}
	ll x =0;
	for (ll i = 0; i < s.size(); i++) {
		x = max(x, count[i]);
	}
	cout << x << endl;
}



Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		Team[] team = new Team[n];
		Team[] originArray = new Team[n];
		for(int i = 0; i < n; i++){
			team[i] = new Team(i+1);
			originArray[i] = team[i];
		}

		while(true){
			String str = br.readLine();

			if(str == null){
				break;
			}

			String[] tmpArray = str.split(" ");

			int teamA = Integer.parseInt(tmpArray[0]) - 1;
			int teamB = Integer.parseInt(tmpArray[1]) - 1;
			int scoreA = Integer.parseInt(tmpArray[2]);
			int scoreB = Integer.parseInt(tmpArray[3]);

			if(scoreA > scoreB){
				team[teamA].score += 3;
			}
			else if(scoreA == scoreB){
				team[teamA].score++;
				team[teamB].score++;
			}
			else {
				team[teamB].score += 3;
			}
		}
		
		Arrays.sort(team);
		
		team[0].rank = 1;
		for(int i = 1; i < n ; i++){
			//System.out.println(team[i].id+" "+team[i].score);
			if(team[i - 1].score != team[i].score){
				team[i].rank = i + 1;
			}
			else {
				team[i].rank = team[i-1].rank;
			}
		}

		for(int i = 0; i < n; i++){
			System.out.println(originArray[i].rank);
		}

	}

}

class Team implements Comparable<Team>{
	int id;
	int score;
	int rank;

	public Team(int id){
		this.id = id;
		score = 0;
		rank = 0;
	}

	@Override
	public int compareTo(Team o) {
		// TODO ?????????????????????????????????????????????
		if(this.score > o.score){
			return -1;
		}
		else if(this.score == o.score){
			return 0;
		}
		else {
			return 1;
		}
	}
}

Measured memory_bytes: 30408
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	string a;
	cin >> a;
	if(a[0]=='R'&&a[1]=='R'&&a[2]=='R') printf("3");
	else if(a[0]=='R'&&a[1]=='R') printf("2");
	else if(a[1]=='R'&&a[2]=='R') printf("2");
	else if(a[0]=='R'||a[1]=='R'||a[2]=='R') printf("1");
	else printf("0");
	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int k; std::cin >> k;
    string s; std::cin >> s;
    if (s.size() > k) std::cout << s.substr(0, k) << "..." << "\n";
    else std::cout << s << "\n";
}


Measured memory_bytes: 3644
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		cout<<(B%A==0?A+B:B-A)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 
using namespace std; 
int main(){ int a,b; 
char op; 
while(true){ 
scanf("%d %c %d",&a,&op,&b); if(op == '?') break;
 switch(op){ case '+': printf("%d\n",a+b); break;
 case '-': printf("%d\n",a-b); break;
 case '/': printf("%d\n",a/b); break;
 case '*': printf("%d\n",a*b); break;
 }
 } 
} 


Measured memory_bytes: 2732
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let EPS = 1e-8;
const let Pi = acos(-1.0);

int sign(let x) { return (x < -EPS) ? -1 : (x > EPS) ? 1 : 0; }

struct Point {
  let x, y;

  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }

  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }

  Point operator ~ () {
    return (Point) {x, -y};
  }

  friend let Cdot(Point a, Point b) {
    return a.x * b.x + a.y * b.y;
  }

  friend let Time(Point a, Point b) {
    return a.x * b.y - a.y * b.x; 
  }

  Point Rotate(let sink, let cosk) {
    return (Point) { x * cosk - y * sink, x * sink + y * cosk };
  }

  Point Rotate(let k) {
    return Rotate(sin(k), cos(k));
  }

  Point Rotate(Point k) {
    let z = k.Dist();
    // k.EchoWith('\n'); printf("%Lf\n", z);

    return Rotate(k.y / z, k.x / z);
  }

  let Dist() {
    return sqrt(x * x + y * y);
  }

  void EchoWith(char c = 0) {
    printf("%.8Lf %.8Lf", x, y);
    if (c) putchar(c);
  }
};

typedef Point Vec;

struct Line {
  Point p;
  Vec v;

  Line() { }
  Line(Point a, Point b) {
    p = a, v = b - a;
  }

  friend Point Projection(Line a, Point b) {
    return ((Point) {(b - a.p).Rotate(~a.v).x, 0}).Rotate(a.v) + a.p;
  }

};

Line line;

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_1_A.in", "r", stdin);
//   freopen("CGL_1_A.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_1_A.log", "w", stderr);
// #endif
  let xp1 = read(), yp1 = read(), xp2 = read(), yp2 = read();
  line = (Line) { (Point) {xp1, yp1}, (Point) {xp2, yp2} };
  int q = read();
  while (q--) {
    let x = read(), y = read();
    Point res = Projection(line, (Point) {x, y});
    res.EchoWith('\n');
  }
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_1_A CGL_1_A.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_1_A CGL_1_A.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_1_A < CGL_1_A.in > CGL_1_A.out
==================
}}} */



Measured memory_bytes: 3232
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

int n;

long long raz=1, dwa=1;

int main()
{
	scanf("%d", &n);
	while(n--)
	{
		int x;
		scanf("%d", &x);
		raz*=3;
		if (!(x&1))
			dwa*=2;
	}
	printf("%lld\n", raz-dwa);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
struct edge{
    int v; //行き先
    ll d; //重み
};
#define inf 1e15
#define MAX_N 1000
ll dis[MAX_N];
vector<edge> G[MAX_N];

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    REP(i,M){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        G[a-1].push_back((edge){b-1,-c});
    }
    REP(i,N) dis[i] = inf;
    dis[0] = 0;
    REP(i,N-1){
        REP(u,N){
            REP(j,G[u].size()){
                ll v = G[u][j].v;
                if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){
                    dis[v] = dis[u] + G[u][j].d;
                }
            }
        }
    }//ベルマンフォード法
    bool isNcycle[MAX_N] = {};
    REP(u,N){
        REP(j,G[u].size()){
            ll v = G[u][j].v;
            if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){
                isNcycle[v] = true;
            }
            if(isNcycle[u]) isNcycle[v] = true;
        }
    } //NEGATIVE CYCLEチェック
    if(isNcycle[N-1]) cout <<  "inf" << endl;
    else cout << -dis[N-1] << endl;
    return 0;
}


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

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; int K;
    cin >> s >> K;
    unordered_map<char, int> mp;
    int i = 1;
    for (char c = 'a'; c <= 'z'; ++c) {
        mp[c] = i;
        ++i;
    }
    for (auto &elem : s) {
        if (mp[elem] + K <= 26) {
            if (&elem == &s.back()) {
                elem += K;
            } else {
                continue;
            }
        } else {
            if (&elem == &s.back()) {
                int tmp = K % 26;
                elem = (mp[elem] + tmp <= 26 ? elem + tmp : elem - (26 - tmp));
            } else {
                if (elem == 'a') {
                    continue;
                }
                K -=  26 - mp[elem] + 1;
                elem = 'a';
            }
        }
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 592
import java.util.*;

public class Main {
    static final long MOD = 1_000_000_007;
    static long N, K, first;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        K = sc.nextLong();
        first = mod10(100);
        List<Range> allRanges = new ArrayList<>();
        long sum = 0;
        for(long k=K;k<=N+1;k++){
            sum += func(k);
            sum %= MOD;
        }

        System.out.println(sum);
    }

    private static long func(long k){
        return ((2*N-k+1)*k/2 - (k-1)*k/2+1) % MOD;
    }

    private static long mod10(int k){
        if(k == 0){
            return 1;
        }
        return mod10(k-1)*10 % MOD;
    }

    private static void getRangeForK(long k, List<Range> all){
        long s = (first*k + k*(k-1)/2 )% MOD;
        long e = (first*k + (2*N-k+1)*k/2 ) % MOD;
        if(e < s){
            all.add(new Range(0, e));
            all.add(new Range(s, MOD-1));
        }else{
            all.add(new Range(s, e));
        }
        return;
    }

    private static class Range{
        long s, e;
        Range(long s, long e){
            this.s = s;
            this.e = e;
        }
        @Override
        public String toString(){
            return s + "-" + e;
        }

    }


}


Measured memory_bytes: 35816
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 10000009
#define mod 998244353
ll n,m,i,j,k,t,arr[sz],brr[sz],l;
vector<ll>v[sz];
map<ll,ll>mp;
vector<pair<ll,ll> >v1;
int main()
{
 for(i=1;i<=10000000;i++)
 {
    for(j=1;j*i<=10000000;j++)
        arr[i*j]++;
 }
 for(i=1;i<=10000000;i++)
    arr[i]*=i,brr[i]=brr[i-1]+arr[i];
    scanf("%lld",&n);
    printf("%lld\n",brr[n]);
 return 0;
}


Measured memory_bytes: 394424
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {
            String[] aryStr = Console.ReadLine().Split(' ');

            int num1 = int.Parse(aryStr[0]);
            int num2 = int.Parse(aryStr[2]);

            if (aryStr[1].Equals("?"))
            {
                break;
            }

            if (aryStr[1].Equals("+"))
            {
                Console.WriteLine(num1 + num2);
            }
            else if (aryStr[1].Equals("-"))
            {
                Console.WriteLine(num1 - num2);
            }
            else if (aryStr[1].Equals("*"))
            {
                Console.WriteLine(num1 * num2);
            }
            else if (aryStr[1].Equals("/"))
            {
                Console.WriteLine(num1 / num2);
            }
        }
    }
}

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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1,2,4,3);}
    void roll_y(){ roll(0,2,5,3);}
    void roll_x(){ roll(0,1,5,4);}
    void roll(int i, int j, int k, int l){
        int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

bool eq(Cube c1, Cube c2){
    for(int i=0; i<6; i++)
        if(c1.f[i] != c2.f[i]) return false;
    return true;
}

bool equal(Cube c1, Cube c2){
    for(int i=0; i<6; i++){
        for(int j=0; j<4; j++){
            if(eq(c1,c2)) return true;
            c1.roll_z();
        }
        if(i%2==0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

Cube C[100]; int n;

bool check(){
    for(int i=0; i<n-1; i++)
        for(int j=i+1; j<n; j++) if(equal(C[i], C[j])) return false;
    return true;
}

int main(){
    cin >> n;
    for(int j=0; j<n; j++)
        for(int i=0; i<6; i++) cin >> C[j].f[i];
    
    if(check()) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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


int main () {
	
	string s;
	cin >> s;
	
	if(s[2] == s[3]  && s[4] == s[5])
	{
		 cout << "Yes";
	}
	else
	{
		cout << "No";
	}


	
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int a[30]={};
int main(){
	string s;
	cin>>s;
	int d=s.size();
	for(int i=0;i<d;i++){
		a[s[i]-97]++;
	}
	for(int i=0;i<26;i++){
	if(a[i]>1){cout<<"no"<<endl;return 0;}
	}
	cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

ll n, m, k, u, v;
ll cnt[10];
map<pair<ii, ii>, ll> mp;
void add(int u, int v){
//	printf("Trong ham u = %d v = %d:\n", u, v);
	if(u > 0 && v > 0 && u + 2 <= n && v + 2 <= m){
		mp[{{u, v},{u+2, v+2}}]++;
//		printf("%d %d %d %d\n", u, v, u+2, v+2);
	}
	if(u > 0 && v-1 > 0 && u + 2 <= n && v + 1 <= m){
		mp[{{u, v-1},{u+2, v+1}}]++;
//		printf("%d %d %d %d\n", u, v-1, u+2, v+1);
	}
	if(u > 0 && v-2 > 0 && u + 2 <= n && v <= m){
		mp[{{u, v-2},{u+2, v}}]++;
//		printf("%d %d %d %d\n", u-1, v-2, u+1, v);
	}
	if(u-1 > 0 && v > 0 && u + 1 <= n && v + 2 <= m){
		mp[{{u-1, v},{u+1, v+2}}]++;
//		printf("%d %d %d %d\n", u-1, v, u+1, v+2);
	}
	if(u-1 > 0 && v-1 > 0 && u + 1 <= n && v + 1 <= m){
		mp[{{u-1, v-1},{u+1, v+1}}]++;
//		printf("%d %d %d %d\n", u-1, v-1, u+1, v+1);
	}
	if(u-1 > 0 && v-2 > 0 && u + 1 <= n && v <= m){
		mp[{{u-1, v-2},{u+1, v}}]++;
//		printf("%d %d %d %d\n", u, v-2, u+2, v);
	}
	if(u-2 > 0 && v > 0 && u <= n && v + 2 <= m){
		mp[{{u-2, v},{u, v+2}}]++;
//		printf("%d %d %d %d\n", u-2, v, u, v+2);
	}
	if(u-2 > 0 && v-1 > 0 && u <= n && v + 1 <= m){
		mp[{{u-2, v-1},{u, v+1}}]++;
//		printf("%d %d %d %d\n", u-2, v-1, u, v+1);
	}
	if(u-2 > 0 && v-2 > 0 && u <= n && v <= m){
		mp[{{u-2, v-2},{u, v}}]++;
//		printf("%d %d %d %d\n", u-2, v-2, u, v);
	}
}

signed main(){
	scanf("%d %d %d", &n, &m, &k);
	f(i,1,k){
		scanf("%d %d", &u, &v);
		add(u, v);
	}
	memset(cnt, 0, sizeof(cnt));
	for(auto i : mp){
//		printf("%lld %lld %lld %lld : ", i.first.first.first, i.first.first.second, i.first.second.first, i.first.second.second);
//		printf("%lld\n", i.second);
		cnt[i.second] += 1;
	}
	cnt[0] = (n-3+1)*(m-3+1);
	f(i,1,9){
		cnt[0] -= cnt[i];
	}
	f(i,0,9){
		printf("%lld\n", cnt[i]);
	}
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

int main(){
int n;
cin >> n;
string s;
cin >> s;
if(n%2==1){
cout << "No";

}else{
int flag=0;
for(int i=0;i<n/2;i++){
if(s[i]!=s[n/2+i])flag=1;
}
if(flag==1)cout << "No";
else cout << "Yes";
}





}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

vll adj[200222],sz;
map<ii, int>vis;
ll ans[200222], col[200222];
ll n,m,k;
void bfs(int curr, int color){
	int v[n+1];
	memset(v,0,sizeof(v));
	queue<int>q;
	q.push(curr);
	ll cur_sz=0;
	while(!q.empty()){
		int cur = q.front();
		q.pop();
		if(v[cur])continue;
		v[cur]=1;
		col[cur]=color;
		cur_sz++;
		for(int i = 0; i < int(adj[cur].size()); i++){
			int neg = adj[cur][i];
			if(!v[neg]){
				q.push(neg);
			}
		}
	}
	sz.pb(cur_sz);
	return;
}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll a,b,c,d;
	cin >> n >> m >> k;
	memset(ans,0,sizeof(ans));
	
	for(int i=0; i<m; i++){
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int colour = 1; sz.pb(0);
	for(int i=1; i<=n; i++){
		if(col[i]==0)bfs(i,colour),colour++;
		ans[i] = sz[col[i]]-1-int(adj[i].size());
 	}
	for(int i=0; i<k; i++){
		cin >> c >> d;
		if(col[c]==col[d]){
			ans[c]--;
			ans[d]--;
		}
	}
 	for(int i=1; i<=n; i++){
		cout << ans[i] << ' ' ;
	}
	cout << endl;
}	


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

const int mod=998244353;
#define ll long long
#define ld long double
#define pb push_back
#define Dracarys ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()

ll po(ll x,ll y,ll md=mod){
	ll res=1;
	x%=md;
	
	while(y){
		if (y&1){
			res=(res*x)%md;
		}
		y>>=1;
		x=(x*x)%md;
	}
	return res;
}

void solve(){
	ld a,b;
	cin>>a>>b;
	cout<<(ll)floor(a*b)<<"\n";
}	

int main(){
	
	Dracarys

	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



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

int main() {
  int A,B,C,X,Y,M,m;
  cin >> A >> B >> C >> X >> Y;
  
  m = A*X + B*Y + C*(X+Y);
  
  for (int i = 0; i <= max(2*X,2*Y); i++) {
    M = max(X-i/2,0)*A + max(Y-i/2,0)*B + i*C;
    if ( M <= m ) {
      m = M; 
    }         
  }
  
  cout << m << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,x,t1,t2;
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a==0)
    {
        t1=(b/x)+1;
        printf("%lld",t1);
    }
    else if(a==1)
    {
        t1=(b/x);
        printf("%lld",t1);
    }
    else
    {
        t2=(a-1)/x;
        t1=(b/x)-t2;
        printf("%lld",t1);
    }
    return 0;
}


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

int main(){
    string S; cin >> S;

    int ans = 0;
    int tmp = 0;
    for(int i=0; i<S.size(); ++i){
        if(S[i] == 'R'){
            tmp++;
            ans = max(ans, tmp);
        }else{
            tmp  = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod (int) (1e9 +7)

int main(){
    
    int a,b; cin>>a>>b;
    
    int res= (a*(a-1))/2 + (b*(b-1))/2;
    
    cout<<res<<"\n";
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int r = sc.nextInt();

		final int MAX_VALUE = 1_000_000_000;

		int[][] dist = new int[n + 1][n + 1];
		for (int i = 0; i < n + 1; i++) {
			for (int j = 0; j < n + 1; j++) {
				if (i == j) dist[i][j] = 0;
				else dist[i][j] = MAX_VALUE;
			}
		}

		List<Integer> towns = new ArrayList<Integer>();
		for (int i = 0; i < r; i++) {
			towns.add(sc.nextInt());
		}

		for (int i = 0; i < m; i++) {
			int from = sc.nextInt();
			int to = sc.nextInt();
			int cost = sc.nextInt();

			dist[from][to] = dist[to][from] = cost;
		}

		sc.close();

		for (int k = 0; k < n + 1; k++) {
			for (int i = 0; i < n + 1; i++) {
				for (int j = 0; j < n + 1; j++) {
					dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}

		List<List<Integer>> perm = permutations(r, towns);
		int min = MAX_VALUE;
		for (List<Integer> item : perm) {
			int temp = 0;
			for (int i = 1; i < item.size(); i++) {
				temp += dist[item.get(i - 1)][item.get(i)];
			}
			if (min > temp) min = temp;
		}
		System.out.println(min);

	}

	private static List<List<Integer>> permutations(int n, List<Integer> list) {
		if (n <= 0) {
			return Arrays.asList(Arrays.asList());
		}
		else {
			List<List<Integer>> result = new ArrayList<>();
			for (Integer head : list) {
				for (List<Integer> tail : permutations(n - 1, remove(head, list))) {
					result.add(cons(head, tail));
				}
			}
			return result;
		}
	}

	private static List<Integer> cons(Integer head, List<Integer> tail) {
		List<Integer> list = new ArrayList<>();
		list.add(head);
		list.addAll(tail);
		return list;
	}

	private static List<Integer> remove(Integer e, List<Integer> list) {
		List<Integer> newList = new ArrayList<>(list);
		newList.remove(e);
		return newList;
	}
}


Measured memory_bytes: 66436
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
ll N,Q;
const ll MAX_V=1e9;
vector<ll> rnkend;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>Q;
	if(N==1){
		REP(i,Q){
			ll u,v;
			cin>>u>>v;
			cout<<u<<endl;
		}
	}else{
		rnkend.push_back(1);
		while(rnkend.back()<MAX_V){
			rnkend.push_back(rnkend.back()*N+1);
		}
		REP(q,Q){
			ll u,w;
			cin>>u>>w;
			ll rnku,rnkw;
			rnku=lower_bound(rnkend.begin(),rnkend.end(),u)-rnkend.begin();
			rnkw=lower_bound(rnkend.begin(),rnkend.end(),w)-rnkend.begin();
			while(rnku>rnkw){
				u=(u+N-2)/N;
				rnku--;
			}
			while(rnku<rnkw){
				w=(w+N-2)/N;
				rnkw--;
			}
			while(u!=w){
				u=(u+N-2)/N;
				w=(w+N-2)/N;
			}
			cout<<u<<endl;
		}
	}
			
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#include "string"
//#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
const int N = 1e5 + 1;


int32_t main(){ 
    boost;
	int n,m;
	cin>>n>>m;
	pi a[2] ={{m+1+(m+1)%2,2*m+1},{1,m+(m+1)%2}};
	for(int i=0;i<m;i++){
		cout<<a[i%2].ff<<" "<<a[i%2].ss<<endl;
		a[i%2].ff++,a[i%2].ss--;
	}     
}


Measured memory_bytes: 3668
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    if s.len() == 2 {
        println!("{}", s);
    } else {
        println!("{}", s.chars().rev().collect::<String>());
    }
}

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()
}


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin >> n >> k;
    int h[n]; for (int i = 0; i < n; ++i) cin >> h[i];
    sort(h, h + n);
    int ans = 1e9;
    map<int, int> mp;
    for (int i = 0; i < k; ++i) {
        mp[h[i]]++;
    }
    {
        auto it = mp.end();
        it--;
        ans = it->first - mp.begin()->first;
        //cout << ans << endl;
    }
    for (int i = k; i < n; ++i) {
        mp[h[i]]++;
        mp.erase(h[i - k]);
        auto it = mp.end();
        it--;
        ans = min(ans, it->first - mp.begin()->first);
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x,y,x_,y_;
	cin>>x>>y>>x_>>y_;
	int dx=x_-x,dy=y_-y;
	printf("%d %d %d %d\n",x_-dy,y_+dx,x-dy,y+dx);
}

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

ll solve() {
    string A;
    cin >> A;
    ll c = 0;
    map<char, int> m;
    for ( char a : A ) {
        m[a]++;
        c += m[a]-1;
    }
    ll ans = A.size() * (A.size() - 1) / 2 + 1 - c;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
	int n, k;
	std::cin >> n >> k;

	std::vector<int> d(k);
	for (auto&& e : d)
		std::cin >> e;

	for (int i = n; true; ++i) {
		if ([&d](int x) {
			while (x > 0) {
				for (auto&& e : d)
					if (x % 10 == e)
						return false;

				x /= 10;
			}

			return true;
		}(i)) {
			std::cout << i << std::endl;
			return 0;
		}
	}
}

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

public class AC
{


    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }


    public static void Main()
    {
        int[] A = ReadArray();

        Console.WriteLine((int)Math.Ceiling((double)A[0] / A[1]) * A[2]);


    }

}


Measured memory_bytes: 17984
#include<stdio.h>
int main (void){
    int n;
    scanf("%d",&n);
    unsigned long long int power=1;
    int loop1;
    for(loop1=1;loop1<=n;loop1++){
        power*=loop1;
        power%=1000000007;
    }
    printf("%llu\n",power);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{

	long long int n = 0, m = 100;
	long long int a;
	
	scanf("%lld", &a);
	
	while(1)
	{
		if(m >= a)
		{
			printf("%d", n);
			return 0;
		}
		m += (m*0.01);
		n++;
	}
}
	

Measured memory_bytes: 1724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		String s=sc.next();
		String ans="";
		for(int i=0; i<N; i++) {
			if(i==K-1) {
				ans=ans+((char)(s.charAt(i)+32));
			}
			else {
				ans=ans+s.charAt(i);
			}
		}
		pl(ans);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int n,a,b,ca,cb,cc;
vector<int> v;

int main(void){
    cin>>n>>a>>b;
    int temp;
    rep(i,n){
        cin>>temp;
        if(temp<=a)ca++;
        else if(temp<=b)cb++;
        else cc++;
    }
    cout<<min(ca,min(cb,cc))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    int N;
    cin >> N;
    cout << pow(N,2)*3 << endl;
}

Measured memory_bytes: 256
K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
    

Measured memory_bytes: 41196