akhauriyash/Code-Regression huggingface dataset:
n,*ar = gets.split.map(&:to_i)
x = n.times.map{gets.to_i}

ans = 10**9
sum = Array.new(3,0)
(4**n).times{|i|
  s = (4**n+i).to_s(4)[1..-1]
  sum.fill(0)
  tmp = 0
  n.times{|j|
    next if s[j].to_i>2
    tmp += 10 if sum[s[j].to_i] > 0
    sum[s[j].to_i] += x[j]
  }
  next if 3.times.map{|j|sum[j]<=0}.any?
  tmp += 3.times.map{|j|(ar[j]-sum[j]).abs}.inject(:+)
  
  ans = tmp if ans > tmp
}

p ans

Measured memory_bytes: 1788
H, W = list(map(int, input().split()))
s = [list(input()) for _ in range(H)]

DP = [[0] * W for _ in range(H)]
if s[0][0] == "#":
  DP[0][0] = 1

for i in range(1, W):
  if s[0][i - 1] != s[0][i]:
    DP[0][i] = DP[0][i - 1] + 1
  else:
    DP[0][i] = DP[0][i - 1]

for i in range(1, H):
  DP[i][0] = DP[i - 1][0]
  if s[i][0] != s[i - 1][0]:
    DP[i][0] += 1
  for j in range(1, W):
    x = DP[i][j - 1]
    if s[i][j] != s[i][j - 1]:
      x += 1
    y = DP[i - 1][j]
    if s[i][j] != s[i - 1][j]:
      y += 1
    DP[i][j] = min(x, y)

print((DP[-1][-1] + 1) // 2)

Measured memory_bytes: 3188
import java.util.*;

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

    double r = sc.nextDouble();

    System.out.println(String.format("%.8f", r * r * Math.PI) + " " + String.format("%.8f", 2 * r * Math.PI));
  }
}



Measured memory_bytes: 28048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		count += Math.max(a, b);
		count += Math.max(Math.max(a, b) - 1, Math.min(a, b));
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 23508
#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<double> p(n);
  rep(i,n) cin >> p[i];
  vector<vector<double>> dp(3100, vector<double>(3100));
  dp[0][0] = 1.0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i; j++) {
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
    }
  }
  double ans = 0.0;
  for(int j = n/2 + 1; j <= n; j++) ans += dp[n][j];
  printf("%.10f", ans);
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

unsigned int randxor(){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

#define int ll

int D;
const int N=26;
vector<vector<int>>s;
vector<int>c;

ll score(vector<int>&t){
  ll score=0;
  ll ans=0;
  vector<int>last(N,-1);
  for(int i=0;i<D;i++){
    ans+=s[i][t[i]];
    last[t[i]]=i;
    for(int j=0;j<N;j++){
      if(last[j]==-1)ans-=c[j]*(i+1);
      else ans-=c[j]*(i-last[j]);
    }
    score+=max(ans+1000000,0ll);
  }
  return score;
}

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

  auto start = std::chrono::system_clock::now();  
  cin>>D;
  c.resize(N);
  for(int i=0;i<N;i++)cin>>c[i];
  s.resize(D,vector<int>(N));
  for(int i=0;i<D;i++)for(int j=0;j<N;j++)cin>>s[i][j];

  vector<int>t(D,0);

  ll S=0;
  for(int i=0;i<D;i++){
    for(int j=0;j<N;j++){
      int memon=t[i];
      t[i]=j;
      ll SS=score(t);
      if(S<SS)S=SS;
      else t[i]=memon;
    }
  }
  while(true){
    for(int x=0;x<100;x++){
      int d=randxor()%D;
      int n=randxor()%N;
      int memon=t[d];
      if(memon==n){
        if(n==N-1)n--;
        else n++;
      }
      t[d]=n;
      ll SS=score(t);
      if(S<SS)S=SS;
      else t[d]=memon;
    }
    auto end = std::chrono::system_clock::now();
    auto dur = end-start;
    auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
    if(1980<msec)break;
  }

  for(auto it:t)cout<<it+1<<endl;
  return 0;
}


Measured memory_bytes: 3744
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):
    s = 'abcdefghijkl'
    ans = []
    from heapq import heapify, heappop, heappush

    def f(t: str):
        if len(t) == N:
            # heappush(ans, t)
            ans.append(t)
            return
        
        if len(t) >= 2:
            x = s.index(max(list(t)))+2
        else:
            x = len(t)+1
        for i in range(x):
            f(t+s[i])


    
    f('')
    # print(ans)
    c = 0
    # print(len(ans))
    # while len(ans):
    #     print(heappop(ans))
    #     c += 1
    ans.sort()
    for i in ans:
        print(i)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12780
import queue
import math
def dijkstra(i,n,adj):
  pq=queue.PriorityQueue()
  dist=[float("inf") for i in range(n+1)]
  parent=[0]*(n+1)
  dist[i]=0
  pq.put((dist[i],i))
  while(not pq.empty()):
    (x,y)=pq.get()
    for e in adj[y]:
      if dist[y]+1 < dist[e]:
        dist[e]=dist[y]+1
        parent[e]=y
        pq.put((dist[e],e))
  if float('inf') in dist[1:]:
      print('No')
  else:
      print('Yes')
  for p in parent[2:]:
      print(p)

n,m=map(int,input().split())
adj=[[] for i in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  adj[a].append(b)
  adj[b].append(a)
#print(adj)
dijkstra(1,n,adj)

Measured memory_bytes: 106072
import math
import sys
A,B = map(int,input().split())
i = 0
while math.floor(i*0.08) <= A and math.floor(i*0.10) <= B:
  if math.floor(i*0.08) == A and math.floor(i*0.10) == B:
    print(i)
    sys.exit(0)
  i+=1
print(-1)
 


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int Nmax=200010;
int H,W,reached[52][52]={},flag=0;
char c[52][52];
int kyori[52][52]={};

void search(int x, int y){
	if(x<=0 || y<=0 || c[x][y]=='#' || x>H || y>W) return;
	if(x==H && y==W) flag=1;
	int aa = kyori[x][y];
    int mina = min(kyori[x-1][y],kyori[x+1][y]);
    int mina2 = min(kyori[x][y+1],kyori[x][y-1]);
    mina=min(mina,mina2);
	mina=min(aa-1,mina);
    kyori[x][y]=mina+1;
    //cout << "(" << x << "," << y << ")" << "=" << kyori[x][y];  
    if(kyori[x][y] != aa) reached[x][y] = 0;
	if(reached[x][y]==1) return;
  	reached[x][y]=1;
	search(x, y+1);
	search(x+1, y);
	search(x, y-1);
	search(x-1, y);
}
 
int main() {
	cin >> H >> W;
	int cnt=0;
	for(int i=1;i <= H;i++){
		for(int j=1;j <= W;j++){
			cin >> c[i][j];
          if(c[i][j] == '.') cnt++;
		}
	}
  	for(int i=0;i <= H+1;i++){
      for(int j=0;j <= W+1;j++){
        kyori[i][j]=200;
      }
    }
  	kyori[1][0]=-1;
	search(1,1);
	if(flag==1) cout << cnt-kyori[H][W]-1 << endl;
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <string>
#include <array>
#include <vector>
#include <iostream>

using namespace std;

int main() {

  int n;
  int cntW = 0;
  int cntB = 0;
  int ans  = 1000000;

  string str;

  cin >> n;
  cin >> str;

  for (int i = 0; i < n; i++) if (str[i] == '.') cntW ++;
  for (int i = 0; i < n; i++) {
    if (str[i] == '.') cntW --;
    ans = min(ans, cntW + cntB);
    if (str[i] == '#') cntB ++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;

  int ar[n+2];


  for(int i=1;i<=n;i++)ar[i] = m+i-1;
  sort(ar+1,ar+n+1);
  int res= 0;

  for(int i=1;i<=n;i++)res+=ar[i];
  int res1= 2e9;
  int ans ;
  for(int i=1;i<=n;i++){
       // cout<<ar[i]<<endl;

    int k = res-ar[i];

    int nk= abs(res-k);
    if(nk<res1){
            res1= nk;
        ans =k;
    }
  }

  cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int r, d, x;
  scanf("%d %d %d", &r, &d, &x);
  for (int i = 0; i < 10; ++i)
  {
    x = r * x - d;
    printf("%d\n", x);
  }
  return 0;
}

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

#define 	fin(i,ii,n)			for(int i=ii; i<n; ++i)
#define 	fni(i,n,ii)			for(int i=n; i>ii; --i)
#define		repit(i, c)			for( auto i = (c).begin(); i != (c).end();++i )
#define		dbg(args...)		do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
#define		pb					push_back
#define		sz(xx)				xx.size()
#define		mk					make_pair
#define 	fastt 				ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

template< typename T > void print(const T& v) {    cerr << v << ' ' ;}
template< typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
typedef set<int> si;

#define d 	1		//discoverd
#define f  -1		//finished

int main()
{
	fastt
	ll n,a[5];
	cin>>n;
	fin(i,0,5) cin>>a[i];
	ll low = a[0];
	fin(i,1,5){ low = min(low,a[i]); }
	if(n<=low){cout << 5 << endl; return 0;}
	ll div = ceil(n*1.0/low);
	cout << div+4 << endl;


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int a, b; cin >> a >> b;
	int c = (a + b) >> 1;
	if(abs(a - c) == abs(b - c)) {
		printf("%d\n", c);
	} else {
		printf("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lowbit(x) x&(-x)
#define PA pair<int, int>
#define MK make_pair
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l*10+a-48;
	return l*f;
}
const int N = 100005;
struct DATA
{
	int t, x, y;
}a[N];
int n;
int main(int argc, char const *argv[])
{
	n = read();
	for (int i = 1; i <= n; ++i) a[i].t = read(), a[i].x = read(), a[i].y = read();
	a[0].t = 0, a[0].x = a[0].y = 0;
	for (int i = 1; i <= n; ++i)
	{
		int tmp = a[i].t-a[i-1].t;
		int dis = abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y);
		if (tmp < dis || (tmp-dis)%2 == 1)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
S=input()
s=int(S)
mod=2019
c=[0]*(len(S)+1)
d=[0]*2019


c[0]=0
d[0]=1
for i in range(len(S)):
  c[i+1]=(c[i]+int(S[-i-1])*pow(10,i,mod))%mod
  d[c[i+1]]+=1
  
m=0
for i in range(2019):
  m+=d[i]*(d[i]-1)//2

print(m)

Measured memory_bytes: 16236
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 26704
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N;
	string S;
	cin >> N >> S;

	vector<vector<int>> su(2, vector<int>((unsigned int)(N + 100), 0));

	su.at(0).at(0) = 0;
	su.at(1).at(0) = 0;
	for (int i = 0; i < N; ++i)
	{
		if (S.at(i) == 'W')
		{
			su.at(0).at(i + 1) = su.at(0).at(i) + 1;
			su.at(1).at(i + 1) = su.at(1).at(i);
		}
		else
		{
			su.at(0).at(i + 1) = su.at(0).at(i);
			su.at(1).at(i + 1) = su.at(1).at(i) + 1;
		}
	}

	int ret = (int)(3 * 1e5);
	int l_min;
	rep(i, N)
	{
		l_min = (su.at(0).at(i)) + (su.at(1).at(N) - su.at(1).at(i+1));
		ret = min(l_min, ret);
	}

	cout << ret << endl;

	return 0;
}

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

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

  string S; cin >> S;
  int Q; cin >> Q;
  int flag = 1;
  for (int i = 0; i < Q; i++) {
    int T; cin >> T;
    if (T == 1) flag = 3 - flag;
    else {
      int F; cin >> F;
      char C; cin >> C;
      if ((flag + F) % 2) S.push_back(C);
      else S.insert(S.begin(), C);
    }
  }
  if (flag == 1) cout << S;
  else for (int i = S.size()-1; i >= 0; i--) cout << S[i];
  cout << "\n";
}

Measured memory_bytes: 1040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int main(){
	char s[101];
	int k;
	cin >> s;
	cin >> k;
	bool ok = true;
	char ans;
	for(int i=0;i<k;i++){
		if(s[i]!='1'){
			ok = false;
			ans = s[i];
			break;
		}
	}
	if(ok){
		cout<< '1'<<endl;
	}else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B,X=map(int,input().split())
    YESNO(A<=X<=A+B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    ds <- map read . words <$> getLine :: IO [Int]
    print $ solve n ds

solve n ds =
    y - x
    where
        sorted = sort ds
        x = sorted !! (n `div` 2 - 1)
        y = sorted !! (n `div` 2)

Measured memory_bytes: 34428
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  rep(i, 3){
    if(s[i] == t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

const int mx = 1e+5;

int a[105];
int dp[mx];
int main()
{	
	int n,k;
	cin>>n>>k;

	for(int i=1;i<=n;i++)cin>>a[i];


		for(int i=1;i<=k;i++)
		{	
			dp[i]=0;
			for(int j=1;j<=n;j++)
			{

				if(i<a[j])break;

				if(dp[i-a[j]]==0)dp[i]=1;

			}
		}

		if(dp[k]==1)
			cout<<"First"<<'\n';
		else
			cout<<"Second"<<'\n';

	return 0;	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL c[30],ans,x[370][30],n,ls[30],k;
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=26;i++)scanf("%lld",&c[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=26;j++)scanf("%lld",&x[i][j]);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&k);
        ans+=x[i][k];
        ls[k]=i;
        for(int j=1;j<=26;j++)ans-=c[j]*(i-ls[j]);
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 3880
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [A, B, C] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

if (A < C && C < B) {
  console.log('Yes')
} else if (A > C && B < C) {
  console.log('Yes')
} else {
  console.log('No')
}


Measured memory_bytes: 7372
program answer
  implicit none
  integer :: N, j, ans, count
  character(len=100) :: S
  character(len=1) :: ss

  ss='I'

  read(*,*) N
  read(*,*) S

  count=0
  ans=0

  do j = 1, N
     if(S(j:j)==ss(1:1)) then
        count=count+1
     else
        count=count-1
     end if

     if(count>ans) then
        ans=count
     end if
  end do

  write(*,*) ans

  stop
 end program answer

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=200000+5;

int n;
int v[N];
map<int,int>p;

int x[N];
int f[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1); reverse(v+1,v+n+1);
    int y=0;
    for(int i=1;i<=n;i++)
    {
        if(v[i]!=v[i-1])
        {
            x[++y]=v[i];
        }
        f[y]++;
    }
    n=y;
    for(int i=1;i<=n;i++)
    {
        p[x[i]]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(f[i]==0) continue;
        int l=log2(x[i]);
        int s=(1<<(l+1));
        int y=s-x[i];
        int id=p[y];
        if(id==0 || f[id]==0) continue;
        if(i==id)
        {
            int jum=f[i]/2;
            ans+=jum;
            f[i]-=2*jum;
        }
        else
        {
            int t=min(f[i],f[id]);
            f[i]-=t;
            f[id]-=t;
            ans+=t;
        }
      //  cout<<x[i]<<" "<<s<<"\n";
    }
    cout<<ans<<"\n";
    return 0;
}
/**


**/


Measured memory_bytes: 21504
def find(N):
    
    if N==3:
        print(2)
        print(1,3)
        print(2,3)
        return 0
        
    if N==4:
        print(4)
        print(1,2)
        print(2,4)
        print(3,4)
        print(1,3)
        return 0
    
    k=N//2
    edges=[]
    if N==2*k:
        for i in range(1,k):
            edges+=[(i,N-i)]
            edges+=[(i,i+1)]
            edges+=[(N+1-i,i+1)]
            edges+=[(N+1-i,N-i)]
        edges+=[(k,1)]
        edges+=[(k,N)]
        edges+=[(k+1,1)]
        edges+=[(k+1,N)]
        edges=set(edges)
        print(len(edges))
        for X in edges:
            print(X[0],X[1])
    else:
        for i in range(1,k):
            edges+=[(i,N-1-i)]
            edges+=[(i,i+1)]
            edges+=[(N-1+1-i,i+1)]
            edges+=[(N-1+1-i,N-1-i)]
        edges+=[(k,N),(N-k,N),(1,N),(N-1,N)]
        edges=set(edges)
        print(len(edges))
        for X in edges:
            print(X[0],X[1])
            
find(int(input()))         
            
        
        

Measured memory_bytes: 3188
using System;

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

const int N=10;
int[] h=new int[N];

string r;

for(int i=0; i<N;i++){
r=Console.ReadLine();
h[i]=int.Parse(r);
}

Array.Sort(h);

for(int i=1;i<=3;i++){
Console.WriteLine(h[N-i]);
}

}
}

Measured memory_bytes: 9224
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N, AC=0, WA=0, TLE=0, RE=0;


	cin >> N;

	rep(i, N){
		string S;
		cin >> S;
		if(S=="AC"){
			AC++;
		}
		if(S=="WA"){
			WA++;
		}
		if(S=="TLE"){
			TLE++;
		}
		if(S=="RE"){
			RE++;
		}
	}
 
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;

 
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> set = new HashSet<String>() {
          {
            for (int i=0;i<N;i++){
            add(sc.next());
            }
        }
        };
      if (N==set.size()){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
      

    }
}

Measured memory_bytes: 76424
nb = int(input())
a = list(map(int,input().split()))
t = sum(a)
g = nb * 1000000000000
q = 0
for i in range(nb - 1):
   q += a[i]
   p = t - q
   diff = abs(q-p)
   if diff < g:
      g = diff
print(g)


Measured memory_bytes: 24824
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int out[(1<<18)+10];
int n,k;
bool cal(){
	cin>>n>>k;
	if(k==0){
		rep(i,(1<<n)) out[i*2]=out[i*2+1]=i;
		return true;
	}
	if(n==1) return false;
	if(k>=(1<<n)) return false;
	out[0]=out[2]=0;out[1]=out[(1<<(n+1))-(1<<n)+1]=k;
	int t=0;
	rep(i,(1<<n)-2){
		t++;if(t==k) t++;
		out[(1<<(n+1))-i-1]=out[3+i]=t;
	}
	return true;
}
int main()
{
	if(!cal()){
		cout<<-1<<endl;
	}
	else{
		rep(i,(1<<(n+1))){
			cout<<out[i];
			if(i<(1<<(n+1))-1) cout<<' ';
			else cout<<endl;
		}
	}
}


Measured memory_bytes: 2816
L, R = [int(c) for c in input().split()]

if R-L+1 >= 2019:
    print(0)
    exit()

m = 2020
l = [c%2019 for c in range(L,R+1)]
for i in range(len(l)):
    for j in range(i+1, len(l)):
        m = min(m, (l[i]*l[j])% 2019)
print(m)


Measured memory_bytes: 3060
M = 10 ** 9 + 7
X, Y = map(int, input().split())

def f(n):
  if n == 0: return 1
  res = 1
  for i in range(1,n+1):
    res = (res * i) % M
  return res % M

def pow(x, n):
  res = 1
  while n:
    if (n & 1) == 1:
      res = res * x % M
    x = x * x % M
    n = n >> 1
  return res

def c(n,r):
  if r == 0 or r == n:
    res = 1
  elif r == 1 :
    res = n
  else:
    res = f(n) * pow(f(r), M-2) * pow(f(n-r), M-2)
  return res % M

if (X+Y) % 3 != 0:
  ans = 0
else:
  a = 0
  b = (X+Y)//3
  if X < Y: X, Y = Y, X
  a = X - Y
  a += (2*Y-X)//3
  if 2*Y - X < 0:
    ans = 0
  else:
    ans = c(b, a) % M
print (ans)

Measured memory_bytes: 3064
#include <iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<vector>
#define oo 0x3f3f3f33f
using namespace std;
int n, m, vis[100010];
int pre[100010];
int Quary(int x)
{
    if(vis[x]==1)
        return x;
    if(vis[pre[x]]==1)
        return pre[x];
    return Quary(pre[x]);
}
int main()
{
    int i;
    while(scanf("%d%d", &n, &m), n+m)
    {
        memset(vis, 0, sizeof(vis));
        char str[6];
        long long ans = 0;
        int root, v;
        vis[1]=1;
        pre[1]=1;
        for(i=2; i<=n; i++)
        {
            scanf("%d", &root);
            pre[i]=root;
        }
        for(i=0; i<m; i++)
        {
            scanf("%s%d", str, &v);
            if(str[0]=='M')
                vis[v]=1;
            else
                ans+=Quary(v);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

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

int main(){
  string s,find_word;

  cin>>s>>find_word;
  for(int i=0,pos=0;;i=pos+1){
    pos=s.find(find_word,i);
    if(pos==string::npos) break;
    cout<<pos<<endl;
  }
}


Measured memory_bytes: 1192
def fact(n,ans=1):
    for i in range(2,n+1):
        ans = (ans*i)%mod
    return ans

N , M = map(int,input().split())
ans = 0
mod = 10**9+7

if abs(N-M) > 1:
    ans = 0
else:
    if N == M:
        ans = fact(N)*fact(M)*2%mod
    else:
        ans = fact(N)*fact(M)%mod

print(ans)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int num,n,i,j;
	char s[9];
	fscanf(stdin, "%d", &n);
	i = 0;
	while (i < n) {
		fscanf(stdin, "%d", &num);
		for (j = 0,fprintf(stdout,"Case %d:\n",++i); j < 10; j++, P(d, num)) {
			sprintf(s, "%08d", num*num);
			s[6] = '\0';
			num = atoi(s + 2);
		}
	}
	return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;cin>>n;
	int k;cin>>k;
	double a[n];
	double sum=0,y=1,x=2;
	for(int i=0;i<n;i++){
		double X; cin>>X;
		a[i]=(double)(X+y)/x;
	}
	for(int i=0;i<k;i++) sum+=a[i];
	double mx=sum;
	for(int i=k;i<n;i++){
		sum=sum+(a[i]-a[i-k]);
		mx=max(mx,sum);
	}
	cout<<setprecision(7)<<mx<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#define num_size 100000
typedef long long ll;

using namespace std;

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

    int cnt[3] = {0};
    int t = 0;
    while (1){
	if (cnt[t] == s[t].size()){
	    cout << char('A'+t) << endl;
	    break;
	}
	t = int(s[t][cnt[t]++]-'a');
    }
  
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  unsigned a,b,c;
  std::cin >> a >> b >> c;
  unsigned num5 = 0;
  unsigned num7 = 0;
  if(a==5) num5++;
  if(b==5) num5++;
  if(c==5) num5++;
  if(a==7) num7++;
  if(b==7) num7++;
  if(c==7) num7++;
  if(num5==2 && num7==1)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b)
{
    return((a>b)?a:b);
}
int maxm(int a,int b,int c)
{
    return(max(a,max(b,c)));
}
int main()
{
    int n,i;
    cin>>n;
    int a[n],b[n],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp1[n],dp2[n],dp3[n];
    dp1[0]=a[0];     dp2[0]=b[0];     dp3[0]=c[0];
    for(i=1;i<n;i++)
    {
        dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
        dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
        dp3[i]=c[i]+max(dp1[i-1],dp2[i-1]);
    }
    cout<<maxm(dp1[n-1],dp2[n-1],dp3[n-1]);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
vector <int>v;
int gcd(int a,int b){
	return ((b==0) ? a : gcd(b,a%b));
}
int main()
{

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int n,x;
	cin>>n>>x;
	v.eb(x);
	for(int i=0; i<n; i++) {
		int a;
		cin>>a;
		v.eb(a);
	}
	sort(all(v));
	int ans=v[1]-v[0];
	for(int i=1; i<n; i++) {
		int dist=v[i+1]-v[i];
		ans=gcd(ans,dist);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 892
// at_nomura2020_b.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

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

	for (int i = 0; i < input.length(); i++) {
		if (input[i] == '?')
			input[i] = 'D';
	}
	cout << input;
}

// 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表
// 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表

// 開始使用的秘訣: 
//   1. 使用 [方案總管] 視窗，新增/管理檔案
//   2. 使用 [Team Explorer] 視窗，連線到原始檔控制
//   3. 使用 [輸出] 視窗，參閱組建輸出與其他訊息
//   4. 使用 [錯誤清單] 視窗，檢視錯誤
//   5. 前往 [專案] > [新增項目]，建立新的程式碼檔案，或是前往 [專案] > [新增現有項目]，將現有程式碼檔案新增至專案
//   6. 之後要再次開啟此專案時，請前往 [檔案] > [開啟] > [專案]，然後選取 .sln 檔案


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll n,m;
  cin >> n >> m;
  ll k[100],s[100][100];
  FOR(i,m){
    cin >> k[i];
    FOR(j,k[i]){
      cin >> s[i][j];
      
    }
  }
int p[100];
  FOR(i,m){
    cin >> p[i];
  }

  bool swi[100],c,d;
  int cnt=0,ans=0;
  
FOR(i,pow(2,n)){
  FOR(j,12){
    swi[j]=0;
  }
  FOR(j,n){
    if(i & (1 << j)){
      swi[j]=1;
    }
  }
  d=0;
  FOR(j,m){
    
    cnt=0;
    FOR(u,k[j]){
      if(swi[s[j][u]-1]){
        cnt++;
      }
    }
    if(cnt%2!=p[j]){
      d=1;
      break;
    }
    
  }
  if(d)continue;
  ans++;
}
  


cout << ans << endl;

  

  
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmpfunc (const void * a, const void * b)
{
    if( *(long long int*)a - *(long long int*)b < 0 )
        return 1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return -1;
    return 0;
}// large from small

int main(){
  long long int n,m,i,j;
  scanf("%lld",&n);
  scanf("%lld",&m);
  long long int a[n],b[m];
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
  }
  for(i=0;i<m;i++) {
    scanf("%lld",&b[i]);
  }
  //qsort(a,n,sizeof(long long int),cmpfunc);
  //qsort(b,m,sizeof(long long int),cmpfunc);
  long long int ans = 1;
  for(i=n*m;i>0;i--) {
    long long int samen = 0;
    long long int largen = 0;
    long long int samem = 0;
    long long int largem = 0;
    for(j=0;j<n;j++) {
      if(a[j] > i) {
        largen++;
      } else {
        if(a[j] == i) {
          samen++;
        }
      }
    }
    for(j=0;j<m;j++) {
      if(b[j] > i) {
        largem++;
      } else {
        if(b[j] == i) {
          samem++;
        }
      }
    }
    if(samen < 2 && samem < 2) {
      if(samen == 0) {
        if(samem == 0) {
          ans = (ans * ((largen * largem) - (m * n) + i))%1000000007;
          //printf("%lld %lld %lld %lld %lld\n",largen,largem,m,n,i);
          //printf("%lld %lld a\n",i,ans);
        } else {
          ans = (ans * largen)%1000000007;
          //printf("%lld %lld b\n",i,ans);
        }
      } else {
        if(samem == 0) {
          ans = (ans * largem)%1000000007;
          //printf("%lld %lld c\n",i,ans);
        } else {
          ans = ans;
          //printf("%lld %lld d\n",i,ans);
        }
      }
    } else {
      ans = 0;
      //printf("%lld %lld e\n",i,ans);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < n - 2; i++) {
			if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> h(N);
    set<ll> h_set;
    rep(i, N){
        cin >> h[i];
        h_set.insert(h[i]);
    }
    vector<ll> h_v(h_set.begin(), h_set.end());
    h_v.insert(h_v.begin(), 0);

    ll ans = 0;
    for(ll i = h_v.size()-1;i>0;--i){
        bool conti = false;
        rep(j, N){
            if (conti){
                if (h[j] != h_v[i]){
                    conti = false;
                    ans += h_v[i] - h_v[i-1];
                }else{
                    h[j] -= h_v[i] - h_v[i-1];
                }
            }else{
                if (h[j] == h_v[i]){
                    h[j] -= h_v[i] - h_v[i-1];
                    conti = true;
                }
            }
        }
        if (conti){
            ans += h_v[i] - h_v[i-1];
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace(int *A, int N) {
    for ( int i = 0; i < N; ++i ) {
        if ( i > 0 ) {
            cout << ' ';
        }
        cout << A[i];
    }
    cout << endl;
}

void swap(int *a, int *b) {
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int BubbleSort(int *A, int N) {
    int flag = 0;
    int sw = 0;
    int cnt = 0;
    do {
        flag = 0;
        for (int i = N - 1; i > cnt; --i) {
            if (A[i] < A[i - 1]) {
                swap(A + i, A + i - 1);
                sw++;
                flag = 1;
            }
        }
        cnt++;
    }while ( flag == 1 );
    return sw;
}

int main() {
    int A[MAX],N;
    int ans;

    cin >> N;
    for ( int i = 0; i < N; ++i ) cin >> A[i];

    ans = BubbleSort(A,N);

    trace(A,N);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3120
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
      int l = sc.nextInt();
      int res=0;
      if(l>0){
        res=(2*l+n)*(n-1)/2;
      }else if(l+n-1<0){
        res=(2*l+n-2)*(n-1)/2;
      }else{
        res=(2*l+n-1)*n/2;
      }
        System.out.println(res);
    }

}


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


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    min_no_coupon = sorted(a)[0] + sorted(b)[0]

    min_coupon = a[x[0] - 1] + b[y[0] - 1] - c[0]
    for i in range(1, M):
        min_coupon = min(min_coupon, a[x[i] - 1] + b[y[i] - 1] - c[i])

    print(min(min_coupon, min_no_coupon))

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

if __name__ == '__main__':
    main()


Measured memory_bytes: 24612
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll n,k ; cin>>n>>k ;
 if(k<= (n-1)*(n-2)/2){
   ll  x= ((n-1)*(n-2)/2)-k ;
   cout<< (n-1)+ x <<endl ;
   rep(i,n-1){
       cout<<n<<" "<<i+1<<endl ;
   }
   if(x>0){
       bool ok=0 ;
       rep2(i,1,n-2){
           if(ok) break ;
           rep2(j,i+1,n-1){
               x-- ;
               
               cout<< i<< " "<<j<<endl ;
               if(x==0){
                   ok= 1 ;
                   break ;
               }
           }
       }
   }
 }
 else cout<<-1<<endl ;
 return 0 ; 
}



Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
bitset<10010> ok[2010];
pair<int,int> p[2][10010];
char s[2010][10010],ans[1000010];
int len[2010],n,k,cnt=0,ncnt=0;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);//
        len[i]=strlen(s[i]+1);//
    }
    ok[n+1][0]=1;
    for (int i=n;i>=1;i--)
        ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
    for (int i=1;i<=n;i++)
        if (ok[i+1][k-len[i]]) p[0][++cnt]=make_pair(i,1);
    int f=0;
    for (int i=1;i<=k;i++)
    {
        char mi='z';
        for(int j=1;j<=cnt;j++){
            mi=min(mi,s[p[f][j].first][p[f][j].second]);
        }
        ans[i]=mi;
        //cout<<ans[i]<<endl;
        ncnt=0;
        int pp=n+1;
        for(int j=1;j<=cnt;j++){
            int id=p[f][j].first,pos=p[f][j].second;
            if(mi!=s[id][pos])continue;
            if(pos==len[id])pp=min(pp,id);//
            else p[f^1][++ncnt]=make_pair(id,pos+1);
        }
        for(int j=pp+1;j<=n;j++){
            if(k>=i+len[j]&&ok[j+1][k-i-len[j]])p[f^1][++ncnt]=make_pair(j,1);//
        }
        f^=1;
        cnt=ncnt;
    }
    printf("%s\n",ans+1);
    return 0;
}

Measured memory_bytes: 22016
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	long long a[N+1];
	long long b[N+1];
	long long c[N+1];
	long long bb[N+1];
	long long cc[N+1];
	long long x[N+2];
	long long n, k;
	long long s, ans;
	ans = -1000000000000000000;
	scanf("%lld %lld", &n, &k);
	f(i, n){
		scanf("%lld %lld", &x[i+1],&a[i+1]);
	}
	x[0] = 0;
	x[n + 1] = k;
	b[0] = 0;
	c[0] = 0;
	bb[0] = 0;
	cc[0] = 0;
	f(i, n){
		b[i + 1] = b[i] + a[i + 1] + x[i] - x[i + 1];
		c[i + 1] = c[i] + a[n - i] + x[n - i] - x[n + 1 - i];
		bb[i + 1] = b[i + 1] - x[i + 1];
		cc[i + 1] = c[i + 1] + x[n - i] - k;
	}
	f(i, n){
		b[i + 1] = max(b[i], b[i + 1]);
	}
	f(i, n){
		c[i + 1] = max(c[i], c[i + 1]);
	}
	f(i, n){
		ans = max(ans, bb[i] + c[n - i]);
		ans = max(ans, cc[i] + b[n - i]);
	}

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

	return 0;
}

Measured memory_bytes: 9088
S = input()
T = input()

if len(T) == 2 and S[0] == T[0]:
    print("Yes")
else:
    if S[0] == T[0]:
        T = T.replace(S,"")
        if len(T)==1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 8988
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int K, N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K >> N;
	rep(i, 0, N) cin >> A[i];

	int ans = A[N - 1] - A[0];
	rep(i, 1, N) {
		int i_to_start = K - A[i];
		int start_to_i1 = A[i - 1];
		chmin(ans, i_to_start + start_to_i1);
	}
	cout << ans << endl;
}







Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	x = x - (x / b) * b;
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int a = ni();
		int b = ni();
		int c = ni();

		int[] abc = { a, b, c };

		Arrays.sort(abc);

		int count = 0;
		count += abc[1] - abc[0] + abc[2] - abc[1];
		out(count);

	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 21844
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		String s = sc.next();
		
		String s_1 = s.substring(0, a);
		String s_2 = s.substring(a + 1);
		
		boolean b_1 = false;
		boolean b_2 = false;
		
		for(int i = 0; i < s_1.length(); ++i) {
		    if(Character.isDigit(s_1.charAt(i))) b_1 = true;
		    else {
		        b_1 = false;
		        break;
		    }
		}
		
		for(int i = 0; i < s_2.length(); ++i) {
		    if(Character.isDigit(s_2.charAt(i))) b_2 = true;
		    else {
		        b_1 = false;
		        break;
		    }
		}
		
		String ans = s_1 + '-' + s_2;
		
        //System.out.println(s_1);
        //System.out.println(b_1);
        //System.out.println(s_2);
        //System.out.println(b_2);
        //System.out.println(s==ans);
      
		if(s.equals(ans) && b_1 && b_2) System.out.println("Yes");
		else System.out.println("No");
	    
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i++)
#define _rep(i,a,b) for(int i = a;i <= b;i++)
typedef long long ll;

const int maxn = 100010;
int ind[maxn];
int vis[maxn];
vector<int> to[maxn];

int bfs(int s,int t) {
	vis[s] = 1;
	queue<int> q;
	q.push(s);
	int ret = 0;
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(auto v:to[u]) {
			if(v == t) {
				ret++;
				continue;
			}
			if(vis[v]) continue;
			else {
				vis[v] = 1;
				q.push(v);
			}
		}
	}
	return ret;
}

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m;i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		ind[a]++;
		ind[b]++;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int four = 0,six = 0;
	int ok = 1;
	for(int i = 1;i <= n;i++) {
		if(ind[i]%2 == 1) ok = 0;
		if(ind[i] == 4) four++;
		if(ind[i] >= 6) six++;
	}
	if(ok && (four >= 3 || six >= 1)) printf("Yes\n");
	else if(four == 2) {
		int a = -1,b = -1;
		for(int i = 1;i <= n;i++) {
			if(ind[i] == 4) {
				if(a == -1) a = i;
				else b = i;
			}
		}
		int num = bfs(a,b);
		if(num == 4) printf("No\n");
		else printf("Yes\n");
	}
	else printf("No\n");
	
    return 0;
}


Measured memory_bytes: 6528
def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))

    cnt = 0
    for _ in range(N):
        A = list(map(int, input().split()))
        tmp = 0
        for i in range(M):
            tmp += A[i] * B[i]

        if tmp + C > 0:
            cnt += 1
        
    print(cnt)

main()

Measured memory_bytes: 38468
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s1 = list(input())
    s2 = list(input())

    s1_l = len(s1)
    s2_l = len(s2)

    dp = [[0 for _ in range(s1_l + 1)] for _ in range(s2_l + 1)]
    for i in range(s1_l + 1):
        dp[0][i] = i
    for i in range(s2_l + 1):
        dp[i][0] = i

    for i in range(1, s2_l+1):
        for j in range(1, s1_l+1):
            cost = 0 if s1[j-1] == s2[i-1] else 1
            dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost)

    print(dp[s2_l][s1_l])


if __name__ == '__main__':
    main()



Measured memory_bytes: 45824
#include <stdio.h>
int main(void)
{
	int ta,tn,ans[101];
	scanf("%d",&ta);
	for(tn=0;tn<ta;tn++)
	{
		int c,a,n,t=0;
		scanf("%d%d%d",&c,&a,&n);
		for(;;)
		{
			if(c>=1&&a>=1&&n>=1)
			{
				t+=1;
				c-=1;
				a-=1;
				n-=1;
			}
			else
			{
				break;
			}
		}
		for(;;)
		{
			if(c>=2&&a>=1)
			{
				t+=1;
				c-=2;
				a-=1;
			}
			else
			{
				break;
			}
		}
		for(;;)
		{
			if(c>=3)
			{
				t+=1;
				c-=3;
			}
			else
			{
				break;
			}
		}
		ans[tn]=t;
	}
	for(tn=0;tn<ta;tn++)
	{
		printf("%d\n",ans[tn]);
	}
	return 0;
}

Measured memory_bytes: 2656