akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

int main(void){  
  int n;
  while(cin>>n){
    if(!n) break;
    int tmp,minn=0,maxn=0;
    REP(i,5){
      cin >> tmp;
      minn+=tmp;
      maxn+=tmp;
    }
    REP(i,n-1){
      int tmpn=0;
      REP(i,5){
        cin>>tmp;
        tmpn+=tmp;
      }
      minn = min(minn,tmpn);
      maxn = max(maxn,tmpn);
    }
    printf("%d %d\n",maxn,minn);
  }
  return 0;
}

Measured memory_bytes: 0
from heapq import heappush,heappop,heapify

n,m = map(int,input().split())
lis = [[] for i in range(m+1)]

for _ in range(n):
    a,b = map(int,input().split())
    if a <= m:
        lis[a].append(-b)

ans = 0
num = []
heapify(num)

for j in range(1,m+1):
    for nu in lis[j]:
        heappush(num,nu)
    if len(num) > 0:
        work = heappop(num)
        ans += -work
print(ans)

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

int main(){
  int a,b ,c,i,yaku=0;

  cin >> a >> b >> c ;
  
  for ( i = a ; i <=b ; i++ ){
    if ( c%i == 0 ){
      yaku++;
    }
  }

  cout << yaku << endl;



  return 0 ;

}

Measured memory_bytes: 1160
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
      	int K = scn.nextInt();
      	String s = scn.next();
      	if(s.length() <= K){
        	System.out.println(s);
        }else{
        	System.out.println(s.substring(0, K) + "...");
        }
	}
}

Measured memory_bytes: 38408
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
     
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[]str= br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            
            if(a==0 && b==0){
                break;
            }else{
                if(a>b){
                    System.out.println(b+ " "+ a);
                }else{
                    System.out.println(a+ " "+ b);
                }
            }
        }
    
        
        
    }
}

Measured memory_bytes: 24436
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,C;
    scanf("%d%d%d",&N,&M,&C);
    int A[M],B[M];
    int result =0;
    int SUM=0;
    for(int i=0; i<M; i++){
        scanf("%d", &B[i]);
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            scanf("%d", &A[j]);
            SUM+=A[j]*B[j];
        }
        if(SUM+C>0) result++;
        SUM=0;
    }
    printf("%d", result);
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

ll spow(int a,int r){
  if(r==0) return 1;
  return (ll)a*spow(a,r-1);
}

int main(){
  int n,m;
  cin >> n >> m;
  int time = 1900*m + 100*(n-m);
  cout << spow(2,m)*time << endl;
}


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

long long FloorSum(long long n, long long m, long long a, long long b) {
    long long ret=0;
    while(1) {
        if(a >= m) ret += ((n-1)*n*(a/m))>>1,a%=m;
        if(b >= m) ret += n*(b / m),b%=m;
        long long y=(a*n+b)/m, x=(y*m-b);
        if(y==0) return ret;
        ret += (n-(x+a-1)/a)*y;
        b=(a-x%a)%a; swap(a,m); n=y;
    }
}

using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int Q; cin >> Q;
    while(Q--){
        ll N,M,A,B; cin >> N >> M >> A >> B;
        cout << FloorSum(N,M,A,B) << "\n";
    }
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

void unique_count(vector<int> &a, vector<vector<int>> &b) {
	// erase(b.begin(), b.end());
	for (int i=0; i<a.size(); i++)
		if ((i>0)&&(a.at(i)==a.at(i-1)))
			b.back().at(0)++;
		else
			b.push_back({1, a.at(i)});
	return;
}

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> A(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	sort(A.begin(), A.end());
	vector<vector<int>> B;
	unique_count(A, B);
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	int S=0;
	while(K<B.size()) {
		S +=B.at(K).at(0);
		K++;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 12848
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int n;
    cin >> n;
    int minNum = 500;
    int maxNum = 0;
    int indexMax;
    int indexMin;
    int a[n];
    int b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    int counter = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] != a[i]) ++counter;
    }

    if (counter > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
template <typename F>
int lower_bound(int from, int until, const F& predicate) {
	while (from < until) {
		const auto mid = (from + until) / 2;
		if (predicate(mid)) until = mid;
		else from = mid + 1;
	}
	return until;
}
struct Edge {
	int to;
	long long int cost;
	Edge(const int t, const int c) :to{ t }, cost{ c }{};
};
int mlca(int a, int b, const std::vector<int>& depth, const std::vector<std::vector<int>>& parents) {
	while (a != b) {
		if (depth[a] == depth[b]) {
			auto first = lower_bound(0, parents[a].size(), [&parents, a, b](const int index) { return parents[a][index] == parents[b][index]; });
			if (first == 0) return parents[a].front();
			else {
				a = parents[a][first - 1];
				b = parents[b][first - 1];
			}
		}
		else if (depth[a] > depth[b]) {
			auto first = lower_bound(0, parents[a].size(), [&parents, &depth, a, b](const int index) {return depth[parents[a][index]] <= depth[b]; });
			if (first == 0) a = parents[a].front();
			else a = parents[a][first - 1];
		}
		else {
			auto first = lower_bound(0, parents[b].size(), [&parents, &depth, a, b](const int index) {return depth[parents[b][index]] <= depth[a]; });
			if (first == 0) b = parents[b].front();
			else b = parents[b][first - 1];
		}
	}
	return a;
}
int main() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<std::vector<Edge>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int a, b, c; std::cin >> a >> b >> c;
		nodes[a - 1].emplace_back(b - 1, c);
		nodes[b - 1].emplace_back(a - 1, c);
	}
	std::vector<std::vector<int>> parents(n);
	std::queue<int> queue; queue.push(0);
	std::vector<int> depth(n, INT_MAX); depth[0] = 0;
	std::vector<long long int> length(n, 0);
	while (!queue.empty()) {
		auto current = queue.front(); queue.pop();
		for (const auto& e : nodes[current]) if (depth[e.to] > depth[current]) {
			parents[e.to].push_back(current);
			while (parents[e.to].size() <= parents[parents[e.to].back()].size()) {
				parents[e.to].push_back(parents[parents[e.to].back()][parents[e.to].size() - 1]);
			}
			depth[e.to] = depth[current] + 1;
			length[e.to] = length[current] + e.cost;
			queue.push(e.to);
		}
	}
	int q, k; std::cin >> q >> k; --k;
	for (auto i = 0; i < q; ++i) {
		int x, y; std::cin >> x >> y; --x; --y;
		auto ca = mlca(x, k, depth, parents);
		auto cb = mlca(y, k, depth, parents);
		std::cout << (length[x] + length[k] * 2 + length[y] - length[ca] * 2 - length[cb] * 2) << std::endl;
	}
}



Measured memory_bytes: 22400
n,m=map(int,input().split())
ans=0
if n==1:
  ans+=300000
elif n==2:
  ans+=200000
elif n==3:
  ans+=100000
if m==1:
  ans+=300000
elif m==2:
  ans+=200000
elif m==3:
  ans+=100000
if n==m==1:
  ans+=400000
  
print(ans)

  

Measured memory_bytes: 3060
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(N,A,B);
    if(abs(A-B)%2LL==0LL){
        cout << abs(A-B)/2LL << nn;
    }else{
        int revA = N - A + 1;
        int revB = N - B + 1;
        cout << min(max(A,B)+min(A,B)-1LL, max(revA,revB)+min(revA,revB)-1LL)/2LL << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define pf push_front

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,a[100000];
ll sum1,sum2,ans1,ans2;

int main() {
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) {
		sum1+=a[i];
		if(i&1) {
			if(sum1>=0) ans1+=sum1+1,sum1=-1;
		}
		else {
			if(sum1<=0) ans1+=1-sum1,sum1=1;
		}
	}
	REP(i,n) {
		sum2+=a[i];
		if(i&1) {
			if(sum2<=0) ans2+=1-sum2,sum2=1;
		}
		else {
			if(sum2>=0) ans2+=sum2+1,sum2=-1;
		}
	}

	cout<<min(ans1,ans2)<<endl;

	return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n;
  scanf("%d", &n);
  vector<int> l(n * 2);
  for (int i = 0; i < n * 2; ++i)
    scanf("%d", &l[i]);
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 0; i < n * 2; i += 2)
    ans += l[i];
  printf("%d\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

#include<cmath>

int main()
{


    int k,x;
    cin>>k>>x;

    int start=x-(k-1);
    int end=x+(k-1);

    for(int i=start;i<=end;i++){

        if(i==end)
            cout<<i<<endl;
        else
            cout<<i<<' ';

    }

    return 0;
}  

Measured memory_bytes: 256
#include <iostream>
 using namespace std ;
 int main()
 {
   int A, B, c, d, e;
   cin>>A;
   cin>>B;
   c =(A + B);
   d =(A - B);
   e =(A * B);
   if (c >= e&&c >= d)
   {
   cout<<c<<endl;
   }
else   if (e >= d&&e >= c)
   {
     cout<<e<<endl;
   }
  else  if (d >= e&&d >= c) 
   {
     cout<<d<<endl;
   }
   }

Measured memory_bytes: 3556
n = int(input())

t, a = map(int, input().split())
taka = t
aoki = a
t_a = t / a
for _ in range(n - 1):
    t, a = map(int, input().split())
    if t_a == t / a:
        continue
    elif t_a < t / a:
        tmp = ((aoki - 1) // a + 1)
        aoki = tmp * a
        taka = tmp * t
    else:
        tmp = ((taka - 1) // t + 1)
        aoki = tmp * a
        taka = tmp * t
    t_a = t / a
print(taka + aoki)


Measured memory_bytes: 9204
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
ll vis[mm];

vector<int>y[200005];
int z[200005];
int main()
{
	int a,b,c,n;
	memset(z,0x3f,sizeof(z));z[1]=0;
	scanf("%d%d",&a,&n);
	while(n--)
	{
		scanf("%d%d",&b,&c);
		y[b].push_back(c);
		y[c].push_back(b);
	}
	queue<int>q;
	q.push(1);n=1;
	while(q.size()&&n!=a)
	{
		b=q.front();
		q.pop();
		for(int i=0;i<y[b].size();i++)
		{
			c=y[b][i];
			if(z[c]==maxn)
			{
				n++;
				z[c]=b;
				q.push(c);
			}
			if(n==a)break;
		}
	}
	for(int i=2;i<=a;i++)if(z[i]==maxn){printf("No\n");return 0; }
	printf("Yes\n");
	for(int i=2;i<=a;i++)printf("%d\n",z[i]);
}



Measured memory_bytes: 13392
#include<stdio.h>

int main(){
	
	int a,b,c;

	scanf("%d %d %d\n",&a,&b,&c);

	if(a<b & b<c)
		printf("%d %d %d\n",a,b,c);
	if(a>b & b>c)
		printf("%d %d %d\n",c,b,a);
	if(a<b & b>c & a<c)
		printf("%d %d %d\n",a,c,b);
	if(a<b & b>c & a>c)
		printf("%d %d %d\n",c,a,b);
	if(a>b & b<c & a<c)
		printf("%d %d %d\n",b,a,c);
	if(a>b & b<c & a>c)
		printf("%d %d %d\n",b,c,a);
	if(a<b & b==c)
		printf("%d %d %d\n",a,b,c);
	if(a>b & b==c)
		printf("%d %d %d\n",b,c,a);
	if(a==b & b<c)
		printf("%d %d %d\n",a,b,c);
	if(a==b & b>c)
		printf("%d %d %d\n",c,a,b);
	if(a==c & b<c)
		printf("%d %d %d\n",b,a,c);
	if(a==c & b>c)
		printf("%d %d %d\n",a,c,b);
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int gcd(int,int);

int main()
{
  int x,y;
  int z;

  scanf("%d%d",&x,&y);
  z = gcd(x,y);
  printf("%d\n",z);
  return 0;
}

int gcd(int x,int y)
{
  int k = 0;
  int m;

  while(1){
    if(x > y){
      k = x % y;
      if(k == 0){
	m = y;
	break;
      }
      x = y;
      y = k;
    }
    else{
      k = y % x;

      if(k == 0){
	m = x;
	break;
      }
      y = x;
      x = k;
    }
    
  }

  return m;
}



Measured memory_bytes: 2140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int n;
  cin >> n;
  int total = 1;
  int odd = 1;
  while(n--) {
    int x;
    cin >> x;
    if(x%2 == 0) odd *= 2;
    total *= 3;
  }
  cout << total - odd << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main() {
  int N,E;
  cin >> N;
  E=0;
  string A="a";
  string B="b";
  string C="c";
  for(int i=0;i<N;i++) {
    string x;
    cin >> x;
    if(A=="a"||A==x) {
      if(A=="a") {
        E++;
      }
      A=x;
    } else {
      if(B=="b"||B==x) {
        if(B=="b") {
          E++;
        }
        B=x;
      } else {
        if(C=="c"||C==x) {
          if(C=="c") {
            E++;
          }
          C=x;
        } else {
          E++;
          break;
        }
      }
    }
  }
  if(E==3) {
    cout << "Three" << endl;
  } else {
    if(E==4) {
      cout << "Four" << endl;
    }
  }
}

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

ab = 0
ba = 0

for i in range(b):
    ab += a * (10 ** i)
for i in range(a):
    ba += b * (10 ** i)

ans = ab

if a > b:
    ans = ba
if a == b and ab > ba:
    ans = ba

print(ans)

Measured memory_bytes: 3316
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Main {

    static Map<Integer, List<Integer>> map = new HashMap<>();

    static {
        map.put(0, Arrays.asList(0, 1));
        map.put(1, Arrays.asList(0, 1, 2));
        map.put(2, Arrays.asList(1, 2, 3));
        map.put(3, Arrays.asList(2, 3, 4));
        map.put(4, Arrays.asList(3, 4, 5));
        map.put(5, Arrays.asList(4, 5, 6));
        map.put(6, Arrays.asList(5, 6, 7));
        map.put(7, Arrays.asList(6, 7, 8));
        map.put(8, Arrays.asList(7, 8, 9));
        map.put(9, Arrays.asList(8, 9));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();

        Queue<Long> queue = new ConcurrentLinkedQueue<>();
        int count = 0;
        for (long i = 1; i < 10; i++) {
            queue.add(i);
        }

        long value = 0;
        while (k > count) {
            value = queue.poll();

            int div = (int)(value % 10);
            for (long v : map.get(div)) {
                queue.add(value * 10 + v);
            }
            count++;
        }

        System.out.println(value);
    }

}


Measured memory_bytes: 46420
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  (n : m : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  pss <- sequence . replicate m $ ((,) <$> pred . unsafeSignedDecimal . fst <*> (== T.pack "AC") . snd) . unsafeListToTuple . T.words <$> T.getLine :: IO [(Int, Bool)]
  let
    as :: V.Vector (Bool, Int)
    as = V.accum op (V.replicate n (False, 0)) pss
    op :: (Bool, Int) -> Bool -> (Bool, Int)
    op (False, w) False = (False, succ w)
    op (False, w) True = (True, w)
    op x _ = x
    (a, w) = V.foldl step (0, 0) as
    step (s, t) (True, u) = (succ s, t + u)
    step x _ = x
  putStr . show $ a
  putStr " "
  putStrLn . show $ w

unsafeListToTuple :: [a] -> (a, a)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 51580
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main() {
	ll i, j, k, l;
	ll N;
	string s;
	map<char, int> m;
	cin >> s;
	rep(i, s.size()) {
		m[s[i]] = 0;
	}
	//dump(m.count('S'));
	bool yes = false;
	if (m.size() == 4) {
		yes = true;
	}
	else if (m.size() == 2) {
		if (m.count('N') == 0 && m.count('S') == 0) {
			// cerr << "NS" << endl;
			yes = true;
		}
		else if (m.count('W') == 0 && m.count('E') == 0) {
			// cerr << "SE" << endl;
			yes = true;
		}
	}
	puts(yes ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
import itertools
# import math
# import sys
import numpy as np

# K = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M, X = map(int, input().split())
# H = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0]) # keyでsort
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement([i for i in range(1, M + 1)], N))
# print(a[0][0])
# print(conditions[0])

conditions = []
for i in range(N):
    CA = list(map(int, input().split()))
    conditions.append(CA)
conditions = np.array(conditions)
pattarns = list(itertools.product((0,1), repeat=N))

min_clear_cost = 10**20
for pattarn in pattarns:
    cost = 0
    A = np.zeros(M)
    for i, j in enumerate(pattarn):
        if j == 1:
            cost += conditions[i][0]
            A += conditions[i][1:]
    if min(A) >= X and min_clear_cost > cost:
        min_clear_cost = cost

if min_clear_cost == 10**20:
    min_clear_cost = -1

print(min_clear_cost)


Measured memory_bytes: 27392
#include <bits/stdc++.h>
const int inf=0x3f3f3f3f;
using namespace std;
template <typename T> void read(T &t) {
    t=0; char ch=getchar(); int f=1;
    while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int main(){
	int a,b;
	read(a);
	read(b);
	b--;
	cout<<ceil(b/(1.0*(a-1)));
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right

N = int(input())
A = [int(input()) for _ in range(N)]

t = [-A[0]]
for a in A[1:]:
    if a <= -t[-1]:
        t.append(-a)
    else:
        t[bisect_right(t, -a)] = -a
print(len(t))


Measured memory_bytes: 11756
X = int(input())
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
  
i = X
cnt = 0
flg = is_prime3(i)
if flg == False:
    while flg==False:
        i += 1
        cnt = i
        flg = is_prime3(i)
    print(cnt)
else:
    print(i)


Measured memory_bytes: 39536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(){
  string s;
  cin >> s;
  string alp = "abcdefghijklmnopqrstuvwxyz";
  REP(i,26){
    if(s.find(alp[i])==-1){
      cout << alp[i];
      break;
    }
    if(i==25){
      cout << "None";
      break;
    }
  }
  cout << endl;
}

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

int main()
{
  int n;
  cin >> n;
  int L[n];
  for(int i = 0; i < n ; i++)
  {
    cin >> L[i];
  }
  
  int temp = L[0];
  int sum = L[0];
  for(int i = 1; i < n ; i++)
  {
    if(temp < L[i])
    {
      temp = L[i];
    }
    sum += L[i];
  }
  sum -= temp;
  
  if(temp < sum)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	a=Math.abs(a-x);
	b=Math.abs(b-x);
if(a<b){
	System.out.println("A");
}else{System.out.println("B");}
	}}

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

const long long  MAX=510000;
const long long MOD=1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (long long i=2;i<MAX;i++) {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k) {
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main(){
    COMinit();
    long long n,k,ans=0ll;
    scanf("%lld %lld",&n,&k);
    for (long long i=1;i<=k;i++) {
        //ans=(COM(n+1-k,i)*COM(k-1,i))%MOD;
        if (i>1) {
            ans=(COM(n+1-k,i)*COM(k-1,i-1))%MOD;
        } else {
            ans=COM(n+1-k,i);
        }
        printf("%lld\n",ans%MOD);
    }
    return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#include <iomanip>
#include <limits>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const long long INF = 1LL << 60;
using namespace std;

int main(){
	int n; cin >>n;
	cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, d = map(int, input().split())
ans = 0

for i in range(n):
    x, y = map(int, input().split())
    if (x ** 2 + y ** 2) <= d ** 2:
        ans += 1

print(ans)


Measured memory_bytes: 68564
# -*- coding: utf-8 -*-

N = int(input())
S = input()

# 累積和を使う方法
W_ruiseki = [0]
E_ruiseki = [0]
# 0地点を含めたN+1パターンを予め用意しておく
for i in range(N):
    if S[i] == "W":
        W_ruiseki.append(W_ruiseki[i] + 1)
    else:
        W_ruiseki.append(W_ruiseki[i])
    # Eは全体-Wで出せる
    E_ruiseki.append(i+1 - W_ruiseki[i+1])

ans = float("inf")
for i in range(N):
    cnt = 0
    cnt += W_ruiseki[i]
    cnt += E_ruiseki[N] - E_ruiseki[i+1]
    ans = min(ans, cnt)

print(ans)

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

int main() {
    int a,b,c,k ;
    cin >> a >> b >> c >> k ;

    while (k && (a>=b))
    {
        b *= 2 ;
        k-- ;
        //cout << a << b << c << endl ;
    }

    while (k && (b>=c))
    {
        c *= 2 ;
         k-- ;
    }


    if(b>a && c>b){
              cout << "Yes" << endl ;   
    }else{
             cout << "No" << endl ;   
    } 


    return 0 ;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp1[5010][5010]={0};
int dp2[5010][5010]={0};
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	dp1[0][0]=dp2[0][0]=1;
	rep(i,n)rep(j,5010)if(dp1[i][j]){
		if(j+in[i]<5010)dp1[i+1][j+in[i]]=true;
		dp1[i+1][j]=true;
	}
	rep(i,n)rep(j,5010)if(dp2[i][j]){
		if(j+in[n-1-i]<5010)dp2[i+1][j+in[n-1-i]]=true;
		dp2[i+1][j]=true;
	}
	int out=0;
	rep(i,n){//[ m-in[i] , m)
		vi d1(m+1),d2(m+2);
		rep(j,m+1)d1[j]=dp1[i][j];
		rep(j,m+1)d2[j+1]=dp2[n-1-i][j];
//		rep(j,m+1)cout<<" "<<d1[j];cout<<endl;
//		rep(j,m+1)cout<<" "<<d2[j];cout<<endl;
//		cout<<endl;
		rep(j,m+1)d2[j+1]+=d2[j];
		bool h=false;
		rep(j,m+1)if(d1[j]){
			int l=m-in[i]-j,r=m-j;
			if(r<=0)continue;
			if(l<0||d2[r]-d2[l])h=true;
//			cout<<l<<" "<<r<<endl;
		}
//			cout<<h<<endl;
		out+=h;
	}
	cout<<n-out<<endl;
}











Measured memory_bytes: 196224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
    
int main()
{
    int N;
    cin >> N;
    vll A(N);
    bool z = false;
    rep(i, N)
    {
        cin >> A[i];
        if(!A[i]) z = true;
    }
    if(z)
    {
        ll ans = 0;
        rep(i, N)
        {
            ans += abs(A[i]);
        }
        cout << ans << endl;
    }
    else
    {
        ll ans = 0;
        ll minabs = 1LL << 60;
        ll minabsi = 0;
        ll mc = 0;
        rep(i, N)
        {
            if(abs(A[i]) < minabs)
            {
                minabs = abs(A[i]);
                minabsi = i;
            }
            if(A[i] < 0) mc++;
        }
        if(mc % 2 == 0)
        {
            rep(i, N)
            {
                ans += abs(A[i]);
            }
        }
        else
        {
            rep(i, N)
            {
                if(i == minabsi)
                {
                    ans -= abs(A[i]);
                }
                else
                {
                    ans += abs(A[i]);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
    int h[10];
    int i, j;
    int M, idx;
    char buf[8];
     
    for(j = 0; j < 10; j++) {
        fgets(buf, 8, stdin);
        h[j] = strtol(buf, NULL, 10);
    }
 
    for(i = 0; i < 3; i++) {
        M = 0;
        for(j = 0; j < 10; j++) {
            if (h[j] > M) {
                M = h[j];
                idx = j;
            }
        }
        printf("%d\n", M);
        h[idx] = 0;
    }
    return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int a, b, c, d; cin >> a >> b >> c >> d;
    rep(i, 201) {
        if (i%2 == 0) c -= b;
        else a -= d;
        if (c<=0) {
            puts("Yes");
            return 0;
        }
        if (a<=0) {
            puts("No");
            return 0;
        }
    }
}

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

using namespace std;

typedef long long int64;

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

  int64 t = 1ll;
  int64 a = 1ll;
  // cout << t << " " <<  a << endl;
  for (int i = 0; i < N; ++i) {
    int64 tmp = max((t + T[i] - 1) / T[i],
		    (a + A[i] - 1) / A[i]);

    a = tmp * A[i];
    t = tmp * T[i];
  }

  int64 ans = t + a;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split(' '))
X = sorted(list(map(int,(input().split(' ')))))
max = max(X)
min = min(X)
Y = list()
for i in range(0,M-1):
  Y.append(X[i+1] - X[i])
  
Y.sort(reverse=True)
print(max-min-sum(Y[0:N-1]))
  


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    int x;
    cin >> x;
    if (x >= 30){
        cout << "Yes" << endl; 
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

    int price = 700;
    if(s[0] == 'o') price += 100;
    if(s[1] == 'o') price += 100;
    if(s[2] == 'o') price += 100;

    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char c = sc.next().charAt(0);
    if(c >= 'A' && c <= 'Z'){
      System.out.println("A");
    } else {
      System.out.println("a");
    }
  }
}

Measured memory_bytes: 35676
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>

using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll making_base(ll a, ll b) {
	ll  r, x, tmp;

	


	x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return x / b;

}


int main()
{
	ll n, m;
	cin >> n >> m;
	
	string s,t;
	cin >> s >> t;
	if (m > n) {
		using std::swap;
		swap(n, m);
		swap(s, t);
	}
	ll base = making_base(n, m);
	ll up_one = base / m;
	ll down_one = base / n;
	
	if (s[0] != t[0]) {
		cout << -1 << endl;
		return 0;
	}
	for (ll i = 1; i*up_one < n; i++) {
		/*for (int j = 2; j < m; i++) {
			if ((i - 1)*m == (j - 1)*n) {
				if (s[n - 1] == t[m - 1]){
					if (i + 1 == n) {

					}
					continue;
				}
				else {
					cout << -1 << endl;
					return 0;
				}
			}
		}*/
		//cout << s[(up_one)*i] << " " << t[(down_one)*i] << endl;
		if (s[(up_one)*i] != t[(down_one)*i]) {
			cout << -1 << endl;
			return 0;
		}


	}
	
	cout << base << endl;


}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> point;

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

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

  int a, b; cin >> a >> b;
  string sol1 = "", sol2 = "";
  REP(i, a)
    sol1 += char(b + '0');
  REP(i, b)
    sol2 += char(a + '0');
  cout << min(sol1, sol2);
}


Measured memory_bytes: 256
def main():
    N = int(input())
    cnt = [[0] * 10 for i in range(10)]
    for n in range(1, N + 1):
        cnt[int(str(n)[0])][int(str(n)[-1])] += 1

    ans = 0
    for i in range(10):
        for j in range(10):
            ans += cnt[i][j] * cnt[j][i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
const int N=2e5+5;
char c[N],d[N];
int n,i,x,y,z,m;
long long ans;
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	for(i=1;i<=n;++i)if(c[i]=='1')++x,ans+=x+1>>1;else ++y;
	for(i=1;i<=n;++i)if(c[i]=='1'){
		if(d[m]=='1')--m;else d[++m]='1';
	}else d[++m]='0';
	x=0;
	for(i=1;i<=y;++i)ans+=n-m>>1;
	for(i=1;i<=m;++i)if(d[i]=='1'){
		++x;
		ans+=(x&1?z>>1:z+1>>1)+y-z;
	}else ++z;
	printf("%lld\n",ans);
}

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

int main() {
    cout<<fixed<<setprecision(50);
    long double a, b, c;
    cin >> a >> b >> c;
    
    
    
    string ans = "No";
    if ((a + b + (2 * sqrt(a*b))) < c) ans = "Yes";
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	string s,t;
	cin >>s>>t;
	string ans="Yes";
	int n,m;
	n=s.length();
	m=t.length();
	if(n+1!=m)ans="No";
	rep(i,n){
		if (s[i]!=t[i]){
			ans="No";
			break;
		}
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//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")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:i64);
    let mut N:i64 = N;
    let mut ans = i64::max_value();
    while N >= 100{
        ans = min(ans,(753-N%1000).abs());
        N /= 10;
    }
    print!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll x = n % k;
    x = min(x, k - x);
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 20000;

int main()
{
	vector<int> able(MAX + 1), is(MAX + 1, 1);
	for (int i = 0; i < 150; i++) {
		for (int j = 0; j < 150; j++) {
			int d = i * i + j * j;
			if (d <= MAX) {
				able[d] = 1;
			}
		}
	}
	for (int i = 2; i <= MAX; i++) {
		if (able[i] && is[i]) {
			for (int j = 2; i * j <= MAX; j++) {
				if (able[j]) {
					is[i * j] = 0;
				}
			}
		}
	}
	int q, m, n;
	cin >> q;
	while (q--) {
		cin >> m >> n;
		cout << (is[m * m + n * n] ? 'P' : 'C') << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 100000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
double PI = atan2(0, -1);

int main () {
    int N;
    cin >> N;
	vi L(N);
	rep(i,N) cin >> L[i];
	sort(L.begin(), L.end());
	ll ans = 0;
	for (int a = 2; a < N; ++a)
		for (int b = 1; b < a; ++b) {
			auto c = upper_bound(L.begin(), L.begin() + b, L[a]-L[b]);
			int c1 = c - L.begin();
			ans += (b - c1);
		}
	cout  << ans  << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int res=0;
    res+=max(0,(4-a)*100000);
    res+=max(0,(4-b)*100000);
    if(a==1&&b==1) res+=400000;
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 384
import itertools

def solve(S):
    bit_list = list(itertools.product([0, 1], repeat=3))
    
    for pattern in bit_list:
        count = int(S[0])
        ans = S[0]
        for i in range(3):
            if pattern[i] == 0:
                count += int(S[i+1])
                ans += "+" + S[i+1]
            else:
                count -= int(S[i+1])
                ans += "-" + S[i+1]
        
        if count == 7:
            print(ans + "=7")
            break
    

if __name__ == '__main__':
    S = input()
    solve(S)

Measured memory_bytes: 3064
#include <stdio.h>
int Min(int a,int b){
    return a<b?a:b;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    char s[100001];
    scanf("%s",s);
    int arr[n];
    int l=0,r=0;
    for(int i=0;i<n;i++){
        arr[i]=-1;
    }int j=1;
    if(s[0]=='L'){
        arr[0]=0;
        l++;
    }else{
        arr[0]=1;
        r++;
    }
    
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1])continue;
        if(s[i]=='R'){
            arr[j]=1;
            r++;
        }else{
            arr[j]=0;
            l++;
        } 
        j++;
    }
    if(Min(r,l)<=k){
        printf("%d",n-1);
        return 0;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1])ans++;
    }
    printf("%d",ans+2*k);
    
    return 0;
    
}

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

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (N <= K) {
		cout << N * X << endl;
	}
	else {
		cout << K * X + (N - K) * Y << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int w, i = 0;
    int x1, x2, y, n;
    scanf("%d",&w);
    scanf("%d",&n);
    int array [30] = {0};
    for (i = 0; i < w; i++) {
        array[i] = i + 1;
    }
    for (i = 0; i < n; i++) {
        scanf("%d,%d", &x1, &x2);
        y = array [x1-1];
        array [x1-1] = array [x2-1];
        array [x2-1] = y;
    }
    for (i = 0; i < w; i++) {
        printf("%d\n",array[i]);
    }
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

string to_bin(ll x) {
    if (x <= 1) return to_string(x);
    return to_bin(x / 2) + to_string(x % 2);
}
/*

string format_bin(string bin) {
    reverse(bin.begin(), bin.end());
    while (bin.size() < 31) {
        bin.push_back('0');
    }
    reverse(bin.begin(), bin.end());
    return bin;
}
*/

#define ALL(a) (a).begin(), (a).end()

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

    vector<ll> A(N), B(N);

    ll ans1 = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        if ((A[i] | K) == K) ans1 += B[i];
    }

    ll ans2 = 0;
    for (int i = 0; i < 32; i++) {
        if (((K >> i) & 1) != 1) continue;
        ll mask = 0,
           mask2 = 0;
        for (int j = 0; j < 32; j++) {
            mask <<= 1;
            mask2 <<= 1;
            if (j < 31 - i) {
                mask += 1;
            }
            if (j <= 31 - i) {
                mask2 += 1;
            }
        }
        ll mask3 = mask & K;

        // cerr << "i: " << i << " " << to_bin(mask3) << endl;

        ll cost = 0;
        for (int j = 0; j < N; j++) {
            if (((A[j] & mask2) | mask3) == mask3) cost += B[j];

            // cerr << "A[" << j << "]&mask" << to_bin(A[j] & mask2) << endl;
        }
        ans2 = max(ans2, cost);
    }

    cout << max(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 1792
q = int(input())

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

def bubblesort(ary):
    cnt = 0
    for i in range(q):
        for j in range(q-1, i, -1):
            if ary[j] < ary[j-1]:
                ary[j-1], ary[j] = ary[j], ary[j-1]
                cnt += 1
    return (ary, cnt)

ary, cnt = bubblesort(sort1)
print(" ".join(map(str, ary)))
print(cnt)

Measured memory_bytes: 7744