akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

inline int read() {
	char v = getchar();int x = 0,f = 1;
	while (!isdigit(v)) {if (v == '-')f = -1;v = getchar();}
	while (isdigit(v)) {x = x * 10 + v - 48;v = getchar();}
	return x * f;
}
const int N = 1001;
const int M = 500001;

int to[M],hd[N],nxt[M],tot;

inline void add(int u,int v) {to[++tot] = v;nxt[tot] = hd[u];hd[u] = tot;}

inline int min(int x,int y) {return x<y?x:y;}
inline int max(int x,int y) {return x>y?x:y;}

inline int gts(char x) {
	if (x == '0') {
		return 0;
	}
	if (x == '1') {
		return 1;
	}
}

int ans,n,p[N],cnt,ind[N],tim,g[N][N];
char s[N];
int vis[N];
void bfs(int s) {
    memset(vis,0,sizeof(vis));
    vis[s] = 1;
    for (int i = 1;;++i) {
        int op = 0;
        for (int j = 1;j <= n;++j) {
            if (vis[j] == i) {
                for (int k = 1;k <= n;++k) {
                    if (g[j][k]) {
                        if (!vis[k]) vis[k] = i+1;
                        else if (vis[k] == i) return ;
                    }
                    op = 1;
                }
            }
        }
        if (!op) {
            tim = max(tim,i);
            return ;
        }
    }
}

int main() {
	cin >> n;
	for (int i = 1;i <= n;++i) {
		scanf("%s",s);
		for (int j = 0;j < n;++j) {
            g[i][j+1] = s[j] - 48;
		}
	}
    for (int i = 1;i <= n;++i) {
        bfs(i);
    }
    printf("%d",tim-1);
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
long long int a[100000];
int main(){
	long long int a, c = 0;
	long long int m;
	string b;
	cin >> a >> b;
	int n = b.size();
	c += (b[3] - '0');
	c += (b[2] - '0') * 10;
	c += (b[0] - '0') * 100;
	cout << (a * c / 100) << endl;

}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    
    if(N%2==0){
        vvll dp(N/2,vll(2,0));//奇数にシフト
        for(int i=0;i<N/2;i++){
            if(i==0){
                dp[0][0]=A[0];
                dp[0][1]=A[1];
            }else{
                dp[i][0]=A[i*2]+dp[i-1][0];
                dp[i][1]=max(dp[i-1][1],dp[i-1][0])+A[2*i+1];
            }
        }
        cout<<max(dp[N/2-1][0],dp[N/2-1][1])<<endl;
    }else{
        vvll dp(N/2,vll(3,0));
        for(int i=0;i<N/2;i++){
            if(i==0){
                dp[0][0]=A[0];
                dp[0][1]=A[1];
                dp[0][2]=A[2];
            }else{
                dp[i][0]=A[i*2]+dp[i-1][0];
                dp[i][1]=max(dp[i-1][1],dp[i-1][0])+A[2*i+1];
                dp[i][2]=max(dp[i-1][2],dp[i-1][1])+A[i*2+2];
            }
        }
        cout<<max(dp[N/2-1][2],max(dp[N/2-1][0],dp[N/2-1][1]))<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 10336
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll f(ll n,ll p){
	ll cnt=p;
	ll a[100]={};
	while(1){
		for(ll crr=0;crr<n;crr++){
			if(cnt==0){
				cnt+=a[crr];
				a[crr]=0;
			}else{
				cnt--;
				a[crr]++;
				if(a[crr]==p)return crr;
			}
		}
	}
}

int main(){
	ll n,p;
	while(scanf("%lld%lld",&n,&p),n){
		printf("%lld\n",f(n,p));
	}
}



Measured memory_bytes: 2032
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    double x, ans = 0;
    string u;
    rep(i, 0, n)
    {
        cin >> x >> u;
        if (u == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x*380000.0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Mu-Chan
 *
 * Created on August 9, 2018, 8:36 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void koch(int,double,double,double,double);

int main(){
    int size;
    scanf("%d",&size);
    printf("%.8f %.8f\n",0.0,0.0);
    koch(size,0,0,100,0);
    printf("%.8f %.8f\n",100.0,0.0);
    return (EXIT_SUCCESS);
}

void koch(int n, double xStart, double yStart, double xEnd, double yEnd){
    if(n==0)
        return;
    
    double point[3][2];
    point[0][0]=(2*xStart + xEnd)/3;
    point[0][1]=(2*yStart + yEnd)/3;
    point[2][0]=(xStart + 2*xEnd)/3;
    point[2][1]=(yStart + 2*yEnd)/3;

    point[1][0]=(point[2][0]-point[0][0])/2-(point[2][1]-point[0][1])*sqrt(3)/2+point[0][0];
    point[1][1]=(point[2][0]-point[0][0])*sqrt(3)/2+(point[2][1]-point[0][1])/2+point[0][1];
    
    koch(n-1,xStart,yStart,point[0][0],point[0][1]);
    printf("%.8f %.8f\n",point[0][0],point[0][1]);
    
    koch(n-1,point[0][0],point[0][1],point[1][0],point[1][1]);
    printf("%.8f %.8f\n",point[1][0],point[1][1]);
    
    koch(n-1,point[1][0],point[1][1],point[2][0],point[2][1]); 
    printf("%.8f %.8f\n",point[2][0],point[2][1]);
    
    koch(n-1,point[2][0],point[2][1],xEnd,yEnd);
}



Measured memory_bytes: 2096
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, k; cin>>n>>k;
    string s; cin>>s;
    int p=s[k-1]-'A';
    s[k-1]='a'+p;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		sum += a[i];
	}
	printf("%d",sum-n);
	return 0;
}

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

int main(void) {
  	string s[110], t[110];
  	int N, M;
  
  	cin >> N;
  	for(int i = 0; i < N; i++){
    	cin >> s[i];
    }
  	cin >> M;
  	for(int i = 0; i < M; i++){
    	cin >> t[i];
    }
  	
  	int ans = 0;
  	for(int i = 0; i < N; i++){
    	int score = 0;
      	for(int j = 0; j < N; j++){
        	if(s[i] == s[j]) score++;
        }
      	for(int l = 0; l < M; l++){
        	if(s[i] == t[l]) score--;
        }
      	ans = max(ans, score);
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    int n;
    cin>>n;
    ll a[n];
    ll sum=0;
  	ll m=1000000000+7;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        ans+=((a[i]%m)*(sum%m))%m;
    }
    cout<<ans%m;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 5140
# ABC058 B - ∵∴∵
from collections import deque
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

O = si()
E = si()
N = len(O) + len(E)

O = [ o for o in O]
E = [ e for e in E]
O = deque(O)
E = deque(E)
ans = ''

for i in range(N):
    if i%2==0:
        ans += O.popleft()
    else:
        ans += E.popleft()
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<vector<int>> data(N + 1, vector<int>(26));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 26; j++){
      data.at(i + 1).at(j) = data.at(i).at(j);
    }
    data.at(i + 1).at((S.at(i) - 'a'))++;
  }
  map<int, char> sub;
  vector<int> ans(26);
  int a, b, c, count;
  char cc;
  for(int i = 0; i < Q; i++){
    cin >> a >> b;
    if(a == 1){
      cin >> cc;
      sub[b] = cc;
    } else{
      cin >> c;
      b--;
      for(int i = 0; i < 26; i++){
        ans.at(i) = data.at(c).at(i);
        ans.at(i) -= data.at(b).at(i);
      }
      for(auto i = sub.begin(); i != sub.end(); i++){
        if(i->first > b && i->first <= c){
          ans.at(S.at(i->first - 1) -'a')--;
          ans.at(i->second -'a')++;
        }
      }
      count = 0;
      for(int i = 0; i < 26; i++){
        if(ans.at(i) != 0)count++;
      }
      cout << count << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 69636
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    r = I()
    print(2*r*3.14159265358979)
    return


if __name__ == "__main__":
    solve()

Measured memory_bytes: 65660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			if(n == 0){
				break;
			}
			
			boolean know[][] = new boolean[n+1][n+1];
			for(int i = 1; i <= n; i++){
				String[] tmpArray = br.readLine().split(" ");
				
				for(int j = 1; j < tmpArray.length ; j++){
					int tmp = Integer.parseInt(tmpArray[j]);
					know[i][tmp] = true;
				}
			}
			
			String[] tmpArray = br.readLine().split(" ");
			int leak[] = new int[Integer.parseInt(tmpArray[0])];
			
			for(int i = 1; i < tmpArray.length ; i++){
				leak[i - 1] = Integer.parseInt(tmpArray[i]);
			}
			
			//?´???´?§£
			ArrayList<Integer> suspect = new ArrayList<Integer>();
			for(int i = 1; i <= n; i++){
				boolean black = true;
				for(int j = 0; j < leak.length ; j++){
					if(!know[i][leak[j]]){
						black = false;
						break;
					}
				}
				if(black){
					suspect.add(i);
				}
			}
			
			if(suspect.size() == 1){
				System.out.println(suspect.get(0));
			}
			else{
				System.out.println(-1);
			}
		}
	}

}

Measured memory_bytes: 41020
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();

        Day[] days = new Day[n];

        for (int i = 0; i < n; i++) {
            days[i] = new Day(nextInt(), nextInt(), nextInt());
        }

        int[][] dp = new int[n + 1][3];

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 3; j++) {
                dp[i][j] = Math.max(dp[i-1][(j + 1) % 3], dp[i-1][(j + 2) % 3]) + days[i-1].get(j);
            }
        }

        out.println(Math.max(Math.max(dp[n][0], dp[n][1]), dp[n][2]));

        out.close();
    }

    static class Day {
        int a, b, c;

        Day(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        private int get(int val) {
            if (val == 0) return a;
            if (val == 1) return b;
            return c;
        }
    }
}




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

int main() {
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  
  if(2*x==w&&2*y==h) cout << double(w)*double(h)*0.5 << endl << 1 <<endl;
  else cout << double(w)*double(h)*0.5 << endl << 0<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),k=stdIn.nextInt(),l[]=new int[50],s=0,i,j,t;
		for(i=0;i<n;i++) l[i]=stdIn.nextInt();
		for(i=0;n-1>i;i++) {
			for(j=n-1;j>i;j--) {
				if(l[j]>l[j-1]) {
					t=l[j];
					l[j]=l[j-1];
					l[j-1]=t;
				}
			}
		}
		for(i=0;i<k;i++) s+=l[i];
		System.out.print(s);
	}
}

Measured memory_bytes: 21972
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl;}
void soutl(ll x) { cout << x << endl;}
void outs(string x) { cout << x << endl;}
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int n, d;
	
	int x[12][12];

	cin >> n >> d;
	rep(i, n) {
		rep(j, d) cin >> x[i][j];
	}
	int ans = 0;
	rep(i, n)rep(j,i) {//j < i
		int sq = 0;
		rep(k, d) {
			int s = x[i][k] - x[j][k];
			sq += s * s;
		}
		int s = sqrt(sq);
		if (s * s == sq) ans++;

	}
	outi(ans);
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n, x, memo[3010][3010];
bool visited[3010][3010];
vector<long long int>arr(3010);

long long int dp(long long int i, long long int j){
	if(visited[i][j]){
		return memo[i][j];
	}
	visited[i][j]=1;
	if(i==j){
		return memo[i][j]=arr[i];
	}
	return memo[i][j]=max(arr[i] - dp(i+1, j), arr[j] - dp(i, j-1));
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	cout << dp(0, n-1) << endl;
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int h[100010];
    int temp = 0,ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    for(int i=1;i<n;i++){
        if(h[i] <= h[i-1]){
            temp++;
        }else{
            temp=0;
        }
        ans = max(ans,temp);
    }
    cout << ans << "\n";
    return 0;
}



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

signed main(){
  int N,M,K;cin>>N>>M>>K;
  int OK=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      if((M-j)*i+(N-i)*j==K)OK++;
    }
  }
  if(OK)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back

#define endl '\n'
#define inf (lli)2000000000000
#define MOD (lli)1000000007
#define MAXN 100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

vlli t(MAXN),x(MAXN),y(MAXN);

int main()
{
	opt;
	lli i,n;
	cin >> n;
	rep(i,n)
	{
	    cin >> t[i] >> x[i] >> y[i];
	}
	lli ti = 0,inx = 0,iny = 0;
    rep(i,n)
    {
        lli tLeft = t[i] - ti;
        if((abs(inx - x[i]) + abs(iny - y[i]) <= tLeft) and (tLeft % 2 == (abs(inx - x[i]) + abs(iny - y[i]))%2))
        {
            inx = x[i];
            iny = y[i];
            ti = t[i];
        }
        else
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}










Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(all(s));

  int cnt = 1;
  int ma = 0;
  REP(i, 1, n-1){
    if(s[i-1] == s[i]) cnt++;
    if(s[i-1] != s[i] || i == n-1){
      chmax(ma, cnt);
      cnt = 1;
    }
  }

  REP(i, 1, n-1){
    if(s[i-1] == s[i]) cnt++;
    if(s[i-1] != s[i] || i == n-1){
      if(cnt == ma) cout << s[i-1] << endl;
      cnt = 1;
    }
  }

  if(ma == 1) cout << s[n-1] << endl;

  return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=307;
int n;
char s[N][N];
char b[N][N];
ll ans=0;
int main(){
	cin>>n;
	for(int i = 1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
	for(int i = 0;i<n;i++){
		for(int j = 1;j<=n;j++){
			for(int k = 1;k<=n;k++){
				b[j][(k+i<=n)?(k+i):(k+i-n)]=s[j][k];
			}
		}
		int jud=1;
		for(int j = 1;j<=n;j++){
			for(int k = j+1;k<=n;k++){
				if(b[j][k]!=b[k][j]) jud=0;
			}
		}
		if(jud) ans++;
	}
	cout<<ans*n<<endl;
	return 0;
}

Measured memory_bytes: 384
N, X = map(int, input().split())
coord = list(map(int, input().split()))

coord.append(X)
coord.sort()

diffs = []
for i in range(1, len(coord)):
    diffs.append(coord[i] - coord[i-1])

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

GCD = diffs[0]
for el in diffs[1:]:
    GCD = gcd(GCD, el)

print(GCD)



Measured memory_bytes: 14252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EDistMax {
public:
    int N;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N;
        int minP = INF;
        int minM = INF;
        int maxP = -INF;
        int maxM = -INF;

        int res = 0;
        REP(i, N) {
            int x, y;
            cin >> x >> y;
            int p = x + y;
            int m = x - y;
            if (i > 0) {
                res = max(res, p - minP);
                res = max(res, -m + maxM);
                res = max(res, m - minM);
                res = max(res, -p + maxP);
            }

            minP = min(minP, p);
            minM = min(minM, m);
            maxP = max(maxP, p);
            maxM = max(maxM, m);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EDistMax solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
  long long a,v,b,w,t;
  cin >> a>> v >> b >> w >> t;
  long long d=abs(a-b);
  long long x=abs(v-w);
  if(v>w && d<=x*t) cout << "YES";
  else cout << "NO";
  
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int N;
	while(cin >> N) {
		int d = N;
		int cnt = 1;
		int ans = 0;
		while(1) {
			if(d * cnt == 600 - N) {
				ans += d * cnt * d * cnt * N;
				break;
			}
			ans += d * cnt * d * cnt * N;
			++cnt;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {

int a,b,c,d,e;
cin >> a>> b >>c;
if(a%b==0)
    {
        d=a/b;
    }
   if((a%b)!=0)
    {
        d=(a/b) + 1;
    }
   e=d*c;
   cout << e;
        return 0;
        
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i;
	deque<int> dq;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
	{
		int x;
		cin>>x;
		if (i % 2)
			dq.push_front(x);
		else dq.push_back(x);
	}
	
	if (n % 2)
		reverse(dq.begin(), dq.end());
	
	for (i = 0; i < n; ++i)
		cout<<dq[i]<<' ';
	cout<<'\n';
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
int cnt[250000];
int isprime(int n){
  if(n==1)return 0;
  for(int i=2;i*i<=n;i++){
    if(n%i==0)return 0;
  }
  return 1;
}

int main(){
  for(int i=2;i<250000;i++){
    cnt[i]=cnt[i-1]+isprime(i);
  }
  while(1){
    int n; cin >>n;
    if(n==0)break;
    cout << cnt[2*n]-cnt[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(long long n, long long root)	{
  for (long long i = 2; i <= root; i++)	{
    if (n % i == 0)
      return false;
  }
  return true;
}

int nDigits(long long n)	{
  int digits = 0;
  while (n > 0)	{
    digits++;
    n /= 10;
  }
  return digits;
}

int main()	{
  long long n;
  cin >> n;
  long long root = sqrt(n);
  //cout << root << endl;
  if (isPrime(n, root))	{
    cout << nDigits(n) << endl;
  }
  else	{
    //find largest factor starting from sqrt(n)
    for (long long i = root; i < n; i++)	{
      if (n % i == 0)	{
        cout << nDigits(i) << endl;
		return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3668
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "bitset"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N + 1), u(N + 1);
    rep(0, i, N + 1)
    {
        cin >> A.at(i);
    }
    if (N == 0 && A.at(0) != 1)
    {
        cout << -1 << endl;
        return 0;
    }
    u.at(N) = A.at(N);
    for (int i = N - 1; i >= 0; i--)
    {
        u.at(i) = u.at(i + 1) + A.at(i);
    }

    ll ans = 1, n = 1 - A.at(0);
    rep(1, i, N + 1)
    {
        n = min(2 * n, u.at(i));
        ans += n;
        n -= A.at(i);
        if (n < 0)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int N, W;
    cin >> N >> W;
    vector<long> w(N);
    vector<long> v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
    // dp[i][j]: i番目以降の品物を使って、重さの総和がj以下になるように選んだ場合の価値の最大値
    // dp[N][j] = 0
    // dp[i][j] = dp[i+1][j] (j-w[i] < 0)
    // dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i])
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j <= W; j++) {
            if (j - w[i] < 0) {
                dp[i][j] = dp[i + 1][j];
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[0][W] << endl;
    return 0;
}

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

int main(){
    char s[200], t[200], u[200];
    int h, n, i, j;
    
    while(scanf("%s", s)){
        if (strcmp(s, "-") == 0) break;
        scanf("%d", &n);
        for (j = 0; j < n; j++){
        	scanf("%d", &h);
            strncpy(t, s, h);
            for (i = h; i < strlen(s); i++) u[i - h] = s[i];
            for (i = 0; i < strlen(s) - h; i++) s[i] = u[i];
            for (i = strlen(s) - h; i < strlen(s); i++) s[i] = t[i + h - strlen(s)];
        }
        printf("%s\n", s);
    }
    
    return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        String S = sc.next();
        int x = 0;

        for(int i=0; i<3; i++){
            if(S.charAt(i%3)!=S.charAt((i+1)%3)){
                x += 1;
            }
            else{
                System.out.println("No");
                break;
            }
        }
        if(x==3){
            System.out.println("Yes");
        }
    } 
}

Measured memory_bytes: 21204
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


char A[100][100], B[100][100];
int N, M;
bool check(int x, int y) {
	REP(i, M) {
		REP(j, M) {
			if (A[i + x][j + y] != B[i][j])return false;
		}
	}
	return true;
}
void solve() {
	cin >> N >> M;
	REP(i, N)REP(j, N)cin >> A[i][j];

	REP(i, M)REP(j, M)cin >> B[i][j];
	REP(i, N - M + 1)REP(j, N - M + 1) {
		if (check(i, j)) {
			print("Yes"); return; 
		}
	}
	print("No");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
N, W = map(int, input().split())
 
import numpy as np
dp = np.zeros(W + 1, dtype='int64')
 
for i in range(1, N + 1):
    w, v = map(int, input().split())
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[:W-w+1] + v)
 
print(dp[-1])

Measured memory_bytes: 15456
#include<stdio.h>
#define N 100
 
main(){
  int i,j,m[N][N],n,l,u,s;
  scanf("%d",&u);
  for(i=0;i<u;i++){
    for(j=0;j<u;j++){
      m[i][j]=0;
    }
  }
 
  for(i=0;i<u;i++){
    scanf("%d %d",&n,&l);
    n--;
    for(j=0;j<l;j++){
      scanf("%d",&s);
      s--;
      m[n][s]=1;
    }
  }
  for(i=0;i<u;i++){
    for(j=0;j<u-1;j++){
      printf("%d ",m[i][j]);
    }
    printf("%d",m[i][u-1]);
    printf("\n");
  }
   
   
 return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(10);
	while(true) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<double> s(n);
		double sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		double m = sum / n;
		double tmp = 0;
		for (int i = 0; i < n; i++) {
			tmp += (s[i] - m) * (s[i] - m);
		}
		double a2 = tmp / (double)n;
		cout << sqrt(a2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll ans = INF, n;
int main() {
	cin >> n;
	REPO(i, n - 1) {
		string a = to_string(i);
		string b = to_string(n - i);
		ll aa = 0, bb = 0;
		REP(i, a.size()) aa += a[i] - '0';
		REP(i, b.size()) bb += b[i] - '0';
		ans = min(ans, aa + bb);
	}
	cout << ans << endl;
}



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

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

	vector< int > A( N );
	set< int > s;
	for ( int &a : A )
	{
		cin >> a;
		s.insert( a );
	}

    if(A.size() == s.size()){
    	cout << "YES" << endl;
    }
    else{
       	cout << "NO" << endl;
    }

    return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
rep(i,n){
    cin>>a[i];
}
int left = *min_element(a.begin(),a.end());
int right = *max_element(a.begin(),a.end());
int ans=MAX;
reps(mean,right+1,left){
    int tmp=0;
    rep(i,n){
        tmp+=(a[i]-mean)*(a[i]-mean);
    }
    ans=min(ans,tmp);
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3636
import bisect
n = int(input())
l = sorted([int(i) for i in input().split()])

ans = 0
for i in range(n):
    for j in range(i+1,n):
        a = l[i]
        b = l[j]
        tri = bisect.bisect_left(l,a+b)
        ans += tri-j-1
        
print(ans)



Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN maxnum
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int a, b, c, d, num[11];

int main()
{
    scanf("%d%d%d%d", &a, &b, &c, &d);
    num[a]++; num[b]++; num[c]++; num[d]++;
    if(num[1]==1 && num[4]==1 && num[7]==1 && num[9]==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string X,Y;
    cin >> X >> Y;
    if (X<Y){
        cout << "<" << endl;
    }
    else if (X>Y){
        cout << ">" << endl;
    }
    else{
        cout << "=" << endl;
    }
}

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


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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define INF MAX/2
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
bool chmin(int &a, int b) {if(a>b){a=b; return true;} else return false;}
bool chmax(int &a, int b) {if(a<b){a=b; return true;} else return false;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  int N, W;
  cin >> N >> W;
  static int w[100], v[100];
  REP(i,N) cin >> w[i] >> v[i];

  // dp[n][w] ... n番目(1-index)までの品物の中で、合計w以下としたときの最大価値
  static int dp[101][100001];

  // 貰うdp
  for (int i=1; i<=N; i++) {
    for (int j=0; j<=W; j++) {
      //i番目を選ばない場合
      chmax(dp[i][j], dp[i-1][j]);

      //i番目を選ぶ場合
      if (j-w[i-1]>=0) chmax(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long

using namespace std;



int main(void){
    ll a, b;
    cin >> a >> b;
    ll check = 1;
    ll r;
    while((r = (a%b))!=0){
        a = b;
        b = r;
    }
    ll count = 0;
    vector<ll> yakusu;
    for(ll i = 1; i <= int(sqrt(b)); i++){
        if(b%i==0){
            if(i == b/i){
                yakusu.push_back(i);
                count++;
            }
            else{
                yakusu.push_back(i);
                yakusu.push_back(b/i);
                count+=2;
            }
        }
    }
    ll ans = 1;
    sort(yakusu.begin(), yakusu.end(), greater<ll>());
    for(ll i = 0; i < count-1; i++){
        for(ll j = i+1; j < count; j++){
            if(j == count-1) ans++;
            if(yakusu[i]%yakusu[j]==0) break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
def atcodeer_and_paint_cans(a: int, b: int, c: int) -> int:
    return len(set([a, b, c]))


if __name__ == "__main__":
    a, b, c = map(int, input().split())
    ans = atcodeer_and_paint_cans(a, b, c)
    print(ans)


Measured memory_bytes: 2940
///S->----------------------------------------------------|
///R->--------------</AUTHOR - SRIJAN DE>-----------------|
///I->--------</https://thesrijande.github.io/>-----------|
///J->----</JALPAIGURI GOVERNMENT ENGINEERING COLLEGE>----|
///A->------------</INFORMATION TECHNOLOGY>---------------|
///N->----------------------------------------------------|
#include    <bits/stdc++.h>
using       namespace            std;
using       ll =                 int64_t ;
using       ull =                unsigned long long ;
using       ld =                 long double;
#define     int                  int64_t
#define     mem(a,val)           memset( a,  val,  sizeof(a) )
#define     b_s                  binary_search
#define     u_b                  upper_bound
#define     l_b                  lower_bound
#define     nl                   cout<<endl
#define     pb                   push_back
#define     pf                   push_front
#define     ppb                  pop_back
#define     ppf                  pop_front
#define     in                   insert
#define     fi                   first
#define     se                   second
#define     umap                 unordered_map
#define     pqueue               priority_queue
#define     rr                   return
#define     bits(n)              __builtin_popcount(n)
const int   N =                   1e6 + 7;
const int   MOD =                 (int)1e9 + 7;
const int   MOD1 =                (int)1e9 + 9;
const int   MOD2 =                998244353;
const ld    pi =                  atan2(0, -1);
const ld    eps =                 1e-9;
int         tests =               1;
template<class x, class y>x max(x a, y b) {
    return (a > b) ? a : b;
}
template<class x, class y>x min(x a, y b) {
    return (a < b) ? a : b;
}
template<class x, class y>x log(x n, y r) {
    return (n > r - 1) ? 1 + log(n / r, r) : 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'
vector<int> adj[N], subset;
int vis[N] = {0};
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main()
{
    auto start = clock();
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    }
#endif
//  cout<<fixed;
//  cout<<scientific;
//  cout<<fixed<<setprecision(12);
    // cin >> tests;
    for (int test = 1; test <= tests; test++)
    {
        // cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.

        int a[5 + 1] = {0};
        for (int i = 0; i < 5; i++)
        {
            int x;
            cin >> x;
            a[x] = 1;
        }
        for (int i = 1; i <= 5; i++)
            if (a[i] == 0)
                cout << i;








///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.

    }
    cerr << endl << endl <<  endl <<
         "Time : " << double(clock() - start) / CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 27212
import sys
import heapq
input = sys.stdin.readline

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    h = []

    for i in range(N):
        A, B = map(int, input().split())
        # deadline, effort
        heapq.heappush(h, (B, A))

    days = 0
    for i in range(N):
        work = heapq.heappop(h)
        days += work[1]
        # print(days, work)
        if days > work[0]:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 68276
import java.util.Scanner;

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

Measured memory_bytes: 26296
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] numbers = new int[n];
        for (int i = 0; i < n; i++) {
            numbers[i] = sc.nextInt();
        }

        int next = 1;
        int count = 0;
        while (numbers[next - 1] != 0) {
            count++;
            if (numbers[next - 1] == 2) {
                System.out.println(count);
                return;
            }
            int tmp = next;
            next = numbers[next - 1];
            numbers[tmp - 1] = 0;
        }

        System.out.println(-1);
    }
}

Measured memory_bytes: 50752
/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/*----------------------------------------------------------------*/
const int mod2 = 998244353;
void solve() {
    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> v(k);
    for(int i = 0;i < k;i++) {
        cin >> v[i].first >> v[i].second;
    }

    set<int> s;
    for(int i = 0;i < k;i++) {
        s.insert(v[i].first);
        s.insert(v[i].second);
    }

    vector<ll> cnt(n + 1, 0);
    vector<ll> preSum(n + 1, 0);

    cnt[1] = 1;
    preSum[1] = 1;
    for(int i = 2;i <= n;i++) {
        for(int j = 0;j < k;j++) {
            int l = i - v[j].second;
            int r = i - v[j].first; 

            if(r < 0) {
                continue;
            }

            l = max(1, l);
            cnt[i] += (preSum[r] - preSum[l - 1]);
            cnt[i] %= mod2;
        }

        preSum[i] = preSum[i - 1] + cnt[i];
    }

    pf(cnt[n]);
}

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

Measured memory_bytes: 6332
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long C = sc.nextLong();
        long[] x = new long[N + 1];
        int[] v = new int[N + 1];
        long[] sumLeft = new long[N + 1];
        long[] sumRight = new long[N + 1];
        long[] sumLeftMax = new long[N + 1];
        long[] sumRightMax = new long[N + 1];
        long[] sumLeftTurnMax = new long[N + 1];
        long[] sumRightTurnMax = new long[N + 1];
        for (int i = 1; i <= N; i++) {
            x[i] = sc.nextLong();
            v[i] = sc.nextInt();
            sumLeft[i] = sumLeft[i - 1] + v[i];
        }
        for (int i = 1; i <= N; i++) {
            sumRight[i] = sumRight[i - 1] + v[N - i + 1];
        }

        for (int i = 1; i <= N; i++) {
            sumLeftMax[i] = Math.max(sumLeftMax[i - 1], sumLeft[i] - x[i]);
            sumRightMax[i] = Math.max(sumRightMax[i - 1], sumRight[i] - (C - x[N - i + 1]));
        }
        for (int i = 1; i <= N; i++) {
            sumLeftTurnMax[i] = Math.max(sumLeftTurnMax[i - 1], sumLeft[i] - 2 * x[i] + sumRightMax[N - i]);
            sumRightTurnMax[i] = Math.max(sumRightTurnMax[i - 1], sumRight[i] - 2 * (C - x[N - i + 1]) + sumLeftMax[N - i]);
        }
        long max = Math.max(Math.max(sumLeftMax[N], sumRightMax[N]), Math.max(sumLeftTurnMax[N], sumRightTurnMax[N]));
        System.out.println(max);
        sc.close();
    }
}


Measured memory_bytes: 96528
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;

int cnt[25][25];
char mat[25][25];
int n,m;
int r[4] = {-1,0,1,0};
int c[4] = {0,1,0,-1};

int bfs(int a, int b) {
	memset(cnt, -1, sizeof cnt);

	queue<pair<int,int>> Q;
	Q.emplace(a,b);
	cnt[a][b] = 0;

	while(!Q.empty()) {
		auto v = Q.front(); Q.pop();

		for(int i = 0; i < 4; i++) {
			int x = v.ff + r[i];
			int y = v.ss + c[i];

			if(x < 0 or x >= n or y < 0 or y >= m or mat[x][y] == '#' or cnt[x][y] != -1) continue;
			cnt[x][y] = cnt[v.ff][v.ss]+1;
			Q.emplace(x,y);
		}
	}

	int ret = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			ret = max(ret, cnt[i][j]);
	return ret;
}

int main(){

	scanf("%d%d", &n, &m);

	for(int i = 0; i < n; i++)
		scanf(" %s", mat[i]);

	int ans = 0;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(mat[i][j] != '#')
				ans = max(ans, bfs(i,j));

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256