akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(10000);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

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

using namespace std;

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

    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
}

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

int w[101] , c[101];

main()
{
	int n , s ;
	cin >> n >> s;
	vector <int> dp( n * 1e3 + 7 , INT_MAX );
	
	
	dp[0] = 0;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> w[i] >> c[i];
		
		for(int j = n * 1e3; j >= c[i]; j--)
		{
			dp[j] = min(dp[j] , dp[j - c[i]] + w[i]);
		}
	}
	
	for(int i = n * 1e3; i >= 0; i--)
	{
		if(dp[i] <= s)
			return cout << i , 0;
	}
		
	
	
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	while(n--){
		vector<int>in(10);
		rep(i,10)cin>>in[i];
		vector<int>a,b;
		a.pb(in[0]);
		bool h=true;
		loop(i,1,10){
			if(a[a.size()-1]<in[i])a.pb(in[i]);
			else if(b.size()==0||b[b.size()-1]<in[i])b.pb(in[i]);
			else {h=false;break;}
		}
		if(h)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1208
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);

		int n = Integer.parseInt(scanner.nextLine());
		int y = (int)((Math.ceil(n / 1000.0)) * 1000);
		int a = Math.abs(y - n);

		System.out.println(a);

	}
}

Measured memory_bytes: 35688
S = input()

cnt = 0
max_str = 0
flg = True
for x in range(len(S) + 1):
    for y in range(x, len(S) + 1):
        for i in range(len(S[x:y])):
            if "A" in (S[x:y][i]) or "C" in (S[x:y][i]) or "G" in (S[x:y][i]) or "T" in (S[x:y][i]):
                flg = True
            else:
                flg = False
                break
        if flg is True:
            max_str = max(max_str, len(S[x:y]))

print(max_str)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  rep(i,s.size()){
    int a=s[i]-'A';
    a=(a+n)%26;
    s[i]=(char)(a+'A');
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    adic = dict()
    ans = 0

    for i in range(n):
        a = inlis[i]
        if a not in adic:
            adic[a] = 1
        else:
            adic[a] += 1
        if adic[a] > a:
            ans += 1
    
    for num in adic:
        if adic[num] < num:
            ans += adic[num]

    print(ans)
            

        


if __name__ == "__main__":
    main()

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

int main() {
	// your code goes here
	int n,m,i,j,con[607]={0},don[607];
	int s[400005],t[400005];
	double px[607],qx[607],pg[607]={0},qg[607]={0},pm,pmk,pmm,memo,mpt;
	vector<int> g[607],h[607];
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> s[i] >> t[i];
		g[s[i]].push_back(t[i]);
		h[t[i]].push_back(s[i]);
	}
	con[n]=1;
	px[n]=0;
	pg[1]=1;
	for(i=n-1;i>=1;i--){
		for(j=0;j<g[i].size();j++){
			con[i]+=con[g[i][j]];
			px[i]+=px[g[i][j]];
		}
		px[i] /= (double)g[i].size();
		px[i] += 1;
	}
	for(i=1;i<n;i++){
		for(j=0;j<g[i].size();j++){
			pg[g[i][j]] += (double)pg[i] / (double)g[i].size();
		}
	}
	don[1]=1;
	qx[1]=0;
	qg[n]=1;
	for(i=2;i<=n;i++){
		for(j=0;j<h[i].size();j++){
			don[i]+=don[h[i][j]];
			qx[i]+=qx[h[i][j]];
		}
		qx[i] /= (double)h[i].size();
		qx[i] += 1.0;
	}
	for(i=n;i>1;i--){
		for(j=0;j<h[i].size();j++){
			qg[h[i][j]] += (double)qg[i] / (double)h[i].size();
		}
	}
	pm = px[1];
	pmk = px[1];
	pmm = px[1] * (double)con[1];
	for(i=0;i<m;i++){
		double pmr;
		pmr=pmk;
		if(g[s[i]].size()==1&&h[s[i]].size()>=1) continue;
		mpt = pg[s[i]]/(double)g[s[i]].size();
		pmr -= mpt;
		pmr -= mpt * px[t[i]];
		memo = (px[s[i]] - (1.0 + px[t[i]]) / (double)g[s[i]].size())/(1.0-1.0/(double)g[s[i]].size());
		pmr += mpt * memo;
		pm=min(pm,pmr);
		
	}
	//printf("%.13lf\n",pmk);
	printf("%.13lf\n",pm);
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n+1];
        a[0] = 1L;
        for (int i = 1;i<=n;++i) a[i] = sc.nextLong();
        sc.close();

        List<Long> list = new ArrayList<>();

        for (int i = k;i<=n;++i)
        {
            if (i == k)
            {
                for (int j = k;j>i-k;--j)
                {
                   list.add(a[j]);
                }
            }
            else
            {
                long befoer = list.remove(k-1);
                long now = a[i];
                if (a[i] > befoer) System.out.println("Yes");
                else System.out.println("No");

                list.add(0,now);
            }
        }
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 62476
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f
#define N 1003
using namespace std;


int mar[N][N];
char grid[N][N];

int id = 1;

int n, m;
void go(int i, int j, int x){
	if(i < 0 || i >= n) return;
	if(j<0 || j >=m) return;
	if(grid[i][j] == '#') return;
	if(mar[i][j] != 0) return;
	mar[i][j] = x;
	go(i+1, j, x);
	go(i-1, j, x);
	go(i, j+1, x);
	go(i, j-1, x);
}


int bi, bj;
int ei, ej;

int dist[N][N];
bool vis[N][N];
typedef pair<int,int> pii;
typedef pair<int, pii> piii;

const int inf = 5000000;

bool valid(int i, int j){
	if(i < 0 || i >= n) return 0;
	if(j<0 || j >=m) return 0;
	if(grid[i][j] == '#') return 0;
	if(vis[i][j]) return 0;
	return 1;
}

int dij(){
	if(!valid(bi, bj))
		return inf;
	dist[bi][bj] = 0;
	priority_queue<piii, vector<piii>, greater<piii>> q;
	q.push({0, {bi, bj}});
	while(!q.empty()){
		int x,y;
		tie(x,y) = q.top().nd;
		int d = q.top().st;
		vis[x][y] = 1;
		if(tie(x,y) == tie(ei,ej))
			return dist[ei][ej];
		q.pop();
		
		for(int i = x-2; i <=x+2; i++){
			for(int j=y-2; j<= y+2; j++){
				if(!valid(i,j))continue;
				int d2 = d + (mar[x][y]!=mar[i][j]);
				if(d2 < dist[i][j]){
					dist[i][j] = d2;
					q.push({d2, {i,j}});
				
				}
			}
		}
	
	
	}
	
	
	return dist[ei][ej];
}

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

	cin>>n>>m;
	cin>>bi>>bj>>ei>>ej;
	bi--; bj--;
	ei--; ej--;
	for(int i=0;i<n;i++){
		string s; cin>>s;
		for(int j=0;j<m;j++)
			grid[i][j] = s[j];
	}
	int t = 1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++){
			dist[i][j] = inf;
			if(grid[i][j] == '.' && mar[i][j] == 0){
				go(i,j,t);
				t++;
			}
		}
	auto aux = dij();
	
	if(aux == inf)cout<<"-1\n";
	else cout<<aux<<"\n";
	return 0;	
}


Measured memory_bytes: 13404
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

INF = 100100100

class Queue:
    __slots__ = ['Q', 'begin', 'end']
    def __init__(self):
        self.Q = [None] * 100
        self.begin = 0
        self.end = 0
    def full(self) -> bool:
        if self.begin == 0 and self.end == 99:
            return True
        elif self.begin == self.end + 1:
            return True
        else:
            return False
    def empty(self) -> bool:
        if self.begin == self.end:
            return True
        else:
            return False
    def insert(self, num: int):
        if self.full():
            print('Error: Queue is full.')
        else:
            if self.end == 99:
                self.end = 0
            else:
                self.end += 1
            self.Q[self.end-1] = num
    def pop(self) -> int:
        if self.empty():
            print('Error: Queue is empty.')
            return
        else:
            if self.begin == 99:
                self.begin = 0
                return self.Q[99]
            else:
                self.begin += 1
                return self.Q[self.begin-1]

def bfs(M: list, visited: list, d: list, v: int = 0):
    n = len(visited)
    Q = Queue()
    visited[v] = True
    d[v] = 0
    Q.insert(v)
    while not Q.empty():
        u = Q.pop()
        for i in range(n):
            if M[u][i] == 1 and not visited[i]:
                visited[i] = True
                d[i] = d[u] + 1
                Q.insert(i)


def main():
    n = int(input())
    M = [[0]*n for _ in range(n)]
    for _ in range(n):
        a = list(map(int, input().split()))
        i = a[0]-1
        for j in range(a[1]):
            k = a[j+2]-1
            M[i][k] = 1
    visited = [False] * n
    d = [INF] * n
    bfs(M, visited, d)
    for i, l in enumerate(d):
        if l == INF:
            print(i+1, -1)
        else:
            print(i+1, l)

if __name__ == '__main__': main()


Measured memory_bytes: 5684
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  
  int K,T;
  cin>>K>>T;
  int num[101];
  for(int i=0;i<T;i++)cin>>num[i];
  sort(num,num+T);
  

  int ans=0;
  if(num[T-1]>K-num[T-1]) ans=num[T-1]-(K-num[T-1])-1;
  cout << ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n,K = gets.split(' ').map!(&:to_i)

D = gets.split(' ')
while TRUE do
    n_uniq = n.to_s.split('').uniq

    if (n_uniq - D).length == n_uniq.length
        puts n
        break
    else
        n += 1
    end
end
  
      

Measured memory_bytes: 2044
n, m = map(int, input().split())

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

ans = [True]*n

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    if h[a] <= h[b]:
        ans[a] = False
    if h[a] >= h[b]:
        ans[b] = False

print(sum(ans))

Measured memory_bytes: 86256
#include <stdio.h>

class Dice2{
public:
	Dice2(){
		number = new int[6];
		relative = new int[55];
		relative[31] = relative[43] = relative[24] = relative[12] = 0;
		relative[3] = relative[20] = relative[52] = relative[35] = 1;
		relative[1] = relative[40] = relative[54] = relative[15] = 2;
		relative[4] = relative[10] = relative[51] = relative[45] = 3;
		relative[2] = relative[30] = relative[53] = relative[25] = 4;
		relative[21] = relative[42] = relative[34] = relative[13] = 5;
 	};
	~Dice2(){
		delete[] number;
		delete[] relative;
	};

	void setNumber(int index,int num){
		number[index] = num;
	};

	int returnRight(int top,int front){
		int top_index,front_index;
		for(int i = 0; i < 6; i++){
			if(number[i] == top)
				top_index = i;
			if(number[i] == front)
				front_index = i;
		}
		return number[relative[10*top_index+front_index]];
	}
private:
	int* number;
	int* relative;
};

int main(){
	Dice2 dice2;
	int x,q,top,front;
	for(int i = 0; i < 6; i++){
		scanf("%d",&x);
		dice2.setNumber(i,x);
	}
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%d %d",&top,&front);
		printf("%d\n",dice2.returnRight(top,front));
	}
}


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

class Main {
	public static void main (String[] args) {
		Scanner input=new Scanner(System.in);
		int s,w;
		s=input.nextInt();
		w=input.nextInt();
		if(w>=s)
		    System.out.println("unsafe");
		 else
		  System.out.println("safe");
		input.close();
	}
}

Measured memory_bytes: 35736
#include<iostream>

using namespace std;

int main()
{
    int arr1[7] = {1,3,5,7,8,10,12};
    int arr2[4] = {4,6,9,11};
    int arr3[1] = {2};
    int a, b;
    cin>>a>>b;
    int p = 0,q = 0;
    if(a != 2)
    {
        for(int i = 0; i < 4; i++)
        {
            if(a == arr2[i])
            {
                p = 1;
                break;
            }
        }
    }
    else p = 2;
    if(b != 2)
    {
        for(int i = 0; i < 4; i++)
        {
            if(b == arr2[i])
            {
                q = 1;
                break;
            }
        }
    }
    else q = 2;
    if(p == q) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3676
/*input
10
33 18 45 28 8 19 89 86 2 4
*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}
const ll N = 1e6+5;
int solve()
{
	ll n;cin>>n;

	// n=N;
	// vi a(n);
	// rep(i,0,n) a[i]=i+2;

	vi a(n);
	rep(i,0,n) cin>>a[i];
	sort(a.begin(), a.end());

	vi pos(N,-1);
	rep(i,0,n) if(pos[a[i]]==-1) pos[a[i]]=i; 

	vi ans(n,1);
	ll cnt=0;
	rep(i,0,n)
	{
		if(i==0 || (ans[i]==1 && a[i]!=a[i-1])  ) for(ll j = 2*a[i];j<N;j+=a[i]) if(pos[j]!=-1) ans[pos[j]]=0;

	} 

	rep(i,1,n) if(a[i]==a[i-1]) ans[i]=0,ans[i-1]=0;
	rep(i,0,n) cnt+=ans[i];
	cout<<cnt<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main(void){
  int h,w;
  cin >> h >> w;
  int cnt[30];
  fill(cnt,cnt+30,0);
  for(int i = 0;i < h;++i){
    string s;
    cin >> s;
    for(int i = 0;i < (int)s.size();++i){
      ++cnt[s[i]-'a'];
    }
  }
  int odd = 0;
  for(int i = 0;i < 30;++i){
    if(cnt[i] % 2 == 1)++odd;
  }
  
  if((h*w) % 2 == 0 && odd != 0){
    puts("No");
    return 0;
  }else if((h*w) % 2 == 1 && odd != 1 ){
    puts("No");
    return 0;
  }
  int calc = 0;
  for(int i = 0;i < 30;++i){
    cnt[i] %= 4;
    calc += (cnt[i] / 2)*2;
  }
  int cmp;
  if(h % 2 == 1 && w % 2 == 1)cmp = w + h - 2;
  else if(h % 2 == 1) cmp = w;
  else if(w % 2 == 1) cmp = h;
  else cmp = 0;
  if(calc > cmp)puts("No");
  else puts("Yes");
  return 0;
}


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

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

max = sorted(A)[-1]
semi_max = sorted(A)[-2]

if max != semi_max:
    ex = A.index(max)
    
    for i in range(0,ex):
        print(max)
    
    print(semi_max)
    
    for i in range(ex+1,N):
        print(max)

else:
    for i in range(N):
        print(max)

Measured memory_bytes: 19104
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,double> mypair;
typedef complex<double> point;
#define EPS 1e-6
/*mypair in(){
	int x,y;
	cin>>x>>y;
	return mypair(x,y);
}*/
point make(){
	double x,y;
	cin>>x>>y;
	point c(x,y);
	return c;
}
bool is_arg(double a,double b){
			point c(-1,0);
			double pi = 2*arg(c);
			//cout<<"pi "<<pi<<endl;
	if(abs(a-b) <= EPS)return true;
	if(abs(a-b+pi) <= EPS)return true;
	if(abs(a-b-pi) <= EPS)return true;
	return false;
}

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		n++;
		vector<vector<point> > p(n);
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++)p[i].push_back(make() );
		}
		vector<mypair> origin[2];//abs,arg
		int size = p[0].size();
			point now1 = p[0][0];
			point now2 = p[0][size-1];
		for(int j=1;j<size;j++){
			point tmp1 = p[0][j]-now1;
			point tmp2 = p[0][size-1-j]-now2;
			origin[0].push_back(mypair(abs(tmp1),arg(tmp1) ) );
			origin[1].push_back(mypair(abs(tmp2),arg(tmp2) ) );
			now1 = p[0][j];
			now2 = p[0][size-1-j];
		}
		vector<vector<mypair> > a(n);
		double arg1 = origin[0][0].second;
		double arg2 = origin[1][0].second;

		/*cout<<"arg "<<arg1<<' '<<arg2<<endl;
		for(int i=0;i<2;i++){
			for(int j=0;j<origin[i].size();j++){
				cout<<origin[i][j].first<<' '<<origin[i][j].second<<"  ";
			}
			cout<<endl;	
		}
		cout<<endl;*/
		for(int i=1;i<n;i++){
			point now = p[i][0];
			for(int j=1;j<p[i].size();j++){
					point tmp =p[i][j]-now;
				a[i].push_back(mypair(abs(tmp),arg(tmp) ) );
			//	cout<<a[i][j-1].first<<' '<<a[i][j-1].second<<"  ";
				now = p[i][j] ;
			}
		//	cout<<endl;
		}
		vector<int> ans;
		for(int i=1;i<n;i++){
			bool flag1 = true,flag2 = true;
				if( p[i].size() != size) continue;
				double d1  =  a[i][0].second - arg1 ,d2 = a[i][0].second - arg2;
				for(int j=0;j<size-1;j++){
					if(a[i][j].first == origin[0][j].first && is_arg(a[i][j].second-origin[0][j].second , d1)  ) {
					}else
					{	
						flag1 = false;
						break;
					} 
					
					/*if(a[i][j].first != origin[0][j].first || a[i][j].second-origin[0][j].second != d1) {
						flag1 = false;
						break;
					}*/
				}

				for(int j=0;j<size-1;j++){
					if(a[i][j].first == origin[1][j].first && is_arg(a[i][j].second-origin[1][j].second, d2) ){
					       
					}else	
					{
						flag2 = false;
						break;
					}
					/*if(a[i][j].first != origin[1][j].first || a[i][j].second-origin[1][j].second != d2) {
						flag2 = false;
						break;
					}*/

				}
				if(flag1 || flag2 ) ans.push_back(i);
		}
		for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
		cout<<"+++++"<<endl;
	}
	return 0;
}




Measured memory_bytes: 3456
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
Ddic = defaultdict(int)
Tdic = defaultdict(int)

for d in D:
    Ddic[d] += 1
for t in T:
    Tdic[t] += 1
for n, v in Tdic.items():
    Ddic[n] -= v
dv = Ddic.values()
if all(i >= 0 for i in dv):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 57056
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200010*3,mod=998244353;
int p[200];
int n,len,cnt[3],s[3][3];
ll ans=1;
char a[N];
int main()
{
	scanf("%d%s",&n,a+1);
	p['R']=1;p['G']=2;
	for(int i=1;i<=n*3;i++)
	{
		int x=p[a[i]];
		if(x==0)
		{
			if(s[1][2])ans=(ans*s[1][2])%mod,s[1][2]--;
			else if(cnt[1])ans=(ans*cnt[1])%mod,cnt[1]--,s[0][1]++;
			else if(cnt[2])ans=(ans*cnt[2])%mod,cnt[2]--,s[0][2]++;
			else cnt[0]++;
		}
		else if(x==1)
		{
			if(s[0][2])ans=(ans*s[0][2])%mod,s[0][2]--;
			else if(cnt[0])ans=(ans*cnt[0])%mod,cnt[0]--,s[0][1]++;
			else if(cnt[2])ans=(ans*cnt[2])%mod,cnt[2]--,s[1][2]++;
			else cnt[1]++;
		}
		else
		{
			if(s[0][1])ans=(ans*s[0][1])%mod,s[0][1]--;
			else if(cnt[1])ans=(ans*cnt[1])%mod,cnt[1]--,s[1][2]++;
			else if(cnt[0])ans=(ans*cnt[0])%mod,cnt[0]--,s[0][2]++;
			else cnt[2]++;
		}//cout<<cnt[0]<<" "<<cnt[1]<<" "<<cnt[2]<<endl;
	}for(int i=1;i<=n;i++)ans=(ans*i)%mod;
	cout<<ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <queue>

using namespace std;

const string res = "1112131415161700212223242526270031323334353637004142434445464700";
string str;
vector<int> pt;
map<string, bool> mpp;

class St{
public:
  int cnt;
  string st;
  vector<int> vec;

  St() {}
  St(int _cnt, string _st, vector<int> _vec): cnt(_cnt), st(_st), vec(_vec) {}
};

string conv(int n)
{
  stringstream ss;
  ss << n;

  return ss.str();
}

void func(vector<vector<int> > vec)
{
  int t;
  str = "";

  for(int i = 0; i < 4; ++i){
    str += "00";
    for(int j = 0; j < 7; ++j) str += conv(vec[i][j]);
  }

  for(int i = 0; i < 4; ++i)
    for(int j = 1; j < 8; ++j)
      if(vec[i][j-1]%10 == 1){
	t = ((int)(vec[i][j-1]/10)-1)*2*8;
	str[t] = str[i*2*8+j*2];
	str[t+1] = str[i*2*8+j*2+1];
	str[i*2*8+j*2] = '0';
	str[i*2*8+j*2+1] = '0';
	pt.push_back((i*8*2+j*2));
      }
}

int check(string s, char c1, char c2)
{
  for(int i = 0; i < 4; ++i)
    for(int j = 0, p = i*8*2; j < 8; ++j)
      if(s[p+j*2] == c1 && s[p+j*2+1] == c2) return (p+j*2);

  return 0;
}

int bfs()
{
  queue<St> que;
  que.push(St(0, str, pt));
  mpp[str] = true;
  St st;
  int p, q;
  char c1, c2;
  string s;
  vector<int> v;

  while(!que.empty()){
    st = que.front();
    que.pop();

    if(st.st == res) return st.cnt;
    for(int i = 0; i < 4; ++i){
      q = st.vec[i];
      c1 = st.st[q-2];
      c2 = (char)(st.st[q-1]+1);
      if(c2 == '8') continue;
      p = check(st.st, c1, c2);
      if(p == 0) continue;
      s = st.st;
      s[q] = c1;
      s[q+1] = c2;
      s[p] = s[p+1] = '0';
      st.vec[i] = p;
      if(!mpp[s]){
	mpp[s] = true;
	que.push(St(st.cnt+1, s, st.vec));
      }
      st.vec[i] = q;
    }
  }

  return -1;
}

int main()
{
  int n, t;
  vector<vector<int> > vec;

  while(cin>>n)
    while(n--){
      vec = vector<vector<int> >(4);
      for(int i = 0; i < 4; ++i){
	vec[i] = vector<int>(7);
	for(int j = 0; j < 7; ++j) cin >> vec[i][j];
      }
      func(vec);
      vec.clear();

      cout << bfs() << endl;
      mpp.clear();
      pt.clear();
    }

  return 0;
}

Measured memory_bytes: 8804
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	cin>>n;
	int cnt = 0;
	while(n>1){
		if(n%3!=0){
			n /=3;
			n++;
		}else{
			n /=3;
		}
		cnt++;
	}
	cout <<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1164
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
H a[100000];
int b[100003];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		b[a[i].x]++; b[a[i].y + 1]--;
	}
	for (int i = 1; i < 100003; i++) {
		b[i] += b[i - 1];
	}
	int ans = 0;
	for (int i = 0; i <= 100000; i++) {
		if (b[i + 1] >= i) ans = i;
	}
	cout << ans << endl;
	getchar(); getchar();
}


Measured memory_bytes: 5052
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    string s;
    cin >> s;
    int ans = 0, c = 0;
    for (auto &i: s) {
        if (i == 'R') {
            ++c;
        }
        else {
            c = 0;
        }
        ans = max(c, ans);
    }
    cout << ans << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3676
n, m = map(int, input().split())

num = [''] * n

flag = 0
for i in range(m):
    s, c = map(int, input().split())
    if num[s - 1] == '' or num[s - 1] == c:
        num[s - 1] = c
    else:
        print(-1)
        break
else:
    if num[0] == '':
        if n > 1:
            num[0] = 1
        else:
            num[0] = 0
    for i in range(1, n):
        if num[i] == '':
            num[i] = 0
    if n > 1 and num[0] == 0:
        print(-1)
    else:
        print(''.join(map(str, num)))

Measured memory_bytes: 9244
#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;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  sort(a.begin(), a.end(), greater<int>());
  cout << a[0]-a[n-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}

///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
        cout<<p<<' ';
          //cout <<  << " ";
}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;


int main()
{
    ios::sync_with_stdio(false);
    double n;
    cin>>n;
    double d = n/1.08;
    int v = (int) d;
    int u = v+1;
    //cout<<abs(v - d)<<' '<<abs(u - d)<<'\n';
    if((int)(v*1.08)==n){
        cout<<(int)d<<'\n';
    }
    else if((int)(u*1.08)==n){
        cout<<u<<'\n';
    }
    else cout<<":("<<'\n';
    //cout<<d<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ll H,W;
  ll samex,samey,res, halfy;
  cin >> H >> W;
  if(H%2!=0){
    samey = H/2+1; 
  }else{
    samey = H/2;
  }
  if((H-1)%2!=0){
    halfy = (H-1)/2+1;
  }else{
    halfy = (H-1)/2;
  }
  if(W%2!=0){
    samex = W/2+1;
  }else{
    samex = W/2;
  }
  if(H==1 || W==1){
    res = 1;
  }else{
  res = samex*samey+halfy*(W-samex);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7; int n,ans,a[N];
inline bool cmp(int a,int b){
	return a>b;
}
int main(){
    scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
        if(i+1>a[i+1]){
            for(int j=i+1;a[j]==i;j++) ans^=1; ans|=(a[i]-i)&1;
			if(ans) puts("First"); else puts("Second"); break;
        }
    return 0;
} 

Measured memory_bytes: 640
#!/usr/bin/env python3
#ABC52 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()
x = LI()
x.sort()
ans = 0
for i in range(1,n):
    ans += min((x[i]-x[i-1])*a,b)
print(ans)


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

int main(void)
{
    int N;
    cin >> N;
    map<string, int> d;

    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        d[s]++;
    }

    int mx = 0;
    for (auto p : d)
    {
        mx = max(mx, p.second);
    }
    for (auto p : d)
    {
        if (p.second != mx)
            continue;
        cout << p.first << " ";
    }
}

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

int main(void){
    int n, m;
    cin >> n >> m;
    string num = "";
    rep(i, n) num += '.';
    
    rep(i, m) {
        int s;
        char c;
        cin >> s >> c;
        
        if (num[s-1] == '.')
            num[s-1] = c;
        else if (num[s-1] != c) {
            num = "-1";
            break;
        }
    }
    
    if (num == "-1")
        cout << -1;
    else {
        rep(i, n) {
            if (num[i] == '.') {
                if (n != 1 && i == 0)
                    num[i] = '1';
                else
                    num[i] = '0';
            }
        }
        
        if (n != 1 && num[0] == '0')
            cout << -1;
        else
            cout << num;
    }
}

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

using namespace std;

int N, Q;
bool Cards[300001];


bool findCurrentMax(int *pNum) {
	while (!Cards[*pNum]) {
		--(*pNum);
		if (*pNum < 1) {
			return false;
		}
	}

	return true;
}

int main() {
	int num, rest, currentMax, maxRest, maxNum;

	memset(Cards, false, sizeof(Cards));
	maxNum = 0;
	cin >> N >> Q;
	for (int i = 0; i < N; ++i) {
		cin >> num;
		Cards[num] = true;
		maxNum = max(maxNum, num);
	}

	for (int i = 0; i < Q; ++i) {
		cin >> num;
		maxRest = -1;
		currentMax = maxNum;

		while (true) {
			rest = currentMax % num;
			maxRest = max(maxRest, rest);
			currentMax = currentMax - rest - 1;
			if (currentMax < 1) {
				break;
			}
			if (!findCurrentMax(&currentMax)) {
				break;
			}
			//cout << "=" << currentMax << endl;
		}
		cout << maxRest << endl;
	}

	return 0;
}



Measured memory_bytes: 3376
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> C(N);
  REP(i, N) cin >> C[i];

  sort(ALL(C), greater<>());

  int plus = 1;
  REP(i, N-1) (plus *= 2) %= MOD;

  int now = (plus*2)%MOD;

  int ans = 0;
  REP(i, N){
    (ans += now*C[i]) %= MOD;
    (now += plus) %= MOD;
  }

  REP(i, N-1) (ans *= 2) %= MOD;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1792
import sys


def main():
    X, K, D = map(int, sys.stdin.readline().rstrip().split())

    # 0方向に移動
    q, r = divmod(abs(X), D)

    if K <= q:
        X = abs(X) - K * D
        print(abs(X))
        return

    K -= q

    if K % 2 == 0:
        print(abs(r))
    else:
        print(abs(abs(r) - D))


main()


Measured memory_bytes: 9160
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
#include <bitset>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int a[4], b[4];

    vector<int> num(5, 0);
    //入力
    rep(i,3) {
        int a, b;
        cin >> a >> b;
        num[a]++; num[b]++;
    }
    
    rep(i,4) if(num[i+1] >= 3) { cout << "NO" << endl; return 0; }
    cout << "YES" << endl;

    //cout << endl; 
    //rep(i,4) cout << num[i+1] << endl;

    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] s = new int[N + 1];
		int sum = 0, min = 0, ans = 0;

		for (int i = 0; i < N; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
		}

		if (sum % 10 == 0) {
			for (int i = 0; i < N; i++) {
				if (s[i] % 10 != 0) {
					min = s[i];
					break;
				}
			}
			for (int i = 0; i < (N - 1); i++) {
				if (min > s[i + 1] && s[i + 1] % 10 != 0) {
					min = s[i + 1];
				}
			}
		}

		if (((sum - min) % 10) == 0) {
			ans = 0;
		} else {
			ans = sum - min;
		}

		System.out.println(ans);

		sc.close();
	}
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    int n, m, q;
    cin >> n >> m >> q;

    int ans=0, tmp;

    vector<int> a(q),b(q),c(q),d(q);
    REP(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    m++;
    FOR(i1, 1, m)
    FOR(i2, i1, m)
    FOR(i3, i2, m)
    FOR(i4, i3, m)
    FOR(i5, i4, m)
    FOR(i6, i5, m)
    FOR(i7, i6, m)
    FOR(i8, i7, m)
    FOR(i9, i8, m)
    FOR(i10, i9, m){
        int sumd = 0;
        vector<int> v = {0,i1, i2, i3, i4, i5, i6, i7, i8, i9, i10};
        //REP(_,SZ(v)){cout << v[_];}cout << "\n";
        REP(i,q){
            //REP(_, q) { cout << v[b[i]] << v[a[i]]cout << "\n";
            if(v[b[i]]-v[a[i]]==c[i]){
                sumd += d[i];
            }
        }
        ans = max(ans, sumd);
    }
    cout<< ans << "\n";

    return 0;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final double x1 = sc.nextDouble();
		final double y1 = sc.nextDouble();
		final double x2 = sc.nextDouble();
		final double y2 = sc.nextDouble();
		
		System.out.printf("%.7f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
		
	}
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ; 
  cin >> n >> k ;
  
  cout << n - k +1 ;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(){

  int A[100];
  int flag = 1;
  int times = 0;
  int i, j, k, N, B;
  
  scanf("%d", &N);
  for ( i = 0; i <= N - 1; i++){
    scanf("%d", &A[i]);
  }
  
  //bubbleSort
  while(flag == 1){
    flag = 0;
    for ( j = N - 1; j >= 1; j--){
      if( A[j] < A[j-1]){
        B = A[j];
        A[j] = A[j-1];
        A[j-1] = B;
        times = times + 1;
        flag = 1;
      }
    }
  }
   
  //OutPut
  for ( i = 0; i <= N - 2; i++){
    printf("%d ", A[i]);
  }
  printf("%d\n", A[N-1]);
  printf("%d\n", times);
  
  return 0;
}
  

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int N,K,p[3];
    cin>>N>>K;
    REP(i,3) cin>>p[i];
    string t;
    cin>>t;
    vector<vector<int>> dp(N+1,vector<int>(3));
    map<char,int> mp;
    mp['r']=2;
    mp['s']=0;
    mp['p']=1;
    REP(i,N){
        REP(j,3){
            if(i<K){
                if(j==mp[t[i]]) dp[i][j]=p[j];
                else dp[i][j]=0;
            }
            else{
                if(j==mp[t[i]]){
                    dp[i][j]=max(dp[i-K][(j+1)%3],dp[i-K][(j+2)%3])+p[j];
                }
                else{
                    dp[i][j]=max(dp[i-K][(j+1)%3],dp[i-K][(j+2)%3]);
                }
            }
        }
    }
    int ans=0;
    rep(i,N-K,N){
        int tmp=0;
        REP(j,3) tmp=max(tmp,dp[i][j]);
        ans+=tmp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
    int n,m,l;
    int i,j,k;
    scanf("%d %d %d\n",&n,&m,&l);
    int a[n][m];
    int b[m][l];
    long long c[n][l];
    //n*m??????A???????????????
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d ",&a[i][j]);
        }
    }
    //m*l??????b???????????????
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d ",&b[i][j]);
        }
    }
    //n*l??????c????±???????
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            c[i][j]=0;
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    ///n*l???????????¨???
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%lld",c[i][j]);
            if(j<l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    vector<int>a(4);
    rep(i,4)cin >> a[i];
    sort(a.begin(),a.end());
    if(a[0] == 1 and a[1] == 4 and a[2] == 7 and a[3] == 9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc178/tasks/abc178_b"

def main():
    s = int(input())
    count = 0
    for i in range(s):
        d1, d2 = list(map(int, input().split()))
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 62368
def shiftonly(n , al):

    ans = 0
    flag = True

    while flag:
        for i in range(n):
            if al[i] % 2 == 1:
                flag = False
                break
            else:
                al[i] = al[i] / 2
        if flag:
            ans += 1


    return ans

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(shiftonly(n , al))

if __name__ == '__main__':
    main()


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

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

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

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

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

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

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

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	bool OK=false;
	Rep0(i, 3)
		if ('7'==S.at(i))
			OK=true;
	if (OK)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 3632