akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,c,k; cin>>n>>c>>k;
    vector<int>v(n); rep(i,n)cin>>v[i];
    sort(all(v));
    auto itr=v.begin();
    auto iend=v.begin()+c;
    int ans=0;
    int key=v[0];
    while(true){
        ans++;
        auto next=upper_bound(itr,iend,key+k);
        if(next!=iend){
            key=*(next);
            itr=next;
        }else if(next==iend){
            if(iend==v.end())break;
            key=*(iend);
            itr=iend;
        }
        if(itr+c>v.end())iend=v.end();
        else iend=itr+c;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
H, W = [int(_) for _ in input().split()]
cbd = [list(input()) for _ in range(H)]
for i in range(H): 
    for j in range(W):
        if cbd[i][j] == ".":
            c = 0
            for iw in range(i-1,i+2):
                for jw in range(j-1,j+2):
                    if iw < 0 or H <= iw or jw < 0 or W <= jw:
                        continue
                    elif cbd[iw][jw] == "#":
                        c += 1
            cbd[i][j] = str(c)
for i in range(H):
    print("".join(cbd[i]))

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = new List<int>();
        for (int i = 0; i < n; i++)
        {
            a.Add(int.Parse(Console.ReadLine()));
        }
        int max = a.Max();
        int cnt = a.Where(f => f == max).Count();
        foreach (var item in a)
        {
            if (cnt > 1) Console.WriteLine(max);
            else Console.WriteLine(item == max ? a.OrderByDescending(f => f).ToArray()[1] : max);
        }
    }
}


Measured memory_bytes: 23636
n, d = (int(each) for each in input().split())
l = []
for i in range(n):
    l.append([int(each) for each in input().split()])

result = 0

for each in l:
    if each[0]**2 + each[1]**2 <= d**2:
        result += 1

print(result)

Measured memory_bytes: 42392
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        string[] line = Console.ReadLine().Split(' ');

        long k = long.Parse(line[0]);
        long a = long.Parse(line[1]);
        long b = long.Parse(line[2]);

        // たたくことによる利益
        long r1 = k + 1;

        //  交換による利益
        long d = b - a;
        long n = a - 1;
        long c = (k - n) / 2;
        long f = (k - n) % 2;
        long r2 = (n + 1) + (d * c) + f;

        Console.WriteLine(Math.Max(r1, r2));
        Console.ReadLine();
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
int x,n,i,j,sw[100],cc,swsw[100];
  cc=0;
  for(i=0;i<100;++i)
  {
  sw[i]=0;
  swsw[i]=0;
  }
  
scanf("%d %d",&x,&n);
  
  int p[n];

   for(i=0;i<n;++i)
  {
  scanf("%d",&p[i]);
    
  }
 
for(j=0;j<100;++j)   
  for(i=0;i<n;++i)
  {
  if(p[i]-x == j)
    {
     sw[j]++;
     swsw[j]=swsw[j]+1;
    }
  else if(x-p[i] == j)
    {
     sw[j]++;
     swsw[j]=swsw[j]-1;
    }
  }
  i=1;
  if(sw[0]==0) printf("%d",x);
 else
 {
 while(cc==0)
   {
    if(sw[i]==0) {printf("%d",x-i);
                 cc++;
                 }
    else if(sw[i]==1 && swsw[i]==1) {printf("%d",x-i);
                                    cc++;
                                    }
    else if(sw[i]==1 && swsw[i]==-1) {printf("%d",x+i);
                                     cc++;}
   else i++;
   }
 } 
    
       
return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int n, v[20], c[20];
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] < v[i]) ans += v[i] - c[i];
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
import itertools

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

ANS = set()
for i in range(1,n+1):
    A_pairs = list(itertools.combinations(A, i))
    for j in range(len(A_pairs)):
        ANS.add(sum(A_pairs[j]))

for i in range(q):
    if m[i] in ANS:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 56264
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MAXN = 1e5 + 5;
int n, m, a, b;
int value[MAXN];
int repr[MAXN];
int _size[MAXN];

int findset(int x) {
	if (x == repr[x]) return x;
	repr[x] = findset(repr[x]);
	return repr[x];
}

void unionset(int x, int y) {
	x = findset(x);
	y = findset(y);
	if (x == y) return;
	if (_size[x] > _size[y]) swap(x, y);
	_size[y] += _size[x];
	repr[x] = y;
}

bool sameset(int x, int y) {
	return findset(x) == findset(y);
}

void input() {
	for (int i = 0; i < MAXN; i++) {
		repr[i] = i;
		_size[i] = 1;
	}
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> value[i];
}

void solve() {
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		unionset(a, b);
	}
	int suma = 0;
	for (int i = 1; i <= n; i++)
		suma += sameset(i, value[i]);
	cout << suma << "\n";
}


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

	return 0;
}


Measured memory_bytes: 1408
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <random>
#include <cmath>
#include <climits>
#include <iomanip>
#include <cfloat>
#include <set>
#include <map>
#include <tuple>
#include <array>
int main() {
	std::array<std::array<double, 2000>, 2> memo;
	int n, t;
	std::string str;
	double max = 0;
	std::cout << std::setprecision(16);
	while (true) {
		std::cin >> n >> t;
		if (n == 0 && t == 0) return 0;
		std::cin >> str;
		for (auto i = 0; i < str.size(); ++i) {
			if (str[i] == 'R') memo[0][i] = 1;
			else memo[0][i] = 0;
		}
		for (auto times = 0; times < t; ++times) {
			for (auto i = 0; i < n; ++i) {
				memo[(times + 1) % 2][i] = 0;
				for (auto d = 1; d <= 6; ++d) {
					memo[(times + 1) % 2][i] += memo[times % 2][(i + d) % n];
				}
				memo[(times + 1) % 2][i] /= 6;
			}
		}
		max = 0;
		for (auto i = 0; i < n; ++i) {
			if (max < memo[t % 2][i]) max = memo[t % 2][i];
		}
		std::cout << max << std::endl;
	}
}


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

int main() {
  int N, M, total = 0;
  cin >> N >> M;
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    total += A.at(i);
  }
  sort(A.rbegin(), A.rend());
  if (A.at(M-1) * 4 * M >= total) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	if(k<=a){
		cout<<k<<endl;
		// return 0;
	}
	else if(k<=a+b){
		ll sum=a*1+(k-a)*0;
		cout<<sum<<endl;
	}
	else{
		ll sum=a*1+b*0+(k-(a+b))*(-1);
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;



int main()
{
	/*
		ABC92A問題

	*/
	string str;
	cin >> str;

	for (int i = 1; i < 3; i++) {
		for (int j = 0; j < i; j++) {
			if (str[i] == str[j]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    char str[200];
    int i, cnt = 0;

    scanf("%s", str);
    for (i = 1; str[i + 2] != '\0'; i++, cnt++) {
    }
    printf("%c%d%c\n", str[0], cnt + 1, str[cnt + 2]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int N,C;
int how[31];
int beat[31];
int dp[2][1<<16];
int cnts[1<<16];

int main(){

  while(cin>>N>>C&&(N|C)){
    for(int i=0;i<N;i++){
      int mask=0;
      for(int j=0;j<16;j++){
        int a;
        cin>>a;
        mask|=(a<<j);
      }
      beat[i]=mask;
    }
    for(int i=0;i<C;i++){
      int mask=0;
      for(int j=0;j<16;j++){
        int a;
        cin>>a;
        mask|=(a<<j);
      }
      how[i]=mask;
    }
    int cur=0;
    int nxt=1;
    for(int mask=0;mask<(1<<16);mask++){
      cnts[mask]=popcount(mask);
    }
    for(int pos=N;pos>=0;pos--){
      for(int mask=0;mask<(1<<16);mask++){
        int res=0;
        if(pos==N)res=0;
        else{
          int cmask=mask|beat[pos];
          for(int i=0;i<C;i++){
            int tmp=cmask&how[i];
            res=max(res,dp[nxt][cmask^tmp]+cnts[tmp]);
          }
        }
        dp[cur][mask]=res;
      }
      swap(cur,nxt);
    }
    cout<<dp[nxt][0]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1936
#include<cstdio>
using namespace std;
int main()
{
	int a[3][3];bool booki[3]={0};bool bookj[3]={0};
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
		{
			scanf("%d",&a[i][j]);
		}
			
		if(a[0][0]+a[1][1]+a[2][2]==a[0][2]+a[1][1]+a[2][0]&&a[0][0]+a[1][1]+a[2][2]==a[0][1]+a[1][0]+a[2][2]
		&&a[0][0]+a[1][1]+a[2][2]==a[0][0]+a[1][2]+a[2][1]&&a[0][0]+a[1][1]+a[2][2]==a[0][1]+a[1][2]+a[2][0]
		&&a[0][0]+a[1][1]+a[2][2]==a[0][2]+a[1][0]+a[2][1]
		)
		printf("Yes");
		else
		printf("No");
}

Measured memory_bytes: 128
#include<cstdio>
int main()
{
    char a[105][105];
    int H,W;
    while (scanf("%d %d",&H,&W)==2)
    {
        for (int i=1;i<=H;i++)
        {
            getchar();
            for (int j=1;j<=W;j++)
                a[i][j]=getchar();
        }
        getchar();
        for (int i=0;i<=H+1;i++)
        {
            for (int j=0;j<=W+1;j++)
            {
                if (i==0||j==0||i==H+1||j==W+1)printf("#");
                else printf("%c",a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int h,w,a,b;
const int N=1000010;
int fac[N],inv[N];
const int mod=1000000007;
int n,m,k;
int qp(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod;
		k>>=1;
	}
	return res;
}
void init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<N;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-1]=qp(fac[N-1],mod-2);
	for(int i=N-2;i>=1;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int a,int b)
{
	if(a<b)return 0;
	return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;
}
long long ans,sum;
int main()
{
	init();
	scanf("%d%d%d",&n,&m,&k);
	sum=1; ans=qp(3,m+k)%mod;
	for(int i=1;i<=m+k;i++)
	{
		sum=(sum*2%mod-(i-1>=k?C(i-1,k):0)+mod-(i-1>=m?C(i-1,i-m-1):0)+mod)%mod;
		ans=(ans+sum*qp(3,m+k-i)%mod*C(i+n-1,n-1)%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

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

		String s = scan.nextLine();

		if(s.equals("ABC")){
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 35476
using System;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] abcde = Enumerable.Range(1, 5).Select(_ => Console.ReadLine()).Select(x => int.Parse(x)).ToArray();
            int k = int.Parse(Console.ReadLine());
            for (int i = 0; i < 4; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    int p = abcde[i];
                    int q = abcde[j];
                    if ((q - p) > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }
            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 13396
h, w, k = map(int, input().split())
c = []
for i in range(h):
    li = input()
    c.append(li)

ans = 0
for ih in range(1 << h):
    for jw in range(1 << w):
        count = 0
        for i in range(h):
            for j in range(w):
                if (ih >> i & 1) == 0 and (jw >> j & 1) == 0:
                    if (c[i][j] == '#'):
                        count += 1
        if count == k:
            ans += 1
print(ans)


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)4e5 + 3;

void solve() {
	ll n;cin>>n;
	cout<<(n+1)/2<<"\n";
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if( cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->prev = nil;
    x->next = nil->next;
    nil->next = x;
    x->next->prev = x;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
//    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i') { insert(key); size++;}
        else{
            if(strlen(com)==6){deleteKey(key);}
            else if(com[6]=='F'){deleteFirst();}
            else if(com[6]=='L'){deleteLast();}
            size--;
        }
    }
    printList();
    return 0;
}


Measured memory_bytes: 33832
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a, int b){
    if(a<b){int tmp=a;a=b;b=tmp;}
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b, a-b);
}
int main() {
    int n, x;
    cin >> n >> x;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        d[i] = abs(x-a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = gcd(ans, d[i]);
    }

    cout << ans << endl;
    
    
}

Measured memory_bytes: 640
a, b, c = map(int, input().split())

counter = 0
while a%2==b%2==c%2==0:
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    counter += 1
    if counter > 1000:
        counter = -1
        break
print(counter)

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

using namespace std;

int get(vector<int> &a, int x) {
    int res = 0;
    for(int i : a) {
        res += (x - i) * (x - i);
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int s = 0;
    int x;
    vector<int> a;
    for(int i = 0; i < n; ++i) {
        cin >> x;
        s += x;
        a.push_back(x);
    }
    int res = -1;
    int resV = 1e9;
    int div = s / n;
    for(int i = div - 1; i <= div + 1; ++i) {
        if(i >= 0) {
            if(get(a, i) < resV) {
                resV = get(a, i);
                res = i;
            }
        }
    }
    cout << resV << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int X = stdIn.nextInt();
		
		if(A <= X && X <= (A+B))
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}
	}

}


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

using namespace std;
int a[200005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int mi=1e9;
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[i]<=mi){
			ans++;
			mi=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,c=0;cin>>n;while(n) c++,n/=2;
	cout<<(ll)pow(2,c)-1<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int rem (int a, int b);
int main () {
	int a, b;
	int LCM;	// Least Common Multiple
	int GCD;	// Greatest Common Divisor
	while (scanf ("%d %d", &a, &b) != EOF) {
		if (a >= b) {
			LCM = rem (a, b);
			GCD = (a / LCM) * b;
		}
		else if (a < b) {
			LCM = rem (b, a);
			GCD = (a / LCM) * b;
		}
		printf ("%d %d\n", LCM, GCD);
	}
	return 0;
}

int rem (int a, int b) {
	if (a % b == 1) {
		return 1;
	} else if (a % b == 0) {
		return b;
	} else {
		return rem (b, (a % b));
	}
	
}

Measured memory_bytes: 596
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main(){
    int a, b, i;
    cin>>a>>b;
    int sa = b-a;
    int nagasa = 0;
    for(i=1; i<=sa; i++){
        nagasa += i;
    }

    cout<<nagasa-b<<endl;

    return 0;
}

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

int main(){
int a, b;
cin >> a >> b;
int ans;
if(a>=13) ans = b;
if(a>=6 && a<=12) ans = b /2;
if(a<=5) ans = 0;
cout << ans << endl;
return 0;
}

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


Measured memory_bytes: 2092
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	int b[1000];
	int c;
	
	scanf("%d", &n);
	
	for (a = 0; a < n; a++){
		scanf("%d", &b[a]);
	}
	for (c = n - 1; c >= 1; c--){
		printf("%d ", b[c]);
	}
	printf("%d", b[0]);
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 604
s = input()
n = len(s)
res = [1 for _ in range(n)]

for i in range(n):
    if s[i] == 'R' and s[i+1] == 'R':
        res[i+2] += res[i]
        res[i] = 0

for i in range(n-1, -1, -1):
    if s[i] == 'L' and s[i-1] == 'L':
        res[i-2] += res[i]
        res[i] = 0

print(*res)

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#include<complex>

using namespace std;

int xi,yi,vi;
int xp,yp,vp;

double check(vector<pair<int,int> > v,double &cx,double &cy,double t){
  double l=t,h=1e9;
  double lx,ly;
  for(int i=0;i<1000;i++){
    double m=(l+h)/2;
    double r=m;
    int idx;
    for(idx=0;idx<v.size()-1;idx++){
      double ct=hypot(v[idx+1].first-v[idx].first,v[idx+1].second-v[idx].second)/vi;
      if(r<ct)break;
      r-=ct;
    }
    if(idx==v.size()-1){
      lx=v.back().first;
      ly=v.back().second;
    }else{
      complex<double> d=complex<double>(v[idx+1].first-v[idx].first,v[idx+1].second-v[idx].second);
      auto p=d/abs(d)*r*double(vi);
      lx=v[idx].first+p.real();
      ly=v[idx].second+p.imag();
    }
    if(hypot(cx-lx,cy-ly)<=vp*(m-t)){
      h=m;
    }else{
      l=m;
    }
  }
  cy=ly;
  cx=lx;
  return h;
}

int main(){
  int N;
  cin>>N;
  int x[1234],y[1234];
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }
  cin>>xi>>yi>>vi;
  cin>>xp>>yp>>vp;
  vector<pair<int,int> > v[2];
  for(int i=0;i<N;i++){
    if(x[i]==xi&&y[i]==yi){
      for(int j=i;j<N;j++){
	v[0].emplace_back(x[j],y[j]);
      }
      for(int j=i;j>=0;j--){
	v[1].emplace_back(x[j],y[j]);
      }
      goto endinit;
    }
  }
  for(int i=0;i<N-1;i++){
    if(min(x[i],x[i+1])<=xi&&xi<=max(x[i],x[i+1])&&min(y[i],y[i+1])<=yi&&yi<=max(y[i],y[i+1])
       &&(y[i+1]-y[i])*(xi-x[i])==(yi-y[i])*(x[i+1]-x[i])){
      v[0].emplace_back(xi,yi);
      for(int j=i;j>=0;j--){
	v[0].emplace_back(x[j],y[j]);
      }
      v[1].emplace_back(xi,yi);
      for(int j=i+1;j<N;j++){
	v[1].emplace_back(x[j],y[j]);
      }
      goto endinit;
    }
  }
 endinit:
  double t[2][2];
  for(int i=0;i<2;i++){
    double cx=xp,cy=yp;
    double ct=0;
    for(int j=0;j<2;j++){
      t[i][j]=check(v[i^j],cx,cy,ct);
      ct=t[i][j];
    }
  }
  double leave[2]={};
  for(int i=0;i<2;i++){
    for(int j=0;j<v[i].size()-1;j++){
      leave[i]+=hypot(v[i][j+1].first-v[i][j].first,v[i][j+1].second-v[i][j].second)/vi;
    }
  }
  cout<<fixed<<min({max(leave[0],leave[1]),t[0][1],t[1][1],max(t[0][0],leave[1]),max(t[1][0],leave[0])});
}

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

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

	vector<int> A(N);
	for(int i=0; i<N; ++i) cin >> A[i];

	long long ans = 0;
	for(int i=0; i<N; ++i){
		int b; cin >> b;
		ans += b;
	}

	vector<int> C(N);
	for(int i=0; i<N-1; ++i){
		cin >> C[i];
	}

	for(int i=1; i<N; ++i){
		if(A[i-1] + 1 == A[i]) {
			ans += C[A[i-1]-1];
		}
	}

	cout << ans << endl;
}


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


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

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	char ans[1000][1000] = {};

	rep(i, h) {
		bool y = i < b;
		rep(j, w) {
			bool x = j < a;
			ans[i][j] = (x != y ? 1 : 0);
		}
	}

	rep(i, h) {
		rep(j, w) {
			cout << (int)ans[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cmath>
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	double h[6]={165.0,170.0,175.0,180.0,185.0,9999};
	int co[6]={0};
	int n;
	cin>>n;
	rep(i,n){
		double in;
		cin>>in;
		rep(j,6)if(in<h[j]){co[j]++;break;}
	}
	rep(i,6){
		cout<<i+1<<":";
		rep(j,co[i])cout<<"*";
		cout<<endl;
	}
}

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

using namespace std;

int main () {	
	string s;
	cin >> s;
	bool ok1 = 0, ok2 = 0, ok3 = 0, ok4 = 0;
	for (int i = 0;i < s.size ();i ++) {
		if (s[i] == 'N') ok1 = 1;
		if (s[i] == 'S') ok2 = 1;
		if (s[i] == 'E') ok3 = 1;
		if (s[i] == 'W') ok4 = 1;
	}
	if (ok1 != ok2 || ok3 != ok4) cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int a[100010];
int ans[110][110];
int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	int k = 0;
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i % 2 == 0) {
				ans[i][j] = k + 1;
				cnt++;
			}
			else {
				ans[i][W - 1 - j] = k + 1;
				cnt++;
			}
			if (cnt == a[k]) {
				k++;
				cnt = 0;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int ans[10001];
int main()
{
	ans[1]=2;
	for(int i = 2; i < 10001; ++i)
	{
		ans[i]=ans[i-1]+i;
	}

	int n;
	while (cin>>n) 
	{
		cout<<ans[n]<<endl;
	}
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define lson o<<1
#define rson o<<1|1
#define MID int mid=(l+r)>>1;
#define LL long long
using namespace std;
const int maxn=2e5+5;
int bit[maxn];
int book[maxn];
int pos[maxn];
int a[maxn];
int n;
vector<int>l;
struct node
{
    int x, y;

}p[maxn];
int val[maxn<<2];
bool cmp1(node a, node b)
{
    return a.x<b.x;
}
bool cmp2(node a, node b)
{
    return a.x>b.x;
}
void update(int o, int l, int r, int x, int y)
{
    if(l==r)
    {
        val[o]=max(val[o], y);
        return;
    }

    MID;
    if(x>mid)update(rson, mid+1, r, x, y);
    else update(lson, l, mid, x, y);

    val[o]=max(val[lson], val[rson]);

    return;
}

int query(int o, int l, int r, int x, int y)
{
    if(x<=l && r<=y)
    {
        return val[o];
    }

    MID

    int res=0;
    if(x<=mid)res=query(lson, l, mid, x, y);
    if(y>mid)res=max(res, query(rson, mid+1, r, x, y));

    return res;
}



int main()
{
    int  i, j, sx, sy, dx, dy;
    scanf("%d%d%d%d", &sx, &sy, &dx, &dy);
    if(sx>dx)
    {
        swap(sx, dx);
        swap(sy, dy);
    }
    cin>>n;

    for(i=0; i<n; i++)
    {
        scanf("%d%d", &p[i].x, &p[i].y);
    }
    j=0;
    LL mi1=min(sx, dx), ma1=max(sx, dx), mi2=min(sy, dy), ma2=max(sy, dy);
    for(i=0; i<n; i++)
    {
//        if(p[i].x==dx || p[i].y==dy)continue;
        if(p[i].x<=ma1 && p[i].x>=mi1 && p[i].y>=mi2 && p[i].y<=ma2)
        {
            p[j++]=p[i];
        }
    }
    n=j;
    if(sy<dy)sort(p , p+n, cmp1);
    else sort(p, p+n, cmp2);
    for(i=0; i<n; i++)
    {
        pos[i+1]=p[i].y;
        l.push_back(pos[i+1]);
//        printf("%d ", pos[i+1]);
    }
//    printf("\n");
    sort(l.begin(), l.end());
    l.erase(unique(l.begin(), l.end()), l.end());
    for(i=1; i<=n; i++)
    {
        pos[i]=lower_bound(l.begin(), l.end(), pos[i])-l.begin()+1;
    }


    int ans=0;
    int ma=0;
    if(n>1)
    {
    update(1, 1, n, pos[1], 1);
    for(i=2; i<=n; i++)
    {
//        printf("%d\n", pos[i]);
        if(pos[i]-1>=1)ma=query(1, 1, n, 1, pos[i]-1);
        else ma=0;
        update(1, 1, n, pos[i], ma+1);
        ans=max(ans, ma+1);
    }
    }
    else if(n==1)ans=1;
//    cout<<ans<<endl;
    double res=(ma1-mi1)*(double)100.0+(ma2-mi2)*(double)100.0;
    double pi=3.141592653589793238462643383279502884, num=n;
    int row=ma1-mi1+1, col=ma2-mi2+1;

    if(sx!=dx && sy!=dy)
    {
//        cout<<233;
        if(ans>=min(row, col))res+=((double)pi*(double)5.0);
        res=res-ans*(double)20.0+((double)ans*pi*(double)5.0);
    }
    else res=res-num*(double)20.0+(num*pi*(double)10.0);
    printf("%.15f\n", res);
}


Measured memory_bytes: 7412
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val f = str().map {it-'0'}.sum()%9==0
	println(if(f) "Yes" else "No")
}


Measured memory_bytes: 41088
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<climits>
#include<cfloat>
#include<sstream>
#define all(c) (c).begin(),(c).end()
#define INF (1<<29)

using namespace std;


double dist(double p,double q){
  double a=p+q,b=abs(p-q);
  return sqrt(a*a-b*b);
}

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits =(((bits >> 4) + bits) & 0x0f0f0f0f);
  bits += bits >> 8;
  return (bits + (bits >> 16)) & 0xff;
}

double dp[(1<<12)][12];

int main(void){

  string str;
  while(getline(cin,str)){
    int value;
    stringstream ss(str);
    vector<double>in;
    while(ss >> value)in.push_back(value);
    if(in.size()<1)break;
    double L=in[0];
    int m=in.size()-1;
    vector<double>p(m);
    for(int i=1;i<in.size();i++)p[i-1]=in[i];

    fill(dp[0],dp[1<<12],INF);
    for(int i=0;i<m;i++)dp[1<<i][i]=p[i];

    for(int S=0;S<(1<<m);S++){
      for(int v=0;v<m;v++){
	for(int u=0;u<m;u++){
	  if(S>>u&1)continue;
	  int nx=S;
	  nx|=(1<<u);
	  if(count(S)==m-1)dp[nx][u]=min(dp[nx][u],dp[S][v]+dist(p[v],p[u])+p[u]);
	  else dp[nx][u]=min(dp[nx][u],dp[S][v]+dist(p[v],p[u]));
	}
      }
    }
    double ans=INF;
    for(int i=0;i<m;i++)ans=min(ans,dp[(1<<m)-1][i]);
    if(ans<=L)cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

int main() {
  int N, M; cin >> N >> M;
  const int INF = 1000000007;
  vector<vector<int>> G(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) G.at(i).at(i) = 0;
  vector<int> A(M), B(M), C(M);
  for (int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    G.at(a).at(b) = c;
    G.at(b).at(a) = c;
    A.at(i) = a;
    B.at(i) = b;
    C.at(i) = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G.at(i).at(j) = min(G.at(i).at(j), G.at(i).at(k) + G.at(k).at(j));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool ok = true;
    for (int s = 0; s < N; s++) {
      for (int t = s+1; t < N; t++) {
        if (G.at(s).at(t) == G.at(s).at(A.at(i)) + C.at(i) + G.at(B.at(i)).at(t)) {
          ok = false;
        }
        if (G.at(s).at(t) == G.at(s).at(B.at(i)) + C.at(i) + G.at(A.at(i)).at(t)) {
          ok = false;
        }
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    f = list(map(int, readline().split()))
    f.sort(reverse=True)

    cor_v = 10 ** 20
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n):
            if a[i] * f[i] >= bin_v:
                cost += ((a[i] * f[i]) - bin_v + f[i] - 1) // f[i]
            if cost > k:
                break
        #costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 83736
n, m = map(int, input().split())
crd_std = []
crd_chk = []
ans = []

for _ in range(n):
    crd_std.append(list(map(int, input().split())))

for _ in range(m):
    crd_chk.append(list(map(int, input().split())))

for s in crd_std:
    min_crd = 10**9
    ans_crd_idx = 100
    for c in range(len(crd_chk)):
        if abs(s[0] - crd_chk[c][0]) + abs(s[1] - crd_chk[c][1]) < min_crd:
            min_crd = abs(s[0] - crd_chk[c][0]) + abs(s[1] - crd_chk[c][1])
            ans_crd_idx = c+1
    ans.append(ans_crd_idx)

for i in ans:
    print(i)


Measured memory_bytes: 69356
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        int FHY=X/500;
        int FHYR=FHY*500;
        int RY=X-FHYR;
        int FY=RY/5;
        int FHH=FHY*1000;
        int FH=FY*5;
        System.out.println(FHH+FH);
    }
}


Measured memory_bytes: 21844
/*    Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#pragma gcc optimize ("unroll-loop")
#pragma gcc optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    int sum=1;
    int cnt=0;
    while(sum<m)
    {
        sum+=n-1;
        cnt++;
    }
    cout<<cnt<<endl;



        
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
X = [0] * N
Y = K - Q 
for i in range(Q):
  X[A[i]-1] += 1
for j in range(N):
  if Y + X[j] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 56536
a,b=gets.split
x=[*1..13].map(&:to_s)
first=x.shift
x.push(first)
if (x.index(a)>x.index(b))
  puts 'Alice'
elsif (x.index(a)<x.index(b))
  puts 'Bob'
else
  puts 'Draw'
end

Measured memory_bytes: 1788
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main {
  public static void main (String[] args) throws java.lang.Exception {
	Scanner sc = new Scanner(System.in);
	String s = sc.nextLine();
	String result = "Yes";
	for (int i = 0; i < s.length(); i++) {
	  if ((i % 2 == 0 && s.charAt(i) == 'L') || (i % 2 == 1 && s.charAt(i) == 'R')) {
	  	result = "No";
	  	break;
	  }
	}
	System.out.println(result);
  }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
#define V vector<int> 
using namespace std;
int solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    #ifndef ONLINE_JUDGE 
        freopen("input1.txt", "r", stdin); 
        freopen("output1.txt", "w", stdout); 
    #endif 
    
    //int t;
    //cin>>t;
    //while(t--)
    //{
        //solve();
        //cout<<endl;
       cout<<solve()<<endl;
    //}
return 0;
}
int solve()
{
   string s;
   cin>>s;
   int c=0;
   int max=0;
   for(int i=0;i<3;)
   {
       if(s[i]=='R' )
       {
           while(s[i]=='R' && i<3)
            {
                c++;
                i++;
            }
            if(c > max)
                max=c;
            c=0;
       }    
       else i++;
   }
   return max;
}

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

void subseq(ll** mat,ll i,ll n,ll* op,ll j,ll m,ll x,ll &money){
    if(i==n){
        ll* ar = new ll[m+1];
        for(ll q=0;q<=m;q++){
            ar[q]=0;
        }
        ll cost=0;
        for(ll k=0;k<j;k++){
            ll row = op[k];
            cost+=mat[row][0];
            for(ll c=1;c<=m;c++){
                ar[c]+=mat[row][c];
            }
        }
        bool res = true;
        for(ll i=1;i<=m;i++){
            if(ar[i]<x){
                res=false;  break;
            }
        }
        if(res){
            money = min(money,cost);
        }
        return ;
    }

    op[j]=i;
    subseq(mat,i+1,n,op,j+1,m,x,money);

    subseq(mat,i+1,n,op,j,m,x,money);

    return ;
}

int main() {
    ll n,m,x;
    cin>>n>>m>>x;

    ll** mat = new ll*[n];
    for(ll i=0;i<n;i++){
        mat[i] = new ll[m+1];
    }

    for(ll i=0;i<n;i++){
        for(ll j=0;j<=m;j++){
            cin>>mat[i][j];
        }
    }

    ll op[100];
    ll j=0;

    ll i=0;
    ll money=INT_MAX;
    subseq(mat,i,n,op,j,m,x,money);
    if(money==INT_MAX)
        money=-1;
    cout<<money;
    
    return 0;
}


Measured memory_bytes: 4024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll INF = 1e18L + 5;

int main() 
{
    int n, W;
    cin>>n>>W;
    vector<int> wt(n), val(n);
    for(int i = 0; i < n; ++i)
    cin>>wt[i]>>val[i];
    
    int sum_val = 0;
    for(int x : val)
    sum_val += x;

    vector<ll> dp(sum_val + 1, INF); 
    dp[0] = 0;
    for(int item = 0; item < n; ++item) 
    for(int valrd = sum_val - val[item]; valrd >= 0; --valrd)
    dp[valrd + val[item]]=min(dp[valrd + val[item]], dp[valrd] + wt[item]);
    
    ll answer = 0;
    for(int i = 0; i <= sum_val; ++i)
    if(dp[i] <= W)
    answer = max(answer, (ll) i);
    
    cout<<answer;
}

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

int main() {
  int N,K;
  int x[110];
  cin >> N >> K;
  for (int i = 0; i <N; ++i){
  cin >> x[i];
  }
  int y=0;
  for (int i=0; i< N; ++i){
  if (K-x[i] > x[i]){
  y +=x[i]+x[i];  
  }
  else {
    y += (K-x[i])*2;
  }
  }
  cout << y <<endl;
}


Measured memory_bytes: 256
s = input()

if s[0] == s[1]:
    a = s.count(s[0])
    b = s.count(s[2])
    if a == 2 and b == 2:
        print("Yes")
    else:
        print("No")
else:
    a = s.count(s[0])
    b = s.count(s[1])
    if a == 2 and b == 2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n, t int
	fmt.Scanf("%d %d\n", &n, &t)

	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &slice[i])
	}

	total := 0
	for i := 1; i <= n; i++ {
		if i == n {
			total += t
		} else if (slice[i] - slice[i-1]) > t {
			total += t
		} else {
			total += (slice[i] - slice[i-1])
		}
	}

	fmt.Println(total)
}


Measured memory_bytes: 6500
x, n = map(int, input().split())

p = list(map(int, input().split()))

abs_n = 0
ans = 0

if n == 0:
    print(x)
else:
    #r = max(p)
    #l = min(p)

    for i in range(-100,201):
    
        # 配列に含まれていると
        if i in p:
            continue
            
        tmp = abs(x-i)
        #print(i, tmp)

        if i == -100:
            abs_n = tmp
            ans = i
        
        if tmp < abs_n:
            abs_n = tmp
            ans = i
        
    print(ans)

Measured memory_bytes: 61900
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  int ans = 0;
  ans += a[2] - a[1];
  a[0] += a[2] - a[1];
  a[1] = a[2];
  if ((a[1] - a[0]) % 2 == 0)
  {
    ans += (a[1] - a[0]) / 2;
  }
  else
  {
    ans += (a[1] + 1 - a[0]) / 2 + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int a,b,c,d[10000] = {};
string s,t;

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

    P(n/3);
	
	return  0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
string s[1000];
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>s[i];
		int m=0;
		rep1(i,N-1){
			int j=0;
			while(s[i][j]=='.') j++;
			j--;
			s[i][j]='+';
			m=max(m,j);
		}
		rep(i,m){
			int p=-1;
			rep(j,N){
				if(s[j].size()<=i) continue;
				if(s[j][i]=='+'){
					if(p==-1){
						p=j;
					}else{
						for(int k=p+1;k<j;k++) s[k][i]='|';
						p=j;
					}
				}else{
					if(s[j][i]!='.') p=-1;
				}
			}
		}
		rep(i,N){
			rep(j,s[i].size()) if(s[i][j]=='.') s[i][j]=' ';
			cout<<s[i]<<endl;
		}
	}
}

Measured memory_bytes: 1984
def main():
    Q = 998244353
    N, K = map( int, input().split())
    LR = [ tuple( map( int, input().split())) for _ in range(K)]
    LR.sort()
    dp = [0]*(N+1)
    dp[1] = 1
    S = [0]*K
    for i in range(2,N+1):
        for j, (l, r) in enumerate(LR):
            if l <= i:
                S[j] += dp[i-l]
            if r < i:
                S[j] -= dp[i-r-1]
            S[j] %= Q
        dp[i] += sum(S)
        dp[i] %= Q
    # print(dp)
    print(dp[N])
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 16908
import sys
sys.setrecursionlimit(1000000)

def F(S,curr,D,res):
    if D["A"]<0 or D["B"]<0 or D["C"]<0:
        return False
    if len(S)==curr:
        print("Yes")
        for c in res:
            print(c)
        #print("".join(res))
        return True
    s=S[curr]
    
    a=False
    b=False
    if D[s[0]]>=1:
        D[s[0]]-=1
        D[s[1]]+=1
        res.append(s[1])
        a=F(S,curr+1,D,res)
        res.pop(-1)
        D[s[0]]+=1
        D[s[1]]-=1
    if a:
        return a

    if D[s[1]]>=1:
            D[s[1]]-=1
            D[s[0]]+=1
            res.append(s[0])
            b=F(S,curr+1,D,res)
            res.pop()
            D[s[1]]+=1
            D[s[0]]-=1
    return a or b


N,A,B,C=map(int,input().strip().split())
D={"A":A,"B":B,"C":C}
S=[]
res=[]
for i in range(N):
    S.append(input())
if not (F(S,0,D,res)):
    print("No")

Measured memory_bytes: 104388
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
fav = make_divisors(n)
result = 0
for x in fav:
    if x == n:
        continue
    m = int(n/x)-1
    if int(n/m)==n%m:
        result += m
print(result)

Measured memory_bytes: 3272