akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 5555;
long long dp[N][N];

void remin(long long& x, long long y) {
	if (x == -1 || x > y) {
		x = y;
	}
}

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt(), cost_r = nxt(), cost_l = nxt();
	vector<int> p(n), q(n);
	for (int i = 0; i < n; ++i) {
		p[i] = nxt() - 1;
		q[p[i]] = i;
	}

	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i < n; ++i) {
		int num_less = 0, num_greater = 0;
		for (int j = 0; j < i; ++j) {
			if (p[j] < p[i]) {
				++num_less;
			} else {
				++num_greater;
			}
		}
		remin(dp[i][i], 1ll * cost_r * num_greater + 1ll * cost_l * num_less);
		for (int j = 0; j < i; ++j) {
			if (dp[i - 1][j] == -1) {
				continue;
			}
			if (p[i] < p[j]) {
				remin(dp[i][j], dp[i - 1][j] + cost_l);
			} else {
				remin(dp[i][j], dp[i - 1][j] + cost_r);
				remin(dp[i][i], dp[i - 1][j]);
			}
		}
	}

	long long ans = -1;
	for (int i = 0; i < n; ++i) {
		if (dp[n - 1][i] > -1) {
			remin(ans, dp[n - 1][i]);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 241408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using pdd = pair<double, double>;

template <typename T, typename F = std::plus<T>>
class fenwick_tree {
public:
	using value_type = T;
private:
	std::vector<T> m_data;
	F m_func;
public:
	fenwick_tree()
		: m_data(1)
		, m_func()
	{ }
	explicit fenwick_tree(
		size_t n,
		const value_type& x = value_type(),
		const F& f = F())
		: m_data(n + 1)
		, m_func(f)
	{
		m_data[0] = value_type();
		for(size_t i = 1; i <= n; ++i){
			m_data[i] = x;
			for(size_t j = i; (j & 1) == 0u; j >>= 1){
				m_data[i] = m_func(m_data[j], m_data[i]);
			}
		}
	}
	size_t size() const {
		return m_data.size() - 1;
	}
	value_type query(size_t i) const {
		value_type s = m_data[i];
		for(i -= i & -i; i > 0; i -= i & -i){
			s = m_func(m_data[i], s);
		}
		return s;
	}
	void modify(size_t i, const value_type& x){
		const auto n = m_data.size();
		for(++i; i < n; i += i & -i){
			m_data[i] = m_func(m_data[i], x);
		}
	}
};

int count_inversion(const std::vector<double>& a){
	const int n = a.size();
	vector<double> b(a);
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	fenwick_tree<int> ft(b.size());
	int answer = 0;
	for(int i = 0; i < n; ++i){
		const int k = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		answer += i - ft.query(k);
		ft.modify(k, 1);
	}
	return answer;
}

double solve(
	const vector<double>& a,
	const vector<double>& b,
	const vector<double>& c)
{
	const int n = a.size();
	const int nc = n * (n - 1) / 2;
	vector<double> ca(n), ba(n);
	for(int i = 0; i < n; ++i){
		ca[i] = c[i] / a[i];
		ba[i] = b[i] / a[i];
	}
	double ly = -1e9, ry = 1e9;
	for(int iter = 0; iter < 200; ++iter){
		const double y = (ly + ry) * 0.5;
		vector<pdd> v(n);
		for(int i = 0; i < n; ++i){
			const double x = ca[i] - ba[i] * y; //(c[i] - b[i] * y) / a[i];
			const double t = -ba[i]; //-b[i] / a[i];
			v[i] = pdd(x, t);
		}
		sort(v.begin(), v.end());
		vector<double> w(n);
		for(int i = 0; i < n; ++i){ w[i] = v[i].second; }
		const int inv = count_inversion(w);
		if(inv > nc / 2){
			ly = y;
		}else{
			ry = y;
		}
	}
	return ly;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	int n;
	cin >> n;
	vector<double> a(n), b(n), c(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	const double y = solve(a, b, c);
	const double x = solve(b, a, c);
	cout << x << " " << y << endl;
	return 0;
}



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

int main()
{
  int n,i,j;
  char w[101][11];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",w[i]);
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(w[i],w[j])==0){
	printf("No\n");
	return 0;
      }
    }
  }

  for(i=0;i<n-1;i++){
    if(w[i][strlen(w[i])-1]!=w[i+1][0]){
	printf("No\n");
	return 0;
      }
  }
     
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "Yes\n"
#define N cout << "No\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)

long long mod = 1000000007 , ans = 1 ;


int prime[1000010] ;
void fun()
{
     prime[1] = 1 ;
	for (int i = 2; i < 1000001; i++)
	{
		if (prime[i] == 0)
		{
			for (int j = i ; j < 1000001; j += i)
			{
				prime[j] = i ;
			}
		}
	}
}
bool p[1000001] ;
int gcd(int a,int b)
{
     if(b == 0)
     {
          return a ;
     }
     return gcd(b,a%b) ;
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     fun() ;
     int n , m , a[1000010] = {0} ;
     cin >> n ;
     R(i,n)
     {
          cin >> a[i] ;
          if(i > 0)
          {
               m = gcd(a[i],m) ;
          }
          else
          {
               m = a[i] ;
          }
     }
     if(m > 1)
     {
          cout << "not coprime\n" ;
     }
     else
     {
          int f = 0 ;
          R(i,n)
          {
               while(a[i] > 1)
               {
                    int x = prime[a[i]] ;
                    while(1)
                    {
                         if(a[i]%x == 0)
                         {
                              a[i] /= x ;
                         }
                         else
                         {
                              break ;
                         }
                    }
                    if(p[x] != 0)
                    {
                         f = 1 ;
                         break ;
                    }
                    else
                    {
                         p[x] = 1 ;
                    }
               }
          }
          if(f == 0)
          {
               cout << "pairwise coprime\n" ;
          }
          else
          {
               cout << "setwise coprime\n" ;
          }
     }
}


Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    rep(i,1000){
        int p = 0;
        
        int abc[3];
        abc[0] = i/100;
        abc[1] = (i/10)%10;
        abc[2] = i%10;

        int tmp=0;
        int count=0;
        bool b=false;
        while(p<n){
            if((s[p]-'0')==abc[tmp]){
                count++;
                tmp++;
            }
            p++;
            if(tmp==3){
                b = true;
                break;
            }
        }
        if(b) ans++;
        //if(b) cout << i << endl;

    }

    cout << ans << endl;

}

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


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

void step(std::string& s) {
    int n = s.size();

    if (s[0] == 'A') {
        s[0] = 'B';
        return;
    }
    else {
        s[0] = 'A';
    }

    int pos = 1; int dir = 1;

    while (pos != 0 && pos != n) {
        if (dir == 1) {
            if (s[pos] == 'A') {
                s[pos] = 'B';
                dir = -1;
            }
            else {
                s[pos] = 'A';
                pos++;
            }
        }
        else {
            if (s[pos-1] == 'A') {
                s[pos-1] = 'B';
                dir = 1;
            }
            else {
                s[pos] = 'A';
                pos--;
            }
        }
    }
}

char flip(char c) {
    if (c == 'A') return 'B';
    else return 'A';
}

int n, k;

string s, res, suffix;

int main() {
    cin >> n >> k >> s;

    int i = 0; bool flipped = false;

    while (i < n-1 && k > 0) {
        if ((s[i] == 'A' && !flipped) || (s[i] == 'B' && flipped)) {
            s[i] = flip(s[i]);
        }
        else {
            i++;
            flipped = !flipped;

            if (suffix.size() == 0) {
                suffix = 'A';
            }
            else {
                suffix += flip(suffix[suffix.size()-1]);
            }
        }
        k--;
    }

    bool flipFirst = (k % 2 && n % 2);
    bool bFirst = (k > 0 && n % 2 == 0);

    for (int j = i; j < n; j++) {
        res += (flipped ? flip(s[j]) : s[j]);
    }

    reverse(suffix.begin(), suffix.end());
    res += suffix;

    if (flipFirst) {
        res[0] = flip(res[0]);
    }
    if (bFirst) {
        res[0] = 'B';
    }

    cout << res << "\n";

    /*
    cin >> s;

    FORN(i, 20) {
        cout << s << endl;
        step(s);
    }
    */
    
    return 0;
}


Measured memory_bytes: 1284
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int index = dp[n][m]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   }
   cout<<lcs;
}

Measured memory_bytes: 38784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define bit(k) (1LL<<(k))
typedef long long ll;

int main() {

    ll M, K;
    cin >> M >> K;
    ll K_max = bit(M) - 1;
    if(K > K_max){
        cout << -1 << endl;
        return 0;
    }
    if(K == 0){
        rep(i,bit(M)){
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    if(K == 1 && M == 1){
        cout << -1 << endl;
        return 0;
    }
    // 1 <= K <= Kmax
    deque<int> ans;
    ans.push_back(K);
    for(int i = 1; i < bit(M); i++){
        if(i == K)continue;
        ans.push_back(i);
        ans.push_front(i);
    }
    ans.push_back(0);
    ans.push_back(K);
    ans.push_back(0);
    for(auto a: ans){
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4676
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
	int N,M;cin >> N >> M;
	vector<pair<int, int>> A(N);//配列の宣言
	vector<pair<int, int>> B(M);
for(int i = 0; i < N ; i++){
	int a,b;
  cin >> a >> b;
  A[i] = make_pair(a,b);//配列型のpairに代入
}
for(int i = 0; i < M; i++){
	int a,b;
  cin >> a >> b;
  B[i] = make_pair(a,b);//配列型のpairに代入
}
int count , ans,cl;
ans = 1000000000;
for(int i = 0; i < N; i++){
	for(int j = 0; j < M;j++){
		count = abs(A[i].first - B[j].first) + abs(A[i].second - B[j].second);
		if(ans > count){
		ans = min(ans,count);
		cl = j+1;
		}
	}
	cout << cl << endl;
	ans = 1000000000; 
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<int> v[100055],v1[100055];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[111010];
int o[300330];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,-1,1,-1,1},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[1130],u1[1111];
int j[222210];
stack<int> s;
queue<long long> q;
//priority_queue<P> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,int > p;
//list<int> l;
string r;
//char r[310][333];
deque<int> de;

bool as(P a,P b)
{
   // if(a.x!=b.x)
        return a.x<b.x;
    //return a.y>b.y;
}

int f(int a)
{
    if((a%4==0&&a%100)||a%400==0) return 1;
    return 0;
}

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    if((long long)b*c<a||b+c>a+1)
    {
        puts("-1");
        return 0;
    }
    for(int t=1;t<=a;o[t]=t,t++);
    d=a;
    for(;(long long)b*(c-1)>=d;c--,d--);
    for(int t=1;t<=d;t+=b)
    {
        for(int w=t,h=min(d,t-1+b);w<h;w++,h--)
        swap(o[w],o[h]);
    }
    for(int t=a;t>0;t--)
        printf("%d ",o[t]);
}


Measured memory_bytes: 8448
while (num = gets.chomp.to_i) != 0
  ary = []
  num.times do
    tmp = gets.split.map(&:to_i)
    ary << tmp.push(tmp.inject(:+))
  end
  tmp = ary[0].zip(*ary[1..(num - 1)]).map {|item| item.inject(:+)}
  ary << tmp
  ary.each {|item| item.map! {|item2| item2.to_s.rjust(5)}}
  ary.each {|item| puts item.join}
end

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  while(n >= 1000){
    n -= 1000;
  }

  if(n != 0){
  cout << 1000 - n << endl;
  }
  else{
    cout << "0" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARangeFlipFindRoute solver = new ARangeFlipFindRoute();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARangeFlipFindRoute {
        int[][] a;
        int h;
        int w;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            h = in.nextInt();
            w = in.nextInt();
            a = new int[h + 1][w + 1];
            long dp[][] = new long[h + 1][w + 1];
            long dp2[][] = new long[h + 1][w + 1];
            for (int i = 0; i <= h; i++) {
                for (int j = 0; j <= w; j++) {
                    dp[i][j] = Integer.MAX_VALUE;
                    dp2[i][j] = Integer.MAX_VALUE;

                }
            }
            for (int i = 1; i <= h; i++) {
                String x = in.next();
                for (int j = 1; j <= w; j++) {
                    if (x.charAt(j - 1) == '.')
                        a[i][j] = 1;
                }
            }
//        dfs(0,0,1,0);
            dp[0][1] = 0;
            dp[1][0] = 0;
            a[0][1] = 1;
            a[1][0] = 1;
            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    if (a[i][j] != a[i - 1][j]) {
                        dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + 1);
                    } else {
                        dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
                    }
                    if (a[i][j] != a[i][j - 1]) {
                        dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + 1);
                    } else {
                        dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]);
                    }
                }
            }

            out.println((int) Math.ceil((double) dp[h][w] / 2));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <stdio.h>
#include<stdlib.h>
#define M 2000001
#define VM 10000

int main(){

  int C[VM+1],n,i,j;

  scanf("%d",&n);

  int A[n],B[n];
  for(i=0;i<=VM;i++){
    C[i] = 0;
}
  for(j=0;j<n;j++){
    scanf("%d",&A[j+1]);
    C[A[j+1]]++;
  }

  for(i=1;i<=VM;i++)C[i] = C[i] + C[i-1];

    for(j=1;j<=n;j++){
              B[C[A[j]]] = A[j];
              C[A[j]]--;
    }

for(i=1;i<=n;i++){
  if(i==n)printf("%d",B[i]);
  else printf("%d ",B[i]);
    }
 printf("\n");

  return 0;
}


Measured memory_bytes: 17464
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int q(const void *a,const void *b)
{
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int h,w,a[500][501],t[500][501],s=0,i,j;
    scanf("%d%d",&h,&w);
    for(i=0;i<h;++i){
        for(j=0;j<w;++j){
            scanf("%d",&a[i][j]);
            t[i][j]=a[i][j];
        }
    }
    //  計測
    for(i=0;i<h;++i){
        for(j=0;j<w;++j){
            if(t[i][j]%2){
                /*if(i-1>-1&&a[i-1][j]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i,j+1);
                    ++a[i-1][j];
                }*/
                /*else if(j-1>-1&&a[i][j-1]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i+1,j);
                    ++a[i][j-1];
                }*/
                if(w>j+1&&t[i][j+1]%2){
                    ++s;
                    ++t[i][j+1];
                }
                else if(h>i+1&&t[i+1][j]%2){
                    ++s;
                    ++t[i+1][j];
                }
                else{
                    if(w>j+1){
                        ++s;
                        ++t[i][j+1];
                    }
                    else if(h>i+1){
                        ++s;
                        ++t[i+1][j];
                    }
                }
            }
        }
    }
    printf("%d\n",s);
    //
    for(i=0;i<h;++i){
        for(j=0;j<w;++j){
            if(a[i][j]%2){
                /*if(i-1>-1&&a[i-1][j]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i,j+1);
                    ++a[i-1][j];
                }*/
                /*else if(j-1>-1&&a[i][j-1]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i+1,j);
                    ++a[i][j-1];
                }*/
                if(w>j+1&&a[i][j+1]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i+1,j+2);
                    ++a[i][j+1];
                }
                else if(h>i+1&&a[i+1][j]%2){
                    printf("%d %d %d %d\n",i+1,j+1,i+2,j+1);
                    ++a[i+1][j];
                }
                else{
                    if(w>j+1){
                        printf("%d %d %d %d\n",i+1,j+1,i+1,j+2);
                        ++a[i][j+1];
                    }
                    else if(h>i+1){
                        printf("%d %d %d %d\n",i+1,j+1,i+2,j+1);
                        ++a[i+1][j];
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int h,w,k;
ll dp[10][110];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w>>k;
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            rep(l,1<<(w-1)){
                bool can =true;
                ll c=j;
                rep(t,w-1){
                    if(l>>t&1){
                        if(t&&l>>(t-1)&1){
                            can =false;break;
                        }
                        if(t==j-1) c=j-1;
                        else if(t==j) c=j+1;
                    }
                }
                if(can){
                    dp[c][i+1]+=dp[j][i];
                    dp[c][i+1]%=MOD;
                }
            }
        }
    }
    cout<<dp[k-1][h]<<endl;
    return 0;
}

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

using namespace std;
typedef long long Int;
Int n, m, res = 1LL << 30;
Int a[324][324];
Int cnt[324];
int main(){
  cin >> n>>m;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < m;j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0;i < m;i++){
    int mx = 0;
    for(int j = 0;j < n;j++){
      cnt[a[j][0]]++;
      if(cnt[mx] < cnt[a[j][0]])mx = a[j][0];
    }
    res = min(res, cnt[mx]);
    for(int j = 0;j <= m;j++)cnt[j] = 0;
    for(int j = 0;j < n;j++){
      int k = 0;
      while(a[j][k] != mx)k++;
      for(k++;k < m;k++){
	a[j][k-1] = a[j][k];
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int main(){
    ll a,b,i;
    while(cin>>a>>b){
    	ll x,y,max_x=-1,max_y=1000030;
    	for(i=0;i<b;i++){
    		cin>>x>>y;
    		if(x>max_x)max_x=x;
    		if(y<max_y)max_y=y;
		}
		//cout<<max_x<<" "<<max_y<<endl;
		ll sum=max_y-max_x+1;
		if(sum<=0){
			cout<<"0"<<endl;
		}
		else{
			cout<<sum<<endl;
		}
	}
}

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

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}

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

void Main()
{
    long int n, k, t;
    cin >> n >> k;
    long int m = 1000000000000000000;
    if(k < n){
        t = n / k;
        n = n - (k * t);
        m = min(m, n);
    }
    n = abs(k - n);
    m = min(m, n);
    n = abs(k - n);
    m = min(m, n);
    cout << m << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 300003, M = N << 1;

int n, m;
int a[N], b[N];
char s[N];

int main()
{
	//File("");
	n = gi();
    scanf("%s", s + 1);
    if (strlen(s + 1) <= n) cout << s + 1;
    else 
    {
        for (int i = 1; i <= n; i+=1)
            printf("%c", s[i]);
        cout << "...";
    }
	return 0;
}

Measured memory_bytes: 3768
fun main(args: Array<String>) {
    val (W, H, x, y, r) = readLine()!!.split(" ").map { it.toInt() }
    
    when {
        x - r < 0 || x + r > W -> println("No")
        y - r < 0 || y + r > H -> println("No")
        else -> println("Yes")
    }
}



Measured memory_bytes: 32064
import sys
import collections

# input処理を高速化する
input = sys.stdin.readline

def chmax(a, b):
    """ 最大値を返す関数 """
    if a >= b:
        return a
    return b

def main():
    # 入力
    N, M = map(int, input().split())
    # 隣接関係は隣接リストで管理する
    lst_edge = [[] for _ in range(N)]
    # 各頂点の入力辺の本数
    deg = [0] * N
    for _ in range(M):
        x, y = map(int, input().split())
        # 最初のindexをゼロにする
        lst_edge[x-1].append(y-1)
        deg[y-1] += 1

    # 入力辺を持たない頂点をqueueに入れる
    que = collections.deque()
    for v in range(N):
        if deg[v] == 0:
            que.append(v)

    # 各頂点の最初に入力辺を持たなかった点からの距離
    dp = [0] * N

    while que:
        v = que.popleft()
        lst_nv = lst_edge[v]
        for nv in lst_nv:
            # エッジ(v, nv)をグラフから削除する
            deg[nv] -= 1
            if deg[nv] == 0:
                # エッジがなくなったことで、入力辺がなくなったらqueueに入れる
                que.append(nv)
                # 最初に入力辺を持たなかった点からの距離
                dp[nv] = chmax(dp[nv], dp[v] + 1)

    print(max(dp))

main()


Measured memory_bytes: 23052
#!/usr/bin/env python3
import sys

def solve(N: int, X: "List[int]"):
    p = round(sum(X) / N)
    print(sum([(x-p)**2 for x in X]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
#define MOD 1000000007
using namespace std;

int main(){
    char c;
    cin >> c;
    switch (c) {
        case 'A':
            cout << "T" << endl;
            break;
        case 'T':
            cout << "A" << endl;
            break;
        case 'C':
            cout << "G" << endl;
            break;
        case 'G':
            cout << "C" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	string S;
	cin >> S;

	auto dp = make_vec(N + 1, 4, 1000, char(0));//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 100; k++) {
				if (!dp[i][j][k]) {
					continue;
				}
				//i文字目を選択する場合
				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = true;
			
				//i文字目を選択しない場合
				dp[i + 1][j][k] = true;
			}
		}
	}

	Int ans = 0;
	vector<bool> seen(1000,false);
	for (Int i = 1; i <= N; i++) {
		for (Int k = 0; k < 1000; k++) {
			if (dp[i][3][k]) {
				if (seen[k]) {
					continue;
				}
				ans++;
				seen[k] = true;
			}
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 122368
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
XY = np.array(read().split(), np.int64)

X = XY[::2]
Y = XY[1::2]

dx = X[None, :] - X[:, None]
dy = Y[None, :] - Y[:, None]

dist_mat = (dx * dx + dy * dy) ** .5
ans = dist_mat.sum() / N

print(ans)


Measured memory_bytes: 12504
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  int w[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }

  int sum[n];
  sum[0] = w[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i-1] + w[i];
  }

  int min = sum[n-1];
  int dif;
  for (int i = 1; i < n; i++) {
    dif = (sum[n-1]-sum[i-1]) - sum[i-1];
    if (dif < 0) {
      dif = -dif;
    }
    if (dif < min) {
      min = dif;
    }
  }
  printf("%d\n", min);

  return 0;
}

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(n+1,0);
    int t;
    for (int i = 0; i < m; i++){
        cin >> t;
        a[t] = 1;
    }

    int sum1 = 0;
    for (int i = x; i < n + 1; i++){
        if (a[i] == 1){
            sum1++;
        }
    }

    int sum2 = 0;
    for (int i = x; i > 0; i--){
        if (a[i] == 1){
            sum2++;
        }
    }

    cout << min(sum1,sum2) << endl;
}

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

ll solve() {
    ll N, H;
    cin >> H >> N;
    vector<ll> A(N);
    ll s = 0, a;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s += a;
    }

    return s >= H;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  string S;
  cin >>S;
  int min=999;
  int num=S.length();
  for(int i=0; i<num-2;i++){
    if(abs(753-(100*(S[i]-'0')+10*(S[i+1]-'0')+S[i+2]-'0'))<min)
    min=abs(753-(100*(S[i]-'0')+10*(S[i+1]-'0')+S[i+2]-'0'));
  }
  cout<< min;
}


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

using namespace std;

typedef long long ll;

int solve(int a[], int digit){
    int dp[digit][11], ans = 0;
    fill(dp[0], dp[digit-1]+11, 0);
    dp[0][a[0]]++;
    for(int i=0;i<digit-1;i++){
        for(int j=0;j<11;j++){
            if(!dp[i][j]) continue;
            dp[i+1][(10*j+a[i+1])%11] += dp[i][j];
        }
        if(a[i+1]) dp[i+1][a[i+1]]++;
        ans += dp[i+1][0];
    }
    return ans;
}

int main(){
    char s[80001];
    while(scanf("%s", s)){
        if(s[0] == '0') break;
        int a[80001], digit = 0;
        while('0' <= s[digit] && s[digit] <= '9'){
            a[digit] = s[digit] - '0';
            digit++;
        }
        cout << solve(a, digit) << endl;
    }
}


Measured memory_bytes: 6940
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key

#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    vector<string>v,v1;
    map<string,int>mp;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	v1.pb(s);
    	mp[s]++;
	}
	int cnt=-1;
	for(int i=0;i<v1.size();i++)
	{
		if(mp[v1[i]]>cnt) cnt=mp[v1[i]];
	}
	for(int i=0;i<v1.size();i++)
	{
		if(mp[v1[i]]==cnt)
		{
			v.pb(v1[i]);
			mp[v1[i]]=0;
		}
	}
	sort(all(v));
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<endl;
	}
    return 0;
}


Measured memory_bytes: 27120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

class DisjointSet{
public:
  int N;
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int n):N(n),rank(n),p(n),sz(n){
    for(int i=0;i<N;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return leader(x)==leader(y);
  }
 
  void unite(int x,int y){
    if(same(x,y)) return;
    link(leader(x),leader(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        ++rank[y];
      }
    }
  }
 
  int leader(int x){
    if(x!=p[x]) p[x]=leader(p[x]);
    return p[x];
  }
 
  int size(int x){
    return sz[leader(x)];
  }
};

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

  int N,Q;
  cin>>N>>Q;
  
  DisjointSet dsu(N);
  rep(q,Q){
      int T,A,B;
      cin>>T>>A>>B;

      if(T==0) dsu.unite(A,B);
      else{
          if(dsu.same(A,B)) cout<<"1"<<"\n";
          else cout<<"0"<<"\n";
      }
  }

  return 0;
}


Measured memory_bytes: 5416
import java.util.*;
import java.io.*;
public class Main {
    public static int mod = 1000000007;
    public static long dp[][][] ;
    public static long solve(String k , int D , int pos, int d , int tight){
        if(dp[pos][d][tight] != -1){
            return dp[pos][d][tight];
        }
        int ub = (tight == 1) ? (k.charAt(pos)-'0') : 9;

        if(pos == k.length()-1){
            long ans = 0;
            for(int x = 0 ; x <= ub ; x++)
                if(x%D == d) ans++;
            ans = ans;
            return ans;
        }

        long ans = 0;
        for(int x = 0 ; x <= ub ; x++){
            int forw = ((tight == 1) && (x == ub)) ? 1 : 0;
            ans = (ans + solve(k , D , pos+1 , (d+D-(x%D))%D , forw ))%mod;
        }
        return dp[pos][d][tight] = ans;
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        String k = s.next();
        int D = s.nextInt();
        dp = new long[k.length() + 1][101][2];
        for(int i = 0 ; i <= k.length() ; i++){
            for(int j = 0 ; j <= 100 ; j++){
                for(int l = 0 ; l <= 1 ; l++){
                    dp[i][j][l] = -1;
                }
            }
        }
        long ans = ( mod + (solve(k , D , 0 , 0 , 1)-1)%mod) % mod;
        System.out.println(ans);
    }
}

Measured memory_bytes: 90244
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll x;
    cin >> x;
    ll re = x/500;
    re*=1000;
    re += 5*((x%500)/5);
    g(re);
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
    //cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

main()
{	
	#ifndef ONLINE_JUDGE
//		freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
//		freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
	#endif
	
	clock_t clk = clock();
	
	int n, k;
	cin >> n >> k;
	
	int a[n];
	int l;
	
	rep(i, 0, n) {
		cin >> a[i];
		if(a[i] == 1) {
			l = i;
		}
	}
	
	int ans = n;
	rep(m, max(0, l-(k-1)), min(n-1, l+(k-1))+1) {
		ans = min(ans, (int)ceil(m / double(k-1)) + (int)ceil((n-m-k) / double(k-1)) + 1);
	}
	
	cout << ans << '\n';
	
	cerr << double(clock() - clk) * 1000.0 / cps << '\n';
}








Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int tmp;
        int a=scan.nextInt();
        int b=scan.nextInt();
        if(b<a){
            tmp=b;
            b=a;
            a=tmp;
        }
        int c=scan.nextInt();
        if(c<a){
            tmp=c;
            c=b;
            b=a;
            a=tmp;
        }else if(c<b){
            tmp=c;
            c=b;
            b=tmp;
        }
        System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()



void build(ll a1[], ll a2[], int m, vector<ll> &v){
    for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
            v.push_back(a1[i]+a2[j]);
        }
    }
    return;
}

int main() {
    ll N, V, A[1005], B[1005], C[1005], D[1005], cnt=0;
    vector<ll> X, Y;
    cin >> N >> V;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];
    for(int i=0; i<N; i++) cin >> D[i];
    build(A,B,N,X);
    build(C,D,N,Y);
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    for(auto xi : X){
        ll lo = lower_bound(Y.begin(), Y.end(), V-xi) - Y.begin();
        ll hi = upper_bound(Y.begin(), Y.end(), V-xi) - Y.begin();
        cnt += hi - lo;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 23044
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int k,t;
    cin>>k>>t;
    int a[t];
    int max=0;
    int sum=0;
    for(int i=0;i<t;i++){
        cin>>a[i];
        if(max<a[i]){
            max=a[i];
        }
    }
    for(int i=0;i<t;i++){
        sum+=a[i];
    }
    if(max-1>sum-max){
        cout<<max-1-sum+max<<endl;
    }else{
        cout<<"0"<<endl;
    }
    return 0;
}


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

int main(int argc, char **argv)
{
    std::string S, T;
    std::cin >> S >> T;
    
    if(S.size() + 1 != T.size()){
        std::cout << "No" << std::endl;
        return 0;
    }
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

const int N = 1e5+10;

int a[N],ans=0;

int main() {
    int n,k;scanf("%d%d",&n,&k);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    sort(a + 1, a + n + 1);
    for(int i = 1;i <= n;i++) {
        if(i == n && a[i] == k) ans ++;
        else if(i < n){
            if(a[i] <= k){
               k -= a[i];
               ans ++;
            }
        }
        else break;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79768
#include <bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
typedef long long ll;
#define mod 998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 1e15

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p) 
{ 
    return binpow(n, p-2, p); 
} 
	
					
int main()
{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		ll n,p;
		cin>>n>>p;
		string s;
		cin>>s;
		ll c2=0,c5=0;
		for(ll i=0;i<n;i++)
		{
			ll num=s[i]-'0';
			if(num%2==0)
				c2+=(i+1);
			if(num%5==0)
				c5+=(i+1);
		}
		if(p==2)
		{
			cout<<c2;
			exit(0);
		}
		else if(p==5)
		{
			cout<<c5;
			exit(0);
		}
		ll rem=0;
		map<ll,ll> m;
		ll ans=0;
		m[0]=1;
		for(ll i=n-1;i>=0;i--)
		{
			rem+=(s[i]-'0')*binpow(10LL,n-1-i,p);
			rem%=p;
			ans+=m[rem];
			m[rem]++;
		}
		cout<<ans;
		 
}


Measured memory_bytes: 1044
mod=998244353

class Combination:
	def __init__(self,size):
		self.size = size + 2
		self.fact = [1, 1] + [0] * size
		self.factInv = [1, 1] + [0] * size
		self.inv = [0, 1] + [0] * size
		
		for i in range(2, self.size):
			self.fact[i] = self.fact[i - 1] * i % mod
			self.inv[i] = -self.inv[mod % i] * (mod//i) % mod
			self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod
			
	def npk(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * self.factInv[n - k] % mod
		
	def nck(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * (self.factInv[k] * self.factInv[n - k] % mod) % mod
		
	def nhk(self,n,k):
		return self.nck(n + k - 1, n - 1)


n,m,k=map(int,input().split())

comb=Combination(n+k)
res=0

for i in range(k+1):
	res+=((comb.nhk(n-i,i))*m)%mod*(pow(m-1,n-1-i,mod))
	res%=mod
print(res)

Measured memory_bytes: 59260