akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n, k, m;
		List<Integer> list = new ArrayList<Integer>();
		while (true) {
			n = sc.nextInt(); k = sc.nextInt(); m = sc.nextInt();
			if (n == 0) break;
			for (int i = 1; i <= n; i++)
				list.add(i);
			int index = m-1;
			while (true) {
				if (list.size() == 1) break;
				list.remove(index);
				index = (index+k-1)%list.size();
			}
			out.println(list.get(0));
			list.clear();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 29520
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  map<vector<int>, int> mp;
  REP(i, n){
    string s;
    cin >> s;
    vector<int> v(10);
    REP(j, 10){
      v[j] = s[j] - 'a';
    }
    sort(ALL(v));
    mp[v]++;
  }

  ll ans = 0;
  auto itr = mp.begin();
  while(itr != mp.end()){
    ll t = itr->second;
    if(t >= 2) ans += t*(t-1)/2;
    itr++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
n = int(input())
a = list(map(int, input().split()))
t = 1
if 0 in a:
    print("0", end="")
    exit()

for i in range(n):
    t = t*a[i]
    if t > 10**18:
        print("-1", end="")
        exit()
print(t, end="")


Measured memory_bytes: 84604
import heapq
q=[]
heapq.heapify(q)
while True:
    temp = input()
    if temp=="end":
        break    
    if temp=="extract":
        num= heapq.heappop(q)
        print(num*(-1))
    else:
        a,b= temp.split()
        b=int(b)
        heapq.heappush(q,b*(-1))


Measured memory_bytes: 45304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF (1<<30)
#define LINF (1ll<<60ll)
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int n;
    int t,a;
    cin>>n>>t>>a;
    t*=1000;
    a*=1000;
    int mi,mv=INF;
    REP(i,n){
        int h;
        cin>>h;
        if(chmin(mv,abs(a-(t-h*6))))mi=i;
    }
    cout<<mi+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int arr[200005], idx[200005];
int main()
{
	// freopen("AGC014-F.in", "r", stdin);
	int n, ans = 0, lst;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		idx[--arr[i]] = i;
	}
	for (int i = n - 2; i >= 0; i--)
	{
		if (ans)
		{
			if ((idx[lst] < idx[i + 1]) + (idx[i + 1] < idx[i]) + (idx[i] < idx[lst]) == 2)
			{
				ans++;
				lst = i + 1;
			}
		}
		else
		{
			if (idx[i] > idx[i + 1])
			{
				ans++;
				lst = i + 1;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    long K,X;
    cin >> K >> X;
    for(int i=X-K+1; i<=X+K-1; i++){
        cout << i;
        if(i!=X+K-1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#define maxn 100009
#define maxm
#define PS system("pause");
using namespace std;
const int INF=1e9;
int n,m;
vector<int>G[maxn];
int val[maxn];
bool mark[maxn];
int ll[maxn],rr[maxn];

bool dfs(int u,int fa,int sg){
	ll[u]=-INF;
	rr[u]=INF;
	if(mark[u]){
		if(sg!=(val[u]&1)){
			return 0;
		}
	}
	for(int i=0;i<(int)G[u].size();i++){
		int v=G[u][i];
		if(v==fa)
			continue;
		if(!dfs(v,u,sg^1))
			return 0;
		ll[u]=max(ll[u],ll[v]-1);
		rr[u]=min(rr[u],rr[v]+1);
	}
	if(mark[u]){
		ll[u]=max(ll[u],val[u]);
		rr[u]=min(rr[u],val[u]);
	}
	if(ll[u]>rr[u])
		return 0;
	return 1;
}

bool setcolor(int u,int fa,int L,int R){
	L=max(L,ll[u]);
	R=min(R,rr[u]);
	if(L>R)
		return 0;
	val[u]=L;
	for(int i=0;i<(int)G[u].size();i++){
		int v=G[u][i];
		if(v==fa)
			continue;
		if(!setcolor(v,u,L-1,L+1))
			return 0;
	}
	return 1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int root=0;
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		mark[x]=1;
		val[x]=y;
		root=x;
	}
	if(!dfs(root,-1,val[root]&1)){
		puts("No");
	}
	else if(!setcolor(root,-1,val[root],val[root])){
		puts("No");
	}
	else{
		puts("Yes");
		for(int i=1;i<=n;i++)
			printf("%d\n",val[i]);
	}
	//system("pause");
	return 0;
}	

Measured memory_bytes: 15488
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String p = sc.nextLine();
		String ss = s+ s;		
		if(ss.contains(p)){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}



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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int d, t, s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> d >> t >> s;
    cout << (d <= t * s ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    string S;
    cin>>S;

    if((S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2])
     || (S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])
     || (S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])){
         cout<<"Yes"<<endl;
     }else{
         cout<<"No"<<endl;
     }
     
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    int w,h;
    cin>>w>>h;
    vector<vector<int> > hw(h,vector<int>(w,0));
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      x--;
      y--;
      hw[y][x]=1;
    }
    int s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<=h-t;i++){
      for(int j=0;j<=w-s;j++){
        int tmp=0;
        for(int k=0;k<t;k++){
          for(int l=0;l<s;l++){
            tmp+=hw[i+k][j+l];
          }
        }
        ans=max(ans,tmp);
      }
    }
    cout<<ans<<endl;
  }
}



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

using namespace std;

char a[5],b[5];

int doit(char x[])

{

	for(int i=0;i<=2;i++)

	{

		if(x[i]>='a'&&x[i]<='z')

		{

			continue;

		}

		else

		{

			cout<<"NO";

			return false;

		} 

	}

	return true;

}

 

int main()

{

	cin>>a;

	cin>>b;

	if(doit(a)==false) return 0;

	if(doit(b)==false) return 0;

	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])

	{

		cout<<"YES";

	}

	else

	{

		cout<<"NO";

	}

	return 0;

}

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

class Counter{
    int cnt;
public:
    Counter():cnt(0){}
    int show(){return cnt;}
    void up(){++cnt;}
    void down(){--cnt;}
};

void swap(int& a,int& b){
    int t=a;
    a=b;
    b=t;
}

int main(){
    int n;
    cin>>n;
    Counter a;
    int* array=new int[n];
    for(int i=0;i<n;++i){
        cin>>array[i];
    }
    int flag=1;
    while(flag){
        flag=0;
        for(int i=n-1;i>=0;--i){
            if(array[i]<array[i-1]){
                swap(array[i],array[i-1]);
                flag=1;
                a.up();
            }
        }
    }
    for(int i=0;i<n;++i){
        cout<<array[i];
        if(i!=n-1){cout<<" ";}
    }
    cout<<"\n";
    cout<<a.show()<<"\n";
}

Measured memory_bytes: 3068
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,k,s;cin >> n >> k >> s;
    rep(i, k) cout << s << ' ';
    rep(i, n-k) cout << (s==1?s+1:s-1) << ' ';
    return 0;
}

Measured memory_bytes: 3604
object Main {
  def main(args: Array[String]) = {
    val Array(k, s) = readLine.split(" ").map(_.toInt)

    val list = (0 to k).toList

    val res = list.foldRight(0) { (x, t) => t + list.foldRight(0) { (y, t2) => t2 + (if (0 <= (s - x - y) && (s - x - y) <= k) 1 else 0) } }
    println(res)
  }
}

Measured memory_bytes: 95044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		String s = fr.nextLine();
		String v = "keyence";
		int n = s.length();
		boolean pos = false;
		for (int i=0; i<v.length(); i++) {
			String t = s.substring(0, i);
			String rest = v.substring(t.length());
			if (s.substring(n-rest.length(), n).equals(rest) && (t+rest).equals(v)) {
				pos = true;
				break;
			}
		}
		
		if (pos) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


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

class C
{
	static void Main() => Console.WriteLine(Enumerable.Range(int.Parse(Console.ReadLine()), 99).First(n => IsPrime(n)));

	static bool IsPrime(long n)
	{
		for (long x = 2; x * x <= n; ++x) if (n % x == 0) return false;
		return n > 1;
	}
}


Measured memory_bytes: 13268
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M, X = read_ints()
    A = []
    for _ in range(N):
        A.append(read_ints())

    min_T = math.inf
    for S in range(1, (1<<N)):
        T = [0]*(M+1)
        for i in range(0, N):
            if (S>>i)&1 == 1:
                for j in range(M+1):
                    T[j] += A[i][j]
        if all(t >= X for t in T[1:]) and T[0] < min_T:
            min_T = T[0]
    if min_T == math.inf:
        return -1
    return min_T


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9160
N=int(input())
L=[[int(x) for x in input().split()] for i in range(2)]
t=[0]*2

n=1
for i in range(2,N+1):
  n*=i

for i in range(2):
  o=n
  D=[x for x in range(1,N+1)]
  for j in range(N):
    o//=len(D)
    t[i]+=o*D.index(L[i][j])
    D.remove(L[i][j])

print(abs(t[1]-t[0]))


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cassert>
#include<map>
#include<queue>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define MAX 35
#define next(a,b) ((((a+3)%4)+b)%4)
using namespace std;

struct P
{
  int x,y,dir;
  P(int x=inf,int y=inf,int dir=inf):x(x),y(y),dir(dir){}
};

int dx[] = {+1,+0,-1,+0};
int dy[] = {+0,-1,+0,+1};
int H,W;
char G[MAX][MAX];
int  I[MAX][MAX];
int  D[MAX][MAX];
int  Next[MAX][MAX];
string DIR = "ENWS";
vector<P> vec;

bool Finish()
{
  rep(i,vec.size())
    {
      if(G[vec[i].y][vec[i].x] != 'X')return false;
    }
  return true;
}

void print()
{
  cout << "print- ---" << endl;
  rep(i,H)
    {
      rep(j,W)
	{
	  cout << G[i][j];
	}
      cout << endl;
    }
  cout << endl;
}
void print2()
{
  cout << "2print- ---" << endl;
  rep(i,H)
    {
      rep(j,W)
	{
	  cout << D[i][j];
	}
      cout << endl;
    }
  cout << endl;
}

void decide()
{
  rep(i,vec.size())
    {
      int x = vec[i].x;
      int y = vec[i].y;
      if(G[y][x] == 'X')continue;
      int dir = vec[i].dir;
      Next[y][x] = inf;
      rep(j,4)
	{
	  int nx = x + dx[next(dir,j)];
	  int ny = y + dy[next(dir,j)];
	  if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
	  if(!(G[ny][nx] == '.' || G[ny][nx] == 'X'))continue;
	  vec[i].dir = next(dir,j);
	  D[ny][nx]++;
	  break;
	}
    }
}

bool check(int x,int y,int cx,int cy)
{
  rep(i,4)
    {
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
      if(G[ny][nx] == '.' || G[ny][nx] == 'X' || G[ny][nx] == '#')continue;
      return nx == x && ny == y;
    }
  assert(false);
}

void move()
{
  rep(i,vec.size())
    {
      int x = vec[i].x;
      int y = vec[i].y;
      if(G[y][x] == 'X')continue;


      int dir = vec[i].dir;

      int nx = x + dx[dir];
      int ny = y + dy[dir];
      if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
      if(!(G[ny][nx] == '.' || G[ny][nx] == 'X'))continue;
      if(D[ny][nx] == 0)continue;
      if(D[ny][nx] == 0)
	{
	  cout << i << " is out: " << x << "," << y << " -> " << nx << "," << ny << endl; 
	  print();
	  print2();
	}
      if(D[ny][nx] == 0)continue;
      //assert(D[ny][nx]);
      if(D[ny][nx] == 1 || (D[ny][nx] >= 2 && check(x,y,nx,ny)))
	{
	  D[ny][nx] = 0;
	  G[y][x] = '.';
	  vec[i].x = nx, vec[i].y = ny;
	  if(G[ny][nx] != 'X')G[ny][nx] = DIR[dir];
	}

    }
  rep(i,H)rep(j,W)D[i][j] = 0;
}

int main()
{
  while(cin >> W >> H,W|H)
    {
      vec.clear();
      rep(i,H)rep(j,W)
	{
	  cin >> G[i][j];
	  I[i][j] = -inf;
	  if(!(G[i][j] == '.' || G[i][j] == '#' || G[i][j] == 'X'))
	    {
	      char c = G[i][j];
	      int dir = (c=='E'?0:(c=='N'?1:(c=='W'?2:(c=='S'?3:-inf))));
	      vec.push_back(P(j,i,dir));

	    }
	}


      if(vec.empty())
	{
	  cout << 0 << endl;
	  continue;
	}

      rep(phase,180)
	{
	  //print();
	  decide();

	  move();

	  if(Finish())
	    {
	      cout << phase+1 << endl;
	      goto Fin;
	    }
	}
      cout << "NA" << endl;
    Fin:;
    }

  return 0;
}

Measured memory_bytes: 1228
n,k = gets.split.map(&:to_i)
s = gets.chomp.chars

tmp = []
current = s[0]
sum = 0
s.each do |c|
  if current == c
    sum += 1
  else
    tmp << {val: sum, type: current}
    sum = 1
    current = c
  end
end

tmp << {val: sum, type: current}

if tmp[0][:type] == "0"
  tmp.unshift({val: 0, type: "1"})
end

if tmp[-1][:type] == "0"
  tmp.push({val: 0, type: "1"})
end

take = k*2+1
total = tmp[0, take].reduce(0) {|a,e| a+=e[:val]}

ans = total

2.step(tmp.size, 2) do |i|
  next if tmp[i-1].nil?
  break if tmp[i+take-1].nil?
  total -= tmp[i-2][:val]
  total -= tmp[i-1][:val]
  total += tmp[i+take-2][:val]
  total += tmp[i+take-1][:val]
  ans = [ans, total].max
end

puts ans


Measured memory_bytes: 38140
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S, ss;
    cin >> S;
    int len;
    len = (int)S.size();
    int w, t2;
    ss = S.substr(0,3);
    sscanf(ss.c_str(),"%d",&t2);
    w = abs(t2 - 753);

    for(int i=1;i<(len-2);i++){
        ss = S.substr(i,3);
        sscanf(ss.c_str(),"%d",&t2);
        if(w > abs(t2 -753)){
            w = abs(t2 - 753);
        }
    }
    cout << w <<"\n";
    return 0;
}


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

using namespace std;

int main(){

    string W,T;
    int result=0;
    cin>>W;

    for(int j=0;j<W.length();j++)
    {
        if((int)'a'<=(int)W[j] && (int)W[j]<=(int)'z')
        {
            W[j]= W[j] - (int)'a' + (int)'A';
        }
    }

    for(int i= 0;i<1000;i++)
    {
        cin>>T;

        for(int j=0;j<T.length();j++)
        {
            if((int)'a'<=(int)T[j] && (int)T[j]<=(int)'z')
            {
                T[j]= T[j] - (int)'a' + (int)'A';
                if(T == "END_OF_TEXT")
                {
                    T = T+'.';
                }
            }
        }

        if(T == "END_OF_TEXT")break;

        if(T == W)
        {
            result++;
        }else if(T == W+ '.')
        {
            result++;
        }

    }

    cout<<result<<endl;

    return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 1000005, P = 998244353, I2 = (P + 1) >> 1;

int n, m, c[N];
int cnt, prime[N], vis[N], mu[N];
int inv[N], sum[N];

int main() {
	read(n), m = 0;
	for (int i = 1; i <= n; ++i) {
		int x;
		read(x);
		m = std::max(m, x);
		++c[x];
	}
	inv[1] = 1;
	for (int i = 2; i <= m; ++i) {
		inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
	}
	cnt = 0;
	mu[1] = 1;
	for (int i = 2; i <= m; ++i) {
		if (!vis[i]) {
			prime[++cnt] = i;
			mu[i] = -1;
		}
		for (int j = 1; j <= cnt && i * prime[j] <= m; ++j) {
			vis[i * prime[j]] = 1;
			if (i % prime[j] == 0) {
				mu[i * prime[j]] = 0;
				break;
			}
			mu[i * prime[j]] = -mu[i];
		}
	}
	for (int i = 1; i <= m; ++i) {
		sum[i] = 0;
		for (int j = i; j <= m; j += i) {
			sum[i] = (sum[i] + 1ll * j * c[j]) % P;
		}
		sum[i] = 1ll * sum[i] * sum[i] % P;
	}
	int ans = 0;
	for (int d = 1; d <= m; ++d) {
		for (int k = 1; k <= m / d; ++k) {
			ans = (ans + 1ll * inv[d] * mu[k] * sum[d * k]) % P;
		}
	}
	for (int i = 1; i <= m; ++i) {
		ans = (ans - 1ll * c[i] * i) % P;
	}
	ans = 1ll * ans * I2 % P;
	print((ans + P) % P);
}


Measured memory_bytes: 24836
s=int(input())
a=1
mod=10**9+7
x=s//3
y=s%3
ans=0
while x>=1:
  xx=1
  for i in range(1,x):
    xx*=i
    xx%=mod
  yy=1
  for j in range(1,1+y):
    yy*=j
    yy%=mod
  fx=pow(xx,mod-2,mod)
  fy=pow(yy,mod-2,mod)
  xxyy=1
  for k in range(1,x+y):
    xxyy*=k
    xxyy%=mod
  ans+=(xxyy*fx*fy)%mod
  x-=1
  y+=3
print(ans%mod)

Measured memory_bytes: 9164
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  char c;
  int d=0;
  while(scanf("%c", &c)){
    if(c=='g') d++;
    else if(c=='p') d--;
    else break;
  }
  cout<<d/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i, a, b) 	for (uint64_t i=a; i<(b); i++)
#define forev(i, b, a) 	for (int i = (b)-1; i >= a; i--)
typedef long long int	lli;
typedef long double		ld;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define enl	"\n"
#define fast	ios_base::sync_with_stdio(0); cin.tie(0);
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

int main() {
	fast;
	// int t; cin >> t; while (t--)
	uint64_t n; cin >> n;
	int a[n];
	uint64_t sum = 0;
	map<uint64_t, uint64_t> m;
	fo(i, 0, n) {
		cin >> a[i];
		m[a[i]]++;
		sum += a[i];
	}

	uint64_t q; cin >> q;

	fo(i, 0, q) {
		uint64_t k, l; cin >> k >> l;
		sum += (l * m[k]) - (k * m[k]);
		cout << sum << enl;
		m[l] += m[k];
		m[k] = 0;
	}

	return 0;
}

Measured memory_bytes: 9680
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
}

Measured memory_bytes: 35760
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, N):
        self.par = [-1] * N

    def find(self, x):
        r = x
        while self.par[r] >= 0:
            r = self.par[r]
        while x != r:
            tmp = self.par[x]
            self.par[x] = r
            x = tmp
        return r

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

N, M = map(int, input().split())
X = list(map(int, input().split()))
G = [[] for _ in range(N)]
edges = []
for _ in range(M):
    A, B, Y = map(int, input().split())
    A -= 1
    B -= 1
    G[A].append(B)
    G[B].append(A)
    edges.append((A, B, Y))
edges.sort(key=lambda p: p[2])
use = 0
pending = [0] * N
uf = UnionFind(N)
for A, B, Y in edges:
    s = X[uf.find(A)]
    if not uf.same(A, B):
        s += X[uf.find(B)]
        t = pending[uf.find(A)] + pending[uf.find(B)]
        uf.unite(A, B)
        X[uf.find(A)] = s
        pending[uf.find(A)] = t
    if Y <= s:
        use += pending[uf.find(A)] + 1
        pending[uf.find(A)] = 0
    else:
        pending[uf.find(A)] += 1
print(M - use)

Measured memory_bytes: 109936
#include <iostream>
using namespace std; typedef long long ll;
typedef pair<int,int> P; const int INF = 1e9+1;

int main() {
  int n; cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) a[i]--;

  ll b[n]; fill(b,b+n,0);
  for(int i=0;i<n;i++) b[a[i]]++;

  ll sm=0;
  for(int i=0;i<n;i++) {
    sm += b[i] * (b[i] - 1) / 2;
  }

  for(int i=0;i<n;i++) {
    ll cal = sm;
    cal -= b[a[i]] * (b[a[i]] - 1) / 2;
    cal += (b[a[i]] - 1) * (b[a[i]] - 2) / 2;
    cout<<cal<<endl;
  }
}

Measured memory_bytes: 5760
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int ans;
void merge(vector<int> &A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> L(n1+1), R(n2+1);
  FOR(i,0,n1) L[i] = A[left+i];
  FOR(i,0,n2) R[i] = A[mid+i];
  L[n1] = 2e9;
  R[n2] = 2e9;
  int i = 0;
  int j = 0;
  FOR(k,left,right){
    ans ++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(vector<int> &A, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A,left,mid,right);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int> A(n);
  FOR(i,0,n) cin>>A[i];
  mergeSort(A, 0, n);
  FOR(i,0,n){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);
        int w = scn.nextInt();
        int n = scn.nextInt();

        int[] array;
        array = new int[w];

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

        String emp = scn.nextLine();

        for(int i = 0; i < n; i++){

            String str = scn.nextLine();
            int count = 0;

            for(int j = 0; j < str.length(); j++){
                if(str.charAt(j) == ',') break;
                count++;
            }

            int a = Integer.parseInt(str.substring(0,count));
            int b = Integer.parseInt(str.substring(count + 1));
            Swap(a,b,array);
        }

        for(int k = 0; k < w; k++){
            System.out.println(array[k]);
        }
    }

    static void Swap(int a,int b, int[] array) {
        int tmp = array[a - 1];
        array[a - 1] = array[b - 1];
        array[b - 1] = tmp;
    }
}



Measured memory_bytes: 26040
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7,M=N<<1;
const int mod=inf;

int f[N][3],pw2[N];
int v[N],nxt[N];
int p[N],dep[N],head[N],up[N],from[N];
int q[N],st,ed;
priority_queue<pii,vector<pii>,less<pii> > pq;
bool inq[N];
int n,ans;

il void dfs(const int &u){
	if(u){
		dep[u]=dep[p[u]]+1;
		up[u]=(nxt[head[p[u]]]?u:up[p[u]]);
	}
	for(int e=head[u];e;e=nxt[e]){
		dfs(v[e]);
	}
}

il int top(const int &u){
	return up[u]==u?u:up[u]=top(up[u]);
}

il void inc(int &x,const int &y){
	x+=y;
	if(x>=mod) x-=mod;
}

il void upd(int v,int u){
	if(!inq[v]) f[v][0]=1,f[v][1]=f[v][2]=0;
	ll cnt0=f[u][0]+f[u][2],cnt1=f[u][1];
	f[v][2]=((cnt0+cnt1)*f[v][2]+cnt1*f[v][1])%mod;
	f[v][1]=(cnt0*f[v][1]+cnt1*f[v][0])%mod;
	f[v][0]=(cnt0*f[v][0])%mod;
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	pw2[0]=1;
	rep(i,1,n+1){
		pw2[i]=pw2[i-1]<<1;
		if(pw2[i]>=mod) pw2[i]-=mod;
	}
	rep(i,1,n){
		scanf("%d",p+i);
		v[i]=i,nxt[i]=head[p[i]],head[p[i]]=i;
	}
	dfs(0);
	rep(i,1,n) cerr<<i<<" "<<up[i]<<endl;
	for(st=0,ed=0,q[ed]=0;st<=ed;){
		int cur=dep[q[st]],cnt=0;
		for(;st<=ed&&dep[q[st]]==cur;++st){
			int u=q[st];
			++cnt;
			f[u][0]=f[u][1]=1,f[u][2]=0;
			pq.push(mp(dep[u],u));
			inq[u]=true;
			for(int e=head[u];e;e=nxt[e]) q[++ed]=v[e];
			for(u=top(u);u;u=top(p[u])) from[p[u]]=(!from[p[u]]?u:-1);
		}
		while(!pq.empty()){
			pii tmp=pq.top();pq.pop();
			int u=tmp.Y,v=p[top(u)];
			inq[u]=false;
			if(from[u]>0) up[from[u]]=u;
			from[u]=0;
			if(!u){
				inc(ans,1ll*f[u][1]*pw2[n+1-cnt]%mod);
				break;
			}
			upd(v,u);
			if(!inq[v]){
				pq.push(mp(dep[v],v));
				inq[v]=true;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main () {
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	if (a >= k) printf("%d", k);
	else if (a + b >= k) printf("%d", a);
	else printf("%d", a - (k - a - b));
	return 0;
}


Measured memory_bytes: 3824
// C++ program to compute LCM of array elements modulo M 
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
#define int long long 
typedef long long ll; 
const int mod = 1000000007; 

int prime[MAX]; 
unordered_map<int, int> max_map; 

// Function to return a^n 
int power(int a, int n) 
{ 
	if (n == 0) 
		return 1; 
	int p = power(a, n / 2) % mod; 
	p = (p * p) % mod; 
	if (n & 1) 
		p = (p * a) % mod; 
	return p; 
} 
int inv(int a){
    return power(a,mod-2);
}
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
	prime[0] = prime[1] = 1; 
	for (int i = 2; i < MAX; i++) { 
		if (prime[i] == 0) { 
			for (int j = i * 2; j < MAX; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const int* ar, int n) 
{ 

	for (int i = 0; i < n; i++) { 
		int num = ar[i]; 
		unordered_map<int, int> temp; 

		// Temp stores mapping of prime factor to 
		// its power for the current element 
		while (num > 1) { 

			// Factor is the smallest prime factor of num 
			int factor = prime[num]; 

			// Increase count of factor in temp 
			temp[factor]++; 

			// Reduce num by its prime factor 
			num /= factor; 
		} 

		for (auto it : temp) { 

			// Store the highest power of every prime 
			// found till now in a new map max_map 
			max_map[it.first] = max(max_map[it.first], it.second); 
		} 
	} 

	ll ans = 1; 

	for (auto it : max_map) { 

		// LCM is product of primes to their highest powers modulo M 
		ans = (ans * power(it.F, it.S)) % mod; 
	} 

	return ans; 
} 
int dig(int a){
    int x=0;
    while(a!=0){
        x++;
        a/=10;
    }
    return x;
}
int fig(int a){
    int r;
    while(a!=0){
        r=a%10;
        a/=10;
    }
    return r;
}
// Driver code 
int32_t main() 
{ 
	sieve(); 
	int n;
	cin>>n;
	int arr[10][10];
	for(int i=0;i<10;++i)
	for(int j=0;j<10;++j)
	arr[i][j]=0;
	for(int i=1;i<=n;++i){
	    arr[fig(i)][i%10]++;
	}
	/*for(int i=0;i<10;++i)
	{
	    for(int j=0;j<10;++j)
	    cout<<arr[i][j]<<" ";
	    cout<<endl;
	}*/
	int ans=0;
    for(int i=1;i<=9;++i){
        for(int j=i+1;j<=9;++j){
            if(i==j)
            continue;
            ans+=arr[i][j]*arr[j][i];
            ans+=arr[j][i]*arr[i][j];
        }
    }
    for(int i=1;i<=9;++i){
        int tp=(arr[i][i])*(arr[i][i]);
        ans+=tp;
    }
    cout<<ans;
	return 0; 
} 


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}

int main() {
	COME_LET_THE_GAMES_BEGIN();
	string S;
	cin >> S;
	map<char,int> mp;
	for (auto x : S) {
		mp[x]++;
	}
	if (mp.size() != 2) {
		cout << "No" << endl;
		return 0;
	}
	for (auto x : mp) {
		if (x.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  set<ll> ms;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (ms.find(a) != ms.end()) {
      cout << "NO\n";
      return 0;
    }
    ms.insert(a);
  }
  cout << "YES\n";

  return 0;
}



Measured memory_bytes: 12956
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
const int INF = (1 << 30);

//毎回変える場所
#define N_MAX 200


//問題文のとおり
string a;
int main() {
	cin >> a;
	if (a.size() < 4) {
		cout << "No" << endl;
	}
	else if (a[0] == 'Y' && a[1] == 'A' && a[2] == 'K'&&a[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100001
int Partition(int[],int,int);

int main(){

  int A[N],n,i,q;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  q = Partition(A,0,n - 1);

  for(i = 0; i < q; i++) printf("%d ",A[i]);
  printf("[%d] ",A[q]);
  for(i = q + 1; i < n - 1; i++) printf("%d ",A[i]);
  printf("%d\n",A[n - 1]);

  return 0;
}

int Partition(int A[],int p,int r){

  int x,i,j,tmp;

  x = A[r];
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;

  return i + 1;
}

Measured memory_bytes: 988
x1, y1, x2, y2 = map(int,input().split())
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print(x3,end = " ")
print(y3,end = " ")
print(x4,end = " ")
print(y4)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

char s[107];

int main()
{
    int i,j;
    int cnt = 0;

    scanf("%s", s);
    int n = strlen(s);
    for( i=0; i<n/2; i++)
    {
        if( s[i] != s[n-1-i])
            cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
H, W, N = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
dic = {}
for l in L:
  try:
    dic[l[0]].append(l[1])
  except:
    dic[l[0]] = [l[1]]
def get(H, N):
  area = 1.
  for i in range(1, H):
    try:
      for block in sorted(dic[i+1]):
        if 1 <= block and block <= area:
          return i
      if not area+1 in dic[i+1]:
        area += 1
    except:
      area = area+1
  return H
print(get(H, N))

Measured memory_bytes: 81364
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

# st = Counter(raw_input())


a,b = map(int, input().rstrip().split())
ab = str(a) * b
ba = str(b) * a
if ab > ba:
    ab,ba = ba,ab

print(ab)


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

std::vector<long long> primes;
void eratos(int N){
    std::vector<bool> nop(N);

    for (int i = 2; i < N; ++i) {
        if(!nop[i]){
            primes.push_back(i);
            for (int k = i*2; k < N; k += i) {
                nop[k] = true;
            }
        }
    }
}

bool isPrime(long long k){
    return std::binary_search(primes.begin(), primes.end() , k);
}

int main() {
    eratos(55555);

    std::vector<int> A;
    int f = 1;
    int k = 0;
    for (int j = 0; j < 55; ++j) {
        while(primes[k] % 5 != f) k++;
        A.push_back(primes[k]);
        k++;
    }
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cout << A[i] << ' ';
    }
    std::cout << std::endl;

}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n;
vint h(100);


int main(){
    int n,k;
    cin>>n>>k;
    vll a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll ans=inf;
    rep(i,n-k+1){
        ans=min(ans,a[i+k-1]-a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < S.length(); i++) {
                ans.append("x");
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    const size_t L = S.size();


    if (L == 2) {
        if (S[0] == S[1]) {
            std::cout << "1 2" << std::endl;
        }
        else {
            std::cout << "-1 -1" << std::endl;
        }
        return 0;
    }

    for (size_t i = 2; i < L; ++i) {
        if (S[i-1] == S[i]) {
            std::cout << i << " " << i+1 << std::endl;
            return 0;
        }
        if (S[i-2] == S[i]) {
            std::cout << i -1 << " " << i+1 << std::endl;
            return 0;
        }
    }
    std::cout << "-1 -1" << std::endl;

    return 0;
}


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

typedef long long ll;

int main() {
    int N, L, maxL = 0, sumL = 0;
    cin >> N;
    rep(i, N) {
        cin >> L;
        maxL = max(maxL, L);
        sumL += L;
    }
    if (sumL - maxL > maxL) cout << "Yes\n";
    else cout << "No\n";
}

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

R = []
for i in range(n):
    R.append(int(input()))

minv = R[0]
maxv = R[1] - R[0]
for i in range(n-1):
    minv = min(R[i], minv)
    maxv = max(R[i+1] - minv, maxv)

print(maxv)



Measured memory_bytes: 13588
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a;
  vector<int>v(a);
  for(int i=0;i<a;i++)
    cin>>v[i];
  int ans=0;
  sort(v.begin(),v.end());
  for(int i=0;i<=a-3;i++)
  {
     for(int j=i+1;j<=a-2;j++)
     {
        for(int k=j+1;k<a;k++)
        {
           if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i])
              ans++;
           else
            break;
        }
     }
  }
  cout<<ans<<"\n";
}


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

int main(){
  string S;
  cin >> S;
  if(S=="SSS"){
    cout << 0 << endl;
  }
  else if(S=="RRR"){
    cout << 3 << endl;
  }
  else if(S=="RRS" || S=="SRR"){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

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

int main(){
    long long N;
    cin >>N;
    long long niro=26;
    long long mojisu=1;
    while(N>niro){
        niro = 26*niro + 26;
        mojisu++;
    }
    niro/=26;
    N-=niro;
    long long keta[mojisu];
    long long i;
    for(i=mojisu-1; i>=0; i--){
        keta[i]=N%26;
        N=(N-N%26)/26;
    }
    for(i=0; i<mojisu; i++){
        cout << (char)('a'+(int)keta[i]);
    }
    cout << endl;
    system("pause");
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>d1(n);
  vector<int>d2(n);
  cin >> d1[0];
  for(int i = 1;i < n;i++){
    int a;
    cin >> a;
    d1[i] = a+d1[i-1];
  }
  cin >> d2[0];
  for(int i = 1;i < n;i++){
    int a;
    cin >> a;
    d2[i] = a+d2[i-1];
  }
  int ans = d1[0]+d2[n-1];
  for(int i = 1;i < n;i++){
    if(d1[i] + d2[n-1]-d2[i-1] > ans) ans = d1[i] + d2[n-1]-d2[i-1];
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
	int a;
	int b;
	cin >> a >> b;

	int p = 1;
	int ans = 0;

	while (p < b)
	{
		p += (a - 1);
		ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    int u= s.length();
    if(s.equals(t.substring(0,u))) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35860
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;

#define MAX 50
int N,Ma,Mb,a[MAX],b[MAX],c[MAX];

int bf() {
  int mini = INT_MAX;
  REP(i,1,(1<<N)) {
    int sa = 0, sb = 0, sc = 0;
    rep(j,N) {
      if( (i>>j) & 1 ) {
	sa += a[j];
	sb += b[j];
	sc += c[j];
      }
    }
    int gcd = __gcd(sa,sb);
    sa /= gcd, sb /= gcd;
    if( sa == Ma && sb == Mb ) mini = min(mini,sc);
  }
  if( mini == INT_MAX ) mini = -1;
  return mini;
}

void compute() {
  map<ii,ll> dp,next;
  rep(i,N) {
    next.clear();
    next = dp;
    if( dp.count(ii(a[i],b[i])) == 0 ) {
      next[ii(a[i],b[i])] = c[i];
    } else {
      next[ii(a[i],b[i])] = min(dp[ii(a[i],b[i])],(ll)c[i]);
    }
    for(auto v : dp) {
      ii fir = v.first;
      ll sec = v.second;
      fir.first  += a[i];
      fir.second += b[i];
      //ll gcd = __gcd(fir.first,fir.second);
      //fir.first  /= gcd;
      //fir.second /= gcd;
      if( next.count(fir) ) next[fir] = min(next[fir],sec+(ll)c[i]);
      else                  next[fir] = sec + (ll)c[i];
    }
    dp = next;
  }
  ll mini = LLONG_MAX;
  for(auto v : dp) {
    ii fir = v.first;
    ll sec = v.second;
    ll gcd = __gcd(fir.first,fir.second);
    fir.first  /= gcd;
    fir.second /= gcd;
    if( fir.first == Ma && fir.second == Mb ) mini = min(mini,sec);
  }
  if( mini != LLONG_MAX ) cout << mini << endl;
  else puts("-1");
}

int main() {
  cin >> N >> Ma >> Mb;
  rep(i,N) cin >> a[i] >> b[i] >> c[i];
  compute();
  //cout << "Answer : " << bf() << endl;
  return 0;
}


Measured memory_bytes: 2944