akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	char[][] map;
	boolean[][] removed;
	int ans;
	int type='Z'-'A'+1;
	LinkedList<P> pList;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		map=new char[n][];
		for(int j=0; j<n; j++){
			map[j]=sc.next().toCharArray();
		}

		@SuppressWarnings("unchecked")
		LinkedList<P>[] lists=new LinkedList[type];
		for(int i=0; i<type; i++){
			lists[i]=new LinkedList<P>();
		}
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(map[j][i]!='.'){
					lists[map[j][i]-'A'].add(new P(i, j));
				}
			}
		}
		
		pList=new LinkedList<P>();
		for(int i=0; i<type; i++){
			if(lists[i].size()==2){
				P p1=lists[i].get(0);
				P p2=lists[i].get(1);
				if(p1.x==p2.x){
					for(int y=min(p1.y, p2.y)+1; y<max(p1.y, p2.y); y++){
						pList.add(new P(p1.x, y));
					}
				}else if(p1.y==p2.y){
					for(int x=min(p1.x, p2.x)+1; x<max(p1.x, p2.x); x++){
						pList.add(new P(x, p1.y));
					}
				}else{
					pList.add(new P(p1.x, p2.y));
					pList.add(new P(p2.x, p1.y));
				}
			}
		}

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

		ans=0;
		removed=new boolean[n][m];
		for(;;){
			int s=0;
			for(P p : pList){
				if(map[p.y][p.x]=='.'||removed[p.y][p.x]){}else{
					continue;
				}
				P[] ps=new P[4];
				for(int k=0; k<4; k++){
					ps[k]=get(p.x, p.y, dx[k], dy[k]);
				}
				for(int j=0; j<4; j++){
					for(int i=j+1; i<4; i++){
						if(ps[i]!=null&&ps[j]!=null
								&&map[ps[i].y][ps[i].x]==map[ps[j].y][ps[j].x]){
							removed[ps[i].y][ps[i].x]=true;
							removed[ps[j].y][ps[j].x]=true;
							s+=2;
						}
					}
				}
			}
			ans+=s;
			if(s==0){
				break;
			}
		}
		println(ans+"");
	}

	P get(int x, int y, int dx, int dy){
		for(x+=dx, y+=dy; x>=0&&x<m&&y>=0&&y<n; x+=dx, y+=dy){
			if(!removed[y][x]&&map[y][x]!='.'){
				return new P(x, y);
			}
		}
		return null;
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}

		@Override
		public String toString(){
			return "("+x+","+y+")";
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

int N, A, B;

void Solve(int s, int t, int mask) {
    if (__builtin_popcount(mask) == 1) {
        printf("%d %d ", s, t);
        return ;
    }

    int diff = 1, add = 1;
    while (!(diff & mask) || !((s ^ t) & diff)) diff <<= 1;
    while (!(diff != add) || !(add & mask)) add <<= 1;

    Solve(s, s ^ add, mask ^ diff);
    Solve(s ^ diff ^ add, t, mask ^ diff);
}

int main() {
    scanf("%d %d %d", &N, &A, &B);

    bool has_sol = ((__builtin_popcount(A) % 2) != (__builtin_popcount(B) % 2));
    if (has_sol) {
        puts("YES");
        Solve(A, B, (1 << N) - 1);
        puts("");
    } else {
        puts("NO");
    }

    return 0;
}


Measured memory_bytes: 1024
# Matrix Chain Multiplication
import sys

N = int(input())
p = [0] * (N + 1)
for i in range(N):
    p[i], p[i + 1] = map(int, input().split())

dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for l in range(2, N + 1):
    for i in range(1, N - l + 2):
        j = i + l - 1
        dp[i][j] = sys.maxsize
        for k in range(i, j):
            dp[i][j] = min(dp[i][j],
                           dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j])

print(dp[1][N])




Measured memory_bytes: 5724
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int N = 16;
ll f[1 << N], s[1 << N];
int a[N][N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];
	rep(S, 0, 1 << n)
		rep(i, 0, n)
			if (S & 1 << i)
				rep(j, i + 1, n)
					if (S & 1 << j)
						s[S] += a[i][j];
	rep(S, 0, 1 << n) {
		f[S] = s[S];
		for (int x = S; x; --x &= S)
			ckmax(f[S], s[x] + f[S & ~x]);
	}
	cout << f[(1 << n) - 1];
}

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

int main() {
  string s;
  cin >>s;
  int n=s.size();
  int ans10=0, ans01=0;
  //101010...
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='0') ans10++;
    }
    else{
      if(s[i]=='1') ans10++;
    }
  }
  //010101...
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='1') ans01++;
    }
    else{
      if(s[i]=='0') ans01++;
    }
  }

  cout<<min(ans01,ans10)<<endl;

  }


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

class P{
	int t, x, y;

	public P(int t, int x, int y) {
		super();
		this.t = t;
		this.x = x;
		this.y = y;
	}
}

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		P ps[] = new P[n+1];
		ps[0] = new P(0,0,0);
		for(int i=0;i<n;i++) {
			int t = fs.nextInt(), x = fs.nextInt(), y = fs.nextInt();
			ps[i+1] = new P(t, x, y);
		}
		Arrays.sort(ps,(p1,p2)->p1.t - p2.t);
		for(int i=1;i<n+1;i++) {
			int cost = ps[i].t - ps[i-1].t;
			int dx = Math.abs(ps[i].x - ps[i-1].x);
			int dy = Math.abs(ps[i].y - ps[i-1].y);
			if(dx + dy <= cost && (dx + dy - cost) % 2 == 0) {
				continue;
			}
			else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 44360
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef long double ld;
using namespace std;

const int MAXN = 100;
int g[2 * MAXN + 1][2 * MAXN + 1];

int mex(vector<int>& cur) {
    sort(cur.begin(), cur.end());
    int res = 0;
    for(auto x: cur) {
        if(x < res)
            continue;
        if(x > res)
            return res;
        res++;
    }
    return res;
}

int f(int x, int y) {
    if(g[x][y] != -1)
        return g[x][y];
    if(max(x, y) <= 1)
        return g[x][y] = 0;
    else {
        vector<int> v;
        for(int i = 1; 2 * i <= max(x, y); i++) {
            if(2 * i <= x)
                v.push_back(f(x - 2 * i, y + i));
            if(2 * i <= y)
                v.push_back(f(x + i, y - 2 * i));
        }
        return g[x][y] = mex(v);
    }
}

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

    ll x, y;
    cin >> x >> y;
    if(x - 1 <= y && y <= x + 1)
        cout << "Brown\n";
    else
        cout << "Alice\n";
    return 0;
    memset(g, -1, sizeof(g));
    for(int i = 0; i <= MAXN; i++) {
        for(int j = 0; j <= MAXN; j++) {
            g[i][j] = f(i, j);
            cout << i << " " << j << " " << g[i][j] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=200005;
int a[MAXN],n;
LL ans;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	if(a[1]!=0) {
		cout<<-1<<endl;
		return 0;
	}
	for(int i=2;i<=n;++i) {
		if(a[i]-a[i-1]>1||a[i]+1>i) {
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=n;i>=1;--i) {
		int j=i;
		ans+=a[j];
		while(j>1&&a[j]-a[j-1]==1)
			--j;
		i=j;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1024
X,Y,A,B,C = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)[:X]
b = sorted(list(map(int,input().split())),reverse=True)[:Y]
c = sorted(list(map(int,input().split())),reverse=True)

data = sorted(a+b+c,reverse=True)

print(sum(data[:X+Y]))


Measured memory_bytes: 22504
#include<stdio.h>
 
int main(){
   int n,m;
   scanf("%d %d", &n,&m);
   int lc[m],rc[m];
 	
   for(int i=0;i<m;i++){
     	scanf("%d %d ", &lc[i],&rc[i]);
   }
    int lmax = lc[0];
  	for(int i=1;i<m;i++){
     if(lmax < lc[i]){
     	lmax = lc[i];
     }
    }
  	int rmin = rc[0];
  	for(int i=1;i<m;i++){
     if(rmin > rc[i]){
     	rmin = rc[i];
     }
    }
  	int ans;
    if (lmax <= rmin){
  	  ans = rmin - lmax + 1;
    } else {
     	ans = 0; 
    }
	printf("%d", ans);
      return 0;
 
}

Measured memory_bytes: 896
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{

	ll s[1000000] = {}; //素数なら0
	s[0] = 1;
	s[1] = 1;
	for(ll i=2;i*i<1000000;i++)
	{
		if(s[i]==0){
			for(ll j=i*i ; j<1000000 ; j+=i ){	s[j]=1;	}
		}
	}
	
	ll a,b,n;
	while(cin >> a >> b >> n && !( a==0 || b==0 || n==0))
	{
		ll count(0);
		ll ans(0);
		for(ll i=a;i<1000000;i+=b)
		{
			if(s[i]==0){	count++;	}
			if(count == n){ans=i;break;}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8972
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll N, M, X[100005],d[100005],ans;

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

		FOR(i, 0, M) {
			cin >> X[i];
		}sort(X, X + M);
		if (N >= M)ct(0);
		else {
			FOR(i, 0, M - 1) {
				d[i] = abs(X[i + 1] - X[i]);
			}sort(d, d + M - 1);
			FOR(i, 0, M - N) {
				ans += d[i];
			}


			ct(ans);
		}
	return 0;
}


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

using namespace std;

int a[100005];

void solve() {
    int n;
    cin >> n;
    int cur;
    cur = 1;
    for (int i=1; i <= n; ++i) {
        int ai;
        cin >> ai;
        a[i] = ai;
    }
    int cnt = 0;
    for (int i=1; i<= n; ++i) {
        ++cnt;
        if (a[cur] == 2) {
            cout << cnt;
            return;
        } else {
            cur = a[cur];
        }
    }
    cout << -1;

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3580
/*
 * test3.cpp
 */

//include files
#include<iostream>

using namespace std;

//DEFINE MACROS
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

//DEFINE CONSTANT

//DEFINE PROTOTYPE

int main(){
  int N;
  long long int	T,push;
  long long int start,end;
  long long int sum= 0;
  cin >> N;
  cin >> T;
  start = 0;
  end = T;
  for (int i = 0; i < N; ++i) {
	cin >> push;

	if(i==0) continue;
	if(end > push){
	  end = push + T;
	}else{
	  sum += end - start;
	  start = push;
	  end = push + T;
	}
  }
  sum += end - start;
  cout << sum <<endl;
}



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

struct node
{
	double x, y;
};

void koch(int n, node a, node b)
{
	if( n == 0 ) return ;
	node s, t, u;
	double th = M_PI * 60/180.0;
	s.x = (2.0*a.x + 1.0*b.x)/3;
	s.y = (2.0*a.y + 1.0*b.y)/3;
	t.x = (1.0*a.x + 2.0*b.x)/3;
	t.y = (1.0*a.y + 2.0*b.y)/3;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	koch(n-1,a,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	koch(n-1,t,b);
}

int main(int argc, char const *argv[])
{
	node a, b;
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	int n;
	cin>>n;
	printf("%.8lf %.8lf\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8lf %.8lf\n",b.x,b.y);
	return 0;
}


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

int main(){
    int n,a,b,c,d; string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;
    bool ng=false;
    if(c<b){
        for(int i=a; i<c-1; ++i){
            if(s[i]=='#'&&s[i+1]=='#')ng=true;
        }
        for(int i=b; i<d-1; ++i){
            if(s[i]=='#'&&s[i+1]=='#')ng=true;
        }
    }
    else if(c>=b&&c<d){
        for(int i=a; i<d-1; ++i){
            if(s[i]=='#'&&s[i+1]=='#')ng=true;
        }
    }
    else{
        bool ok=false;
        for(int i=b; i<=d; ++i){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')ok=true;
        }
        for(int i=a; i<c-1; ++i){
            if(s[i]=='#'&&s[i+1]=='#')ng=true;
        }
        if(!ok)ng=true;
    }
    cout<<(!ng?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 640
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long sum = 0;
		for(int a=1;a<K+1;a++) {
			for(int b=1;b<K+1;b++) {
				for(int c=1;c<K+1;c++) {
					sum += gcd(gcd(a,b),c);
				}
			}
		}
		System.out.println(sum);
	
	}
	private static long gcd(long m,long n) {
		if(m<n) return gcd(n,m);
		if(n==0) return m;
		return gcd(n,m%n);
	}
	
}

Measured memory_bytes: 35716
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int mod = 100000003;

ll h, w, n;
ll a, b;
map <pair< ll,ll >, ll > m;

int main() {
	cin >> h >> w >> n;
	rep(i, 0, n) {
		cin >> a >> b;
		rep(j, 0, 3) {
			rep(k, 0, 3) {
				if (a - j >= 1 && b - k >= 1 && a + 2-j <= h&&b + 2-k <= w) {
					m[make_pair(a - j, b - k)]++;
				}
			}
		}
	}
	vector<ll> ans(10, 0);
	for (auto it = m.begin(); it != m.end(); it++)ans[it->second]++;
	ans[0] = (h - 2)*(w - 2) - m.size();
	rep(i, 0, 10)print(ans[i]);
}

Measured memory_bytes: 56448
N = int(input())


def F(a, b):
    a = str(a)
    b = str(b)
    return max(len(a), len(b))


ans = 10**9
for i in range(1, int(N ** 0.5) + 1):
    if N % i == 0:
        j = N // i
        ans = min(ans, F(i, j))

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A[5];
	rep(i,5){
		cin >> A[i];
		if(A[i] == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
A, B = map(str, input().split())

A_num = int(A)
if B == "10.00":
    print(A_num * 10)
else:
    B_num = int(B[0]) * 100 + int(B[2]) * 10 + int(B[3])
    print(int((A_num * B_num) // 100))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-10;
const int mod =  1000000007;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define vvpii vector<vector<pair<int,int>>>
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define forr(i,a,b) for(i=a;i<=b;i++)
#define umii unordered_map<int,int>
#define vpii vector<pair<int,int>>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define int long long
#define nl cout<<"\n"
#define pb push_back
#define sp <<" "<<
#define ss second
#define ff first
inline void read(int &x)
{
      int c = getchar();
      x = 0;
      int neg = 0;
      for(; ((c<48 || c>57) && c != '-'); c = getchar());
      if(c=='-')
      {
            neg = 1;
            c = getchar();
      }
      for(; c>47 && c<58 ; c = getchar())
      {
            x = (x<<1) + (x<<3) + c - 48;
      }
      if(neg)
      {
            x = -x;
      }
}
int fpow(int x, int n)
{
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b)
{
    if(b == 0)
    {
          return a;
    }
    return gcd(b,a % b);
}
void sieve(int n)
{
      bool prime[1000006];
      memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
      for (int p = 2; p <= rootn; p++)
      {
            if (prime[p] == true)
            {
                  for (int i = p*p; i <= n; i += p)
                  {
                        prime[i] = false;
                  }
            }
      }
      prime[1] = 0;
}
const int N = 100050;
int cnt, sum, mid, mx, mn, ans, a[N], b[N];
int n, m, d, i, j, k, l, p, q, r, t, w, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>s;
      if(s=="RRR")
      {
            cout<<3;
      }
      else if(s=="RRS"||s=="SRR")
      {
            cout<<2;
      }
      else if(s=="SSS")
              {
                    cout<<0;
      }
      else cout<<1;
     
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main {

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

		int ans = a - 2*b >0 ? a - 2*b : 0;
		System.out.println(ans);
		in.close();
	}
}


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

int main() {
	int n;
	cin >> n;
	int min = 1000000;
	int max = -1000000;
	int64_t sum = 0;
	int tmp;
	for(int i = 0; i < n; i++) {
		cin >> tmp;
		if(min > tmp) {
			min = tmp;
		}
		if(max < tmp) {
			max = tmp;
		}
		sum += tmp;
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(1e5) +5;


char ar[1000];



int check(int s,int e)
{
    while(s<e)
    {
        if(ar[s]!=ar[e])return 0;
        s++; --e;
    }
    return 1;
}

int main()
{
    idfc;

    string s;
    cin>>s;
    int n=s.length();

    int a=(n-1)/2;
    int b=(n+3)/2;
    int i;
    for(i=1;i<=n;i++)
    {
        ar[i]=s[i-1];
    }

    if(check(1,n)&&check(1,a)&&check(b,n))
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  int x = 0; 
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "P"){
      p = 1;
    } else if (S == "W") {
      w = 1;
    } else if (S == "G") {
      g = 1;
    } else if (S == "Y") {
      y = 1;
    }
  }
  x = p + w + g + y;
  if (x == 3) {
    cout << "Three" << endl;
  } else if (x == 4){
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
import sys
from math import log2, ceil

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    for i in range(1, n + 1):
        denom = 1
        while i < k:
            i *= 2
            denom *= 2
        res += 1 / denom
    res /= n
    print(res)   

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
#define ull unsigned  long long
using namespace std;
const int INF =1e9+10;
const int N = 1e2 + 10;
ll l[N];
signed main() {
    int n;
    si(n);
    rep(i,1,n)sl(l[i]);
    sort(l+1,l+1+n);
    ll cnt=0;
    if(n<3)cout<<0;
    else{
        rep(i,1,n){
            rep(j,i+1,n){
                rep(k,j+1,n){
                    if(l[i]+l[j]>l[k]&&(l[i]!=l[j])&&l[j]!=l[k]&&l[i]!=l[k]){
                        
                        cnt++;
                    }
                }
            }
        }cout<<cnt;
    }


    return 0;
}


Measured memory_bytes: 3692
import java.util.Scanner;

class Main{
    public static void main(String[] x){
		Scanner sc = new Scanner(System.in);
		short N = (short)Integer.parseInt(sc.nextLine());
		short[] a = new short[N];
		short[] b = new short[N];
		short[] c = new short[N];
		for(short i=0;i<N;i++){
			String s = sc.nextLine();
			a[i] = (short)Integer.parseInt((s.split(" ",0))[0]);
			b[i] = (short)Integer.parseInt((s.split(" ",0))[1]);
			c[i] = (short)Integer.parseInt((s.split(" ",0))[2]);
		}
		for(short i=0;i<N;i++){
			if(isRightTriangle(a[i],b[i],c[i])){System.out.println("YES");}
			else{System.out.println("NO");}
		}
    }
	public static boolean isRightTriangle(int a, int b, int c){
		return (a>=b&&a>=c&&a*a==b*b+c*c)
			||(b>=c&&b>=a&&b*b==c*c+a*a)
			||(c>=a&&c>=b&&c*c==a*a+b*b);
	}
}

Measured memory_bytes: 32160
#include <bits/stdc++.h>
using namespace std;
int N, K;
string s;
vector<int> cons[2];
int main(){
    //freopen("test.in", "r+", stdin);
    cin >> N >> K;
    cin >> s;
    if(s[0] == '0')cons[1].push_back(0);
    for(int i = 0; i < N; i++){
        int j = i;
        while(s[j] == s[i])j++;
        cons[s[i] - '0'].push_back(j - i);
        i = j - 1;
    }

    /*
    for(int i = 0; i < cons[0].size(); i++)cout << cons[0][i] << " ";
    cout << endl;
    for(int i = 0; i < cons[1].size(); i++)cout << cons[1][i] << " ";
    cout << endl;
    */

    if(K >= cons[0].size())return cout << N << endl, 0;

    int final_res = 0, cur_res = 0;
    for(int i = 0; i < K; i++)
        final_res += cons[0][i] + cons[1][i];
    final_res += (K < cons[1].size() ? cons[1][K] : 0);
    cur_res = final_res;

    for(int i = K; i < cons[0].size(); i++){
        cur_res += cons[0][i] + (i + 1 < cons[1].size() ? cons[1][i + 1] : 0);
        cur_res -= cons[0][i - K] + cons[1][i - K];
        final_res = max(final_res, cur_res);
    }
    cout << final_res << endl;



}


Measured memory_bytes: 1020
n = gets.to_i
a = Array.new(n, "")
for i in 0...n
  w = gets.chomp
  if a.include?(w)
    puts :No
    exit
  else
    a[i] = w
    if i > 0 && a[i-1][-1] != a[i][0]
      puts :No
      exit
    end
  end
end

puts :Yes

Measured memory_bytes: 14180
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define int long long

#define NUM 1000000007

struct _chunk {
	int name;
	int nextNum;
	vector<int> next;
};

int factorial(int num1, int num2){
    int sum = 1;
    for (int i = num1 + 1; i <= num1 + num2; ++i)
    {
        sum *= i;
    }

    for (int i = num2; i >= 1; --i) {
    	sum /= i;
    }
    return sum;
}

signed main(void) {
  int N, A, B;
  cin >> N >> A >> B;

  if (A*N >= B) {
  	cout << B << endl;
  } else {
  	cout << A*N << endl;
  }


  return 0;
}


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

using namespace std;

int main(){
    int n=0;
    //char s[200];
    bool flag = false;
    //vector<int> a(N,0);

    cin >> n;

    if(n%10 == 7)
        flag = true;
    else{
        n /=10;
        if(n%10 == 7)
            flag = true;
        else{
            n /=10;
            if(n%10 == 7)
                flag = true;
        }
    }
    
    //for(int i=0;i<n;i++);


    

    //cout << ans << endl;
    cout << ( (flag) ? "Yes" : "No" ) << endl;
}


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

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

    int suff[200003];
    int cnt[2020];

    memset(suff, 0, sizeof(suff));
    memset(cnt, 0, sizeof(cnt));

    int n = (int) s.length();
    suff[n + 1] = 0;
    cnt[0] = 1;

    long long int answer = 0;

    int mul = 1;
    for (int i = n; i >= 1; i--) {
        int currentDigit = s[i - 1] - '0';
        suff[i] = (mul * currentDigit + suff[i + 1])%2019;

        answer += cnt[suff[i]];
        cnt[suff[i]] += 1;

        mul = (mul * 10)%2019;
    }

    cout << answer << endl;
}


Measured memory_bytes: 4544
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

if (a1<b1 and a2<b2) or (a1>b1 and a2>b2):
    print(0)
    exit()

if a1 > b1:
    a1,b1 = b1,a1
    a2,b2 = b2,a2

_b1 = b1 - a1
_a2 = a2 - b2

v1 = t1*_b1
v2 = t2*_a2

if v1 == v2:
    print('infinity')
    exit()

if v1 > v2:
    print(0)
    exit()

d = v2 - v1
k = v1 // d

ans = k*2 + 1
if v2*k == v1*(k+1):
    ans -= 1
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,sum=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=1;i<n;i++)sum+=a[i/2];
  cout << sum << endl;
}

Measured memory_bytes: 4372
fun main(args: Array<String>) {
    var s = readLine()!!
    val list = listOf("dream", "dreamer", "erase", "eraser")
    var can = true
    while (s.isNotEmpty()) {
        val length = s.length
        for (suffix in list) {
            if (s.endsWith(suffix)) {
                s = s.substring(0, s.length - suffix.length)
                break
            }
        }
        if (length == s.length) {
            can = false
            break
        }
    }
    if (can) {
        println("YES")
    } else {
        println("NO")
    }
}

Measured memory_bytes: 119648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[N];
    set<int> s;
    rep(i, N){
        cin >> A[i];
        s.insert(A[i]);
    }
    //vec[i]:=Aに含まれる整数でi番目(同じ数字は一つと考える)のもの
    vector<int> vec;
    for(auto &e: s){
        vec.pb(e);
    }
    //使えない場所のインデックス
    vector<int> used;
    used.pb(-1), used.pb(N);
    int ans = INT_MAX;
    //最小値としてvec[i]を取る場合
    rep(i, vec.size()){
        vector<int> tog;
        //区間(used[j], used[j+1])を探索
        rep(j, used.size()-1){
            vector<int> tmp;
            int n = used[j+1]-used[j]-1;
            if(n < K) continue;
            rep2(k, used[j]+1, used[j+1]-1){
                tmp.pb(A[k]);
            }
            sort(tmp.begin(), tmp.end());
            rep(k, n-K+1){
                tog.pb(tmp[k]);
            }
        }
        if(tog.size() < Q) continue;
        sort(tog.begin(), tog.end());
        ans = min(ans, tog[Q-1]-tog[0]);
        //A[j]=vec[i]となるjをusedに追加
        rep(j, N){
            if(A[j] == vec[i]) used.pb(j);
        }
        sort(used.begin(), used.end());
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll gcdExtended(ll a,ll b,ll *x,ll *y)
{
    if(a==0)
    {
        *x=0,*y=1;
        return(b);
    }
    ll x1,y1;
    ll gcd=gcdExtended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return(gcd);
}*/
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
/*ll modInverse(ll a, ll m)
{
    ll x,y;
    ll g = gcdExtended(a, m,&x,&y);
    return((x%m+m)%m);
}*/
/*long combi(int n,int k)
{
    long ans=1;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}*/
/*struct cmp{
    bool operator()(const pair<ll,ll>&a,const pair<ll,ll>&b)
    const{
        int lena=a.second-a.first+1;
        int lenb=b.second-b.first+1;
        if(lena==lenb) return a.first<b.first;
        return lena>lenb;
    }
};*/
bool check(ll mid,ll arr[],ll n,ll k)
{
    ll cnt=0;
    if(mid==0)
        return(false);
    for(ll i=0;i<n;i++)
    {
        if(arr[i]==mid)
            continue;
        cnt+=arr[i]/mid;
    }
    return(k>=cnt);
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    ll m=INT_MIN;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        m=max(m,arr[i]);
    }
    ll l=0,r=m;
    ll ans;
    while(l<=r)
    {
        ll mid=ceil((l+r)/2.0);
        if(check(mid,arr,n,k))
        {
            r=mid-1;
            ans=mid;
        }
        else
            l=mid+1;
        //cout<<l<<" "<<r<<endl;
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll n,d,i,l=0,count=0,j,k;
double o,p;
cin>>n>>d;
ll a[n][d];
for(i=0;i<n;i++)
{
	for(j=0;j<d;j++)
	{
		cin>>a[i][j];
	}
}
for(i=0;i<n-1;i++)
{
	for(k=i+1;k<n;k++)
	{
		l=0;
	for(j=0;j<d;j++)
	{
		l+=pow((abs(a[i][j]-a[k][j])),2);
	}
o=sqrt(l);
//cout<<o<<endl;

if(floor(o)==ceil(o))
count++;
}
}
cout<<count<<endl;
}

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

using ll = long long int;
using P = pair<ll,ll>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 100000;
constexpr int di[] = {0,1,0,-1};
constexpr int dj[] = {1,0,-1,0};

bool chmin(ll &a, ll b){
    if(a > b){
        a = b;
        return true;
    }else{
        return false;
    }
}
void chmax(ll &a, ll b){
    a = max(a,b);
}

bool solve(){
    ll n, m, c;
    ll ans = INF, dsum = 0;
    cin >> n >> m >> c;
    vector<vector<P> > g(n);
    for(int i=0;i<m;i++){
        ll a, b, d;
        cin >> a >> b >> d;
        a--; b--;
        g[a].emplace_back(P(b,d));
        g[b].emplace_back(P(a,d));
        dsum += d;
    }
    vector<ll> dist(n, INF);
    dist[0] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,0));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(p.first > dist[v]) continue;
        for(auto e : g[v]){
            ll u = e.first, d = e.second;
            if(chmin(dist[u], dist[v]+d)){
                que.push(P(dist[u], u));
            }
        }
    }
    vector<P> ord;
    for(int i=0;i<n;i++){
        ord.emplace_back(P(dist[i],i));
    }
    sort(ord.begin(), ord.end());
    vector<bool> used(n);
    for(int i=0;i<n;i++){
        ll v = ord[i].second, x = ord[i].first;
        used[v] = true;
        for(auto e : g[v]){
            ll u = e.first, d = e.second;
            if(used[u]) dsum -= d;
        }
        chmin(ans, c*x + dsum);
    }
    cout << ans << endl;
    return true;
}

int main(){
    solve();
    return 0;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;

    vi p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];

    int idx=0;
    while(p[idx]==q[idx])idx++;
    if(p[idx]>q[idx])swap(p,q);

    int ans=0;
    while(idx<n){
        next_permutation(all(p));
        ans++;
        while(p[idx]==q[idx])idx++;
    }

    cout<<ans<<"\n";

    return 0;
}

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

int main(){
   long int a,b;

   while(a!=0&&b!=0){
       cin>>a>>b;
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cout<<"#";
        }
        cout<<endl;
     }
    if(a!=0&&b!=0){
       cout<<endl;
    }
   }     
    return 0;
}


Measured memory_bytes: 3120
import numpy as np
N = int(input())

memo = np.zeros([N,2])
for i in range(N):
    A,B = map(int,input().split())
    memo[i][0] = A
    memo[i][1] = B

memo = memo[np.argsort(memo[:,1])]
#print(memo)
flag = True
s = 0
for i in range(N):
    s += memo[i,0]
    if memo[i,1]-s<0:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 20240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	ll n;
	ll cnt = 0;
	cin >> n;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n-1) {
		ll step;
		if (a[i + 1] < a[i]) {
			step = a[i] - a[i + 1];
			a[i + 1] += step;
			cnt += step;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      acos(-1.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     200005

using namespace std;

int a[MAX];

int main()
{
//    READ;
//    WRITE;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<a[i-1])
        {
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4496
from collections import Counter

def main():
    n, m, k = [int(s) for s in input().strip().split()]
    adj = [[] for _ in range(n)]
    for _ in range(m):
        a, b = [int(s) for s in input().strip().split()]
        adj[a - 1].append(b - 1)
        adj[b - 1].append(a - 1)
    
    groups = [-1] * n
    for i in range(n):
        if groups[i] < 0:
            groups[i] = i
            q = [i]
            for j in q:
                for v in adj[j]:
                    if groups[v] < 0:
                        groups[v] = i
                        q.append(v)
    cnt = Counter(groups)

    result = [cnt[groups[i]] - len(adj[i]) - 1 for i in range(n)]
    for _ in range(k):
        c, d = [int(s) for s in input().strip().split()]
        if groups[c - 1] == groups[d - 1]:
            result[c - 1] -= 1
            result[d - 1] -= 1
    print(" ".join(str(x) for x in result))


main()


Measured memory_bytes: 92576
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  string t = s;
  bool flag = false;
  int n = s.size();
  if(s=="keyence"){
    cout<<"YES"<<endl;
    return 0;
  }
  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j <= n; j++)
    {
      if (i < j)
      {
        s.erase(s.begin() + i, s.begin() + j);
      }
      if (s == "keyence")
      {
        flag = true;
        break;
      }
      else
        s = t;
    }
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,ans;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
}

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

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

using namespace std;
using lint=long long;

const lint MOD=998244353;

int main(){
	int n;
	string s; cin>>n>>s;
	vector<int> x(n);
	rep(i,n) x[i]=s[i]-'0';

	vector<int> D; // divisors d of n s.t. n/d is odd
	for(int i=1;i*i<=n;i++) if(n%i==0) {
		D.emplace_back(i);
		if(i*i<n) D.emplace_back(n/i);
	}
	sort(D.begin(),D.end());
	rep(i,D.size()) if((n/D[i])%2==0) D.erase(D.begin()+i), i--;

	lint ans=0;
	vector<lint> num; // num[i] := number of k's with minimum period 2*d[i]
	for(int d:D){
		int m=n/d;

		// x[0..d) から始まるパターンが可能かどうか
		bool ok=true;
		for(int i=1;i<m;i++){
			int ok2=-1;
			rep(j,d){
				int k=(i%2==1?1-x[j]:x[j]);
				if     (k<x[i*d+j]){ ok2=1; break; }
				else if(k>x[i*d+j]){ ok2=0; break; }
			}
			if     (ok2==1){ ok=true;  break; }
			else if(ok2==0){ ok=false; break; }
		}

		lint cnt=0;
		rep(i,d) cnt=(cnt*2+x[i])%MOD;
		if(ok) cnt=(cnt+1)%MOD;

		rep(i,num.size()) if(d%D[i]==0) cnt=(cnt-num[i]+MOD)%MOD; // inclusion-exclusion
		num.emplace_back(cnt);
		ans=(ans+2*d*cnt)%MOD;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1412
#include <stdio.h>

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

  /*数字を入力*/

  scanf("%d", &x);
  scanf("%d", &y);
  scanf("%d", &z);

  /*数字を交換*/
  s = x;
  x = y;
  y = s;
  s = x;
  x = z;
  z = s;

  /*数字を表示*/
  printf("%d %d %d\n", x, y, z);

  return 0;
}


Measured memory_bytes: 128
#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>;

const int cut = 998244353;

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> q(s+1);
    int ans = 0;
    rep(i,n) {
        q[0] += 1;  // q += 1;
        q[0] %= cut;
        { // q = (1 + x^a[i])
            vector<int> q2(s+1);
            rep(j,s+1) {
                q[j] %= cut;
                q2[j] += q[j];
                q2[j] %= cut;
                if (j+a[i] <= s) q2[j+a[i]] += q[j];
                q2[j+a[i]] %= cut;
            }
            q = q2;
        }
        ans += q[s];
        ans %= cut;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define max(X) *max_element(all(X))
#define min(X) *min_element(all(X))
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

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

  rep(i,0,1000) {
    if((N+i) % 111 == 0){
      print(N+i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
#define n_max 2005
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

llong fac[n_max];  /// fac[n] = n!
llong finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
llong inv[n_max];  /// (n * inv[n]) % MOD = 1
 
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, n_max) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}
 
llong nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


signed main(){
    init();

    int n,k;
    cin >> n >> k;
    FOR(i,1,k+1){
        cout << (nCk(n-k+1,i) * nCk(k-1,i-1)) % MOD << endl; 
    }

}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    char alpha;
    cin >> alpha;
    if (alpha >= 'a' && alpha <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int a, b, c;

    cin >> a >> b >> c;
    cout << c << " " << a <<" " <<  b << endl;;

    return 0;
}

Measured memory_bytes: 256