akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

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

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

# GCDの結合則を利用する
# 左端、右端からの累積GCDを求めておくと、Aiを取り除いた場合のGCDがすぐに計算できる。
# つまり、
# L(i): n=0,...,iまでのGCD 
# R(i): n=i,...,N-1までのGCD
# このとき、Aiを除いた全体のGCDは、GCD(L(i-1), R(i+1))で計算できる。

L = [0]*N
R = [0]*N

L[0] = A[0]
R[-1] = A[-1]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    idx = N-1-i
    R[idx] = gcd(R[idx+1], A[idx])


#残りの N − 1 個の整数の最大公約数
mx = 0
for i in range(N):
	if i == N-1:	#後ろから1個めが抜かれた時
		v = L[N-2]
	elif i == 0:	#前から1個めが抜かれた時
		v = R[1]
	else:		#どれでもない時
		v = gcd(R[i+1], L[i-1])
	mx = max(v, mx)
print(mx)



Measured memory_bytes: 14400
//Name: Ticket Sales
//Level: 1
//Category: やるだけ
//Note:

/**
 * t_iからチケット1枚あたりの値段を求められれば良い。
 * 配列やif文などでやるだけ。
 */
#include <iostream>

using namespace std;

bool solve() {
    const int PRICE[] = {6000, 4000, 3000, 2000};
    for(int i = 0; i < 4; ++i) {
        int t, n;
        cin >> t >> n;
        cout << PRICE[t-1]*n << endl;
    }
    return false;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(0);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1192
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		int a[]=setArray(scan.nextInt());
		int cnt=1;
		int now=0;
		for(int i=0;i<a.length;i++,cnt++) {
			if(a[now]==2) {
				System.out.println(cnt);
				return;
			}
			now=a[now]-1;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 52412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100050;
map<int,int> s;
int x,n;
ll num[maxn];
int tot=0;
bool cmp(ll a,ll b) {
	return a>b;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&x);
		s[x]++;
	}
	for(map<int,int>::iterator it=s.begin();it!=s.end();it++) {
		if(it->second>=4) {
			num[++tot]=it->first;
			num[++tot]=it->first;
			continue;
		}
		else if(it->second>=2) {
			num[++tot]=it->first;
		}
	}
	sort(num+1,num+tot+1,cmp); 
	if(tot<2) {
		puts("0");
		return 0;
	}
	else {
		printf("%lld\n",(num[1]*num[2]));
		return 0;
	}
	return 0;
}

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

//関数
int check(vector<int> b){
    int result=-1;
    for(int i=0;i<b.size();i++){
        if(b.size()>i && b.at(i)==i+1){
            result=i+1;
        }
    }
    return result;
}
    
    
    
    
//main関数
int main() {
    
    
    
    //入力
    int N;
    cin >>N;
    
    vector<int> b(N);
    for(int i=0;i<N;i++){
        cin>>b.at(i);
    }
    
    
    
    
    
    
    
    
    
    
    //計算
    vector<int> c(N);
    bool able=true;
    for(int i=0;i<N;i++){
        /*cout <<check(b)<<" ";
        for(int j=0;j<b.size();j++){
            cout<<b.at(j);
        }
        cout<<endl;*/
        c.at(i)=check(b);
        if(check(b)>-1){
            b.erase(b.begin()+check(b)-1);
        }
    }
    reverse(c.begin(),c.end());
    
    
    
    
    
    
    
    
    
    
    
    
    //出力
    for(int i=0;i<N;i++){
        cout<<c.at(i)<<endl;
        if(c.at(i)==-1){
            break;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC146 E

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

"""
S := aの累積和
(Sj - Si) % k = j - i
ある整数mに対して
Sj - Si = m*k + j - i
Sj - j = m*k + Si - i
(Sj - j) - (Si - i) Ξ 0 (mod k)
(Sj - j) Ξ (Si - i) (mod k)
"""
n,k = LI()
a = LI()
s = [0] + list(accumulate(a))
ans = 0
d = defaultdict(int)
for j in range(n+1):
    t = (s[j] - j) % k
    if j >= k:
        x = (s[j-k] - (j-k)) % k
        d[x] -= 1
    ans += d[t]
    d[t] += 1
print(ans)
    


Measured memory_bytes: 105420
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 200 + 10;
const int inf = 0x3f3f3f3f;

int read()
{
	int x;
	scanf("%d", &x);
	return x;
} 

int N, L, a[maxn], ans = inf, res;

int main()
{
	N = read(), L = read();
	for(int i = 1; i <= N; i ++)
	{
		a[i] = i + L - 1;
		if(abs(a[i]) < abs(ans))ans = a[i];
		res += a[i];
	}
	cout << res - ans << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    X = int(S, 2)
    C = S.count('1')
    xc0 = X % (C + 1)
    xc1 = X % (C - 1) if C > 1 else 0

    def f(x):
        c = 0
        while x:
            c += 1
            x = x % bin(x).count('1')
        return c

    for i, s in enumerate(S):
        k = N - 1 - i
        if s == '0':
            print(f((xc0 + pow(2, k, C + 1)) % (C + 1)) + 1)
        else:
            if C > 1:
                print(f((xc1 - pow(2, k, C - 1)) % (C - 1)) + 1)
            else:
                print(0)


main()


Measured memory_bytes: 9372
a=input()
b=0
c=0
for i in range(len(a)):
  if a[i]=="A" or a[i]=="C" or a[i]=="G" or a[i]=="T":
    b=b+1
    if c<b:
      c=b
  if a[i]!="A" and a[i]!="C" and a[i]!="G" and a[i]!="T":
    b=0
print(c)

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;
    string s,t;
    cin >> s >> t;

    const pair<i64,i64> terminal=make_pair(-1,-1);
    vector<vector<i64>> memo(s.size()+1,vector<i64>(t.size()+1,0));
    vector<vector<pair<i64,i64>>> next(s.size()+1,vector<pair<i64,i64>>(t.size()+1,terminal));
    vector<vector<bool>> done(s.size()+1,vector<bool>(t.size()+1));
    function<i64(i64,i64)> rec=[&](i64 i,i64 j){
        if(done[i][j]) return memo[i][j];
        done[i][j]=true;
        if(i==s.size() or j==t.size()){
            return memo[i][j]=0;
        }
        i64 l=0;
        if(s[i]==t[j]){
            memo[i][j]=1;
            if(chmax(memo[i][j],rec(i+1,j+1)+1)) next[i][j]=make_pair(i+1,j+1);
        }else{
            if(chmax(memo[i][j],rec(i+1,j))) next[i][j]=make_pair(i+1,j);
            if(chmax(memo[i][j],rec(i,j+1))) next[i][j]=make_pair(i,j+1);
        }
        return memo[i][j];
    };

    string ans;
    if(s[0]==t[0]) ans+=s[0];
    rec(0,0);
    auto n=next[0][0];
    while(n!=terminal){
        i64 i=n.first,j=n.second;
        if(s[i]==t[j]) ans+=s[i];
        rec(i,j);
        n=next[i][j];
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 213504
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;
const int MX=2011,inf=0x3f3f3f3f;
char a[MX],b[MX];

int n;
int main(){
	scanf("%s%s",a,b);
	n=strlen(a);
	int sa=0,sb=0,ans=inf;
	for(int i=0;i<n;i++)a[i]-='0',b[i]-='0';
	for(int i=0;i<n;i++)sa+=a[i],sb+=b[i];
	if(!sb&&sa)return puts("-1"),0;
	for(int i=0;i<n;i++){
		static int L[MX],R[MX];
		int tans=0;
		
		for(int j=0;j<n;j++)L[j]=(b[j]?j:L[(j+n-1)%n]);
		for(int j=0;j<n;j++)L[j]=(b[j]?j:L[(j+n-1)%n]);
		
		for(int j=n-1;j>=0;j--)R[j]=(b[j]?j:R[(j+1)%n]);
		for(int j=n-1;j>=0;j--)R[j]=(b[j]?j:R[(j+1)%n]);
		
		for(int j=0;j<n;j++)tans+=(b[j]^a[j]);
		
		static int lr[MX];
		memset(lr,0,sizeof(int)*n);
		
		for(int j=0;j<n;j++)if(!b[j]&&a[j]){
			int dl=(j+n-L[j])%n,dr=(R[j]-j+n)%n;
			if(dl<=i)continue;
			dl-=i;
			lr[dl]=max(lr[dl],dr);
		}
		
		int X,Y=0,td=inf;
		for(X=n-1;X>=0;X--){
			td=min(td,X+Y);
			Y=max(Y,lr[X]);
		}
		
		tans+=td*2+i;
		
		ans=min(ans,tans);
		
		char t=b[0];for(int i=0;i<n-1;i++)b[i]=b[i+1];b[n-1]=t;
	}
	for(int i=0,j=n-1;i<j;i++,j--)swap(a[i],a[j]),swap(b[i],b[j]);
	for(int i=0;i<n;i++){
		static int L[MX],R[MX];
		int tans=0;
		
		for(int j=0;j<n;j++)L[j]=(b[j]?j:L[(j+n-1)%n]);
		for(int j=0;j<n;j++)L[j]=(b[j]?j:L[(j+n-1)%n]);
		
		for(int j=n-1;j>=0;j--)R[j]=(b[j]?j:R[(j+1)%n]);
		for(int j=n-1;j>=0;j--)R[j]=(b[j]?j:R[(j+1)%n]);
		
		for(int j=0;j<n;j++)tans+=(b[j]^a[j]);
		
		static int lr[MX];
		memset(lr,0,sizeof(int)*n);
		
		for(int j=0;j<n;j++)if(!b[j]&&a[j]){
			int dl=(j+n-L[j])%n,dr=(R[j]-j+n)%n;
			if(dl<=i)continue;
			dl-=i;
			lr[dl]=max(lr[dl],dr);
		}
		
		int X,Y=0,td=inf;
		for(X=n-1;X>=0;X--){
			td=min(td,X+Y);
			Y=max(Y,lr[X]);
		}
		
		tans+=td*2+i;
		
		ans=min(ans,tans);
		
		char t=b[0];for(int i=0;i<n-1;i++)b[i]=b[i+1];b[n-1]=t;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s, t;
   cin >> s >> t;
   for(int i = 0;i < s.length();i++) {
       bool yes = true;
       int flag = i;

       for(int j = 0;j < s.length();j++) {
           if(s[j]!=t[flag]){
            //    cout << "no  "<< "s:" << " " << s[j] << " " << "t:" << " " << t[flag] << endl;
               yes = false;
           } else {
            //    cout << "yes  "<<"s:" << " " << s[j] << " " << "t:" << " " << t[flag] << endl;
           }
           if(flag<s.length()-1) flag++;
           else flag = 0;
       }
    //    cout << "-------------------------" << endl;
       if(yes) {
           cout << "Yes" << endl;
           return 0;
       }
   }
   cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+1;

vector<int> adj[maxn];
bool vis[maxn];
int path[maxn];

void dfs(int node) {
    vis[node] = 1;
    // path[node] = 0;
    for(int x : adj[node]) {
        if(! vis[x]) dfs(x);
        path[node] = max(path[node], path[x] + 1);
    }
}

void solve() {
    int N, M, x, y; cin>>N>>M;
    for(int i=0;i<M;i++) {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i = 1; i <= N; i++) {
        if(! vis[i]) dfs(i);
    }
    int ans = 0;
    for(int i = 1; i<= N; i++) {
        ans = max(ans, path[i]);
    }
    cout << ans << "\n";
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 12104
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int a[51];
int main()
{
	int n,k;
	int sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n,cmp);
	for(int i=0;i<k;i++)
	sum+=a[i];
	cout<<sum<<endl;
	return 0;
} 

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

public class Main {
  public static void main(String[] args) {
    final int INIT_NUM = -1;

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    x--; y--;

    int[] result = new int[n];

    for (int i = 0; i < n; i++) {
      int[] dest = new int[n]; //k+1のノードの基準との最短距離（kは配列のインデックス）
      Arrays.fill(dest, INIT_NUM);
      Deque<Integer> queue = new ArrayDeque<>();

      queue.add(i);
      dest[i] = 0;
      while (!queue.isEmpty()) {
        int pos = queue.poll();

        if (pos < n - 1 && dest[pos + 1] == INIT_NUM) {
          queue.add(pos + 1);
          dest[pos + 1] = dest[pos] + 1;
        }

        if (pos > 0 && dest[pos - 1] == INIT_NUM) {
          queue.add(pos - 1);
          dest[pos - 1] = dest[pos] + 1;
        }

        if (pos == x && dest[y] == INIT_NUM) {
          queue.add(y);
          dest[y] = dest[pos] + 1;
        }
      }

      for (int j = i; j < n; j++) {
        result[dest[j]]++;
      }
    }

    for (int i = 1; i < n; i++) {
      System.out.println(result[i]);
    }

  }
}


Measured memory_bytes: 57436
from operator import itemgetter


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

max_s = 0
for i in range(n):
    w, s, _ = info[i]
    max_s = max(max_s, s)
    info[i].append(s + w)
info = sorted(info, key = itemgetter(3))

dp = [[0]*(20010) for i in range(n+1)]

for i in range(n):
    w, s, v, _ = info[i]
    for j in range(20010):
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
        if s - j >= 0:
            dp[i+1][j+w] = max(dp[i][j] + v, dp[i+1][j+w])
print(max(dp[n]))

Measured memory_bytes: 192152
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {  
    string s;
    cin >> s;
    int dig = 0;
    for(auto it : s) {
        dig += it - '0';
        dig %= 9;
    }
    cout << (dig % 9 == 0 ? "Yes\n" : "No\n");
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

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

#define mod 1000000007

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

using namespace std;

int main(void){
	
	int n, m, x, y;
	
	cin >> n >> m >> x >> y;
	
	int X[100], Y[100];
	
	int inin;
	
	for(int i = 0; i < n; i++)
		cin >> X[i];
	
	for(int i = 0; i < m; i++)
		cin >> Y[i];
	
	sort(X, X+n);
	sort(Y, Y+m);
	
	bool ok = 0;
	
	for(int i = x+1; i <= y; i++)
		if (i > X[n-1] && i <= Y[0])
			ok = 1;

	cout << (ok?"No War":"War") << endl;

	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	int opening = 0;
	int needed_opening = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == ')') {
			if (opening) {
				--opening;
			} else {
				++needed_opening;
			}
		} else {
			++opening;
		}
	}

	string correct(needed_opening, '(');

	opening = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '(') {
			++opening;
		} else {
			opening = max(0, opening - 1);
		}

		correct += s[i];
	}
	
	correct += string(opening, ')');

	cout << correct << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll a, b, m;
    cin >> a >> b >> m;
    ll inf = 1e9;
    ll mina = inf, minb = inf;
    ll res = 0;
    vector<ll> A(a), B(b);
    for (auto & p : A) {
        cin >> p;
        mina = min(mina, p);
    }
    for (auto & p : B) {
        cin >> p;
        minb = min(minb, p);
    }
    res = mina + minb;
    for (ll i = 0; i < m; ++i) {
        ll x, y, c;
        cin >> x >> y >> c;
        res = min(res, A[x-1] + B[y-1] - c);
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int cAc = 0;
        int cWa = 0;
        int cTle = 0;
        int cRe = 0;
        for(int i=0; i<n; i++){
            string str = Console.ReadLine();
            if(str.Equals("AC")){
                cAc++;
            }
            else if(str.Equals("WA")){
                cWa++;
            }
            else if(str.Equals("TLE")){
                cTle++;
            }
            else{
                cRe++;
            }
        }
        Console.WriteLine("AC x {0}",cAc);
        Console.WriteLine("WA x {0}",cWa);
        Console.WriteLine("TLE x {0}",cTle);
        Console.WriteLine("RE x {0}",cRe);
    }
}


Measured memory_bytes: 20840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    map<string, int> smap;
    vector<string> v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;   cin >> s;
        if (smap.find(s) != smap.end()) smap[s]++;
        else {
            smap[s] = 1;
            v.push_back(s);
        }
    }

    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;   cin >> s;
        if (smap.find(s) != smap.end()) smap[s]--;
    }

    int ret = 0;
    for (auto e: v) {
        ret = max(smap[e], ret);
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 504
def cumsum2d(m)
  h = m.size-1
  w = m[0].size-1
  ms = Array.new(h+1){Array.new(w+1, 0)}
  (h+1).times do |i|
    w.times do |j|
      ms[i][j+1] = ms[i][j] + m[i][j+1]
    end
  end
  (w+1).times do |j|
    h.times do |i|
      ms[i+1][j] = ms[i][j] + ms[i+1][j]
    end
  end
  return ms
end

def get2dsum(m, x, y, w, h)
  return m[y-1+h][x-1+w] - m[y-1][x-1+w] - m[y-1+h][x-1] + m[y-1][x-1]
end

while true
  n = gets.chomp.to_i
  break if n == 0
  w, h = gets.chomp.split(" ").map(&:to_i)
  m = Array.new(h+1){Array.new(w+1, 0)}
  n.times do
    x, y = gets.chomp.split(" ").map(&:to_i)
    m[y][x] = 1
  end
  ms = cumsum2d(m)
  ret = 0
  s, t = gets.chomp.split(" ").map(&:to_i)
  (1..(h-t+1)).each do |i|
    (1..(w-s+1)).each do |j|
      ret = [ret, get2dsum(ms, j, i, s, t)].max
    end
  end
  puts ret
end

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

int main()
{
    int k, s, count=0;
    cin >> k >> s;

    for (int i = 0; i < k + 1; i++)
    {
        for (int j = 0; j < k + 1; j++)
        {
            if(0<=s-(i+j) && s-(i+j)<=k) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
program b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,ans,i
    integer(int64),allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    if (minval(a) == 0) then
        print'(i0)', 0
        stop
    end if

    ans=1

    do i=1,n
        if (log10(dble(ans))+log10(dble(a(i))) > 18) then
            print'(i0)', -1
            stop
        else
            if (ans*a(i) > 1000000000000000000_8) then
                print'(i0)', -1
                stop
            end if
            ans=ans*a(i)
        end if
    end do
    print'(i0)', ans
end program b

Measured memory_bytes: 3840
#include <stdio.h>

int main() {
    int i, j, H, W, K, black, ans, biti, bitj;
    black = ans = 0;

    scanf("%d %d %d", &H, &W, &K);

    char buf, c[H][W];

    for (i = 0; i < H; i++) {
        scanf("%c", &buf);

        for (j = 0; j < W; j++) {
            scanf("%c", &buf);
            c[i][j] = buf;
        }
    }

    for(biti=0; biti < (1 << H); biti++) {
        for(bitj=0; bitj < (1 << W); bitj++) {
            black = 0;

            for(i=0; i < H; i++) {
                for(j=0; j < W; j++) {
                    if((c[i][j] == '#') && !((biti >> i) & 1) && !((bitj >> j) & 1)) {
                        black++;
                    }
                }
            }
            if(black == K) ans++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1736
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int main()
{
    fast;
    cin>>s;
    for (int i=0;i<=s.size();i++)
       if (s[i]=='A' && s[i+1]=='C')
       {
       	   cout<<"Yes"<<endl;
       	   return 0;
       }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const bList = input[1].split(' ').map(x => parseInt(x, 10));

    var total = bList[0];
    for (var i = 0; i < N - 2; i++) {
        total += Math.min(bList[i], bList[i + 1])
    }

    total += bList[N - 2];
    console.log(total);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    
    int sums=0;
    int& sum=sums;
    
    cin>>a>>b>>c;
    
    int num[3]={a+b,a+c,b+c};
    
    sum=num[0];
    for(int i=0;i<3;i++){
        if(sum>num[i])
        sum=num[i];
    }
    
    cout<<sum<<endl;

}


Measured memory_bytes: 256
// @author: Liz
 
#include <bits/stdc++.h>
using namespace std;
 
const int K_MAX = 2500;
 
int k, s;
bool sz[2 * K_MAX + 1];
 
void solve(){
    for (int i = 0; i <= k; i++)
        if (0 <= s - i && s - i <= 2 * k) sz[s - i] = true;
 
    int cnt = 0;
    for (int i = 0; i <= k; i++)
        for (int j = 0; j <= k; j++) cnt += static_cast<int>(sz[i + j]);
 
    printf("%d\n", cnt);
}
 
int main(void){
    cin >> k >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i, 3*n)cin >> a[i];
    sort(all(a));
    ll s = 0, e = 3 * n - 1, ans = 0;
    rep(i, n){
        ans += a[e-1];
        e-=2;
        s++;
    }
    cout << ans << endl;
}      

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

long long n,k,out;
long long num[200010];

int main()
{
	cin>>n>>k;
	for(int i = 1;i <= n;i++)
	{
		cin>>num[i];
	}
	
	sort(num + 1,num + 1 + n);
	
	for(int i = 1;i <= n - k;i++)
	{
		out += num[i];
	}
	
	cout<<out;
	
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
int main() {
    char cup = 'A';
    char a, b;
    while (scanf("%c,%c", &a, &b) != EOF) {
        if (a == cup) {
            cup = b;
        }
        else if (b == cup) {
            cup = a;
        }
    }
    printf("%c\n", cup);
    return 0;
}

Measured memory_bytes: 544
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    for(int i = 1; i <= n; i++){
      int x = i;
      if(x % 3 == 0){
        System.out.print(" " + i);
      }
      else{
        while(x != 0){
          if(x % 10 == 3){
            System.out.print(" " + i);
            x = 0;
          }
          x /= 10;
        }
      }
    }
    System.out.println();
  }
}

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

int main() {
  int n; cin >>n;
  vector<int> a(n+1),b(n+1),c(n);
  for (int i=1; i<n+1; i++) cin >>a.at(i);
  for (int i=1; i<n+1; i++) cin >>b.at(i);
  for (int i=1; i<n; i++) cin >>c.at(i);
  c.at(0) = 0;
  
  int ans = 0;
  for (int i=1; i<=n; i++){
    ans += b.at(a.at(i));
    if (a.at(i) == a.at(i-1)+1){
      ans += c.at(a.at(i-1));
    }
    //cout <<ans <<endl;
  }
  
  cout <<ans;
  cout <<endl;
}


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

int main(){
  int H , W ; 
  cin >> H >> W ; 
  vector<vector<char>> C(H , vector<char>(W)) ;
  
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> C.at(i).at(j) ;
    }
  }
  
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cout << C.at(i).at(j)  ; 
    }
    cout << endl; 
    for(int j = 0 ; j< W ; j++){
      cout << C.at(i).at(j) ;
    }
    cout << endl ; 
    
  }
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;
Int s[103];
void solve() {
    Int n;
    cin >> n;

    REP(i, n) {
        cin >> s[i];
    }
    Int sum = 0;
    REP(i,n){sum += s[i];}
    if (sum % 10 != 0){
        cout << sum << endl;
        return;
    }
    
    Int v = sum;
    REP(i, n){
        if (s[i] < v && s[i] % 10 != 0) {
            v = s[i];
        }
    }
    cout << sum - v << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

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


Measured memory_bytes: 256
n,m,k=map(int, input().split())
*a,=map(int, input().split())
*b,=map(int, input().split())
now=0
cnt=0
from itertools import accumulate  
a=list(accumulate(a))
a=[0]+a
b=list(accumulate(b))

from bisect import bisect_right
tmp=0
for i in range(n+1):
    ta=k-a[i]
    nb=bisect_right(b,ta)
    if ta>=0:
        tmp=max(tmp,nb+i)
        #print(nb,i)
print(tmp)

Measured memory_bytes: 134304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<int> dx = {-1, 1, 0, 0};
vector<int> dy = {0, 0, -1, 1};

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, w, k; cin >> h >> w >> k;
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	char c[h][w]; zep(i, 0, h)zep(j, 0, w)cin >> c[i][j];
	
	int ans[h][w][2]; memset(ans, -1, sizeof(ans));
	ans[sx][sy][0] = 0;
	ans[sx][sy][1] = 0;
	
	//int rem[h][w][2];
	//rem[sx][sy][0] = k;
	//rem[sx][sy][1] = k;
	
	bool use[h][w][2]; memset(use, 0, sizeof(use));
	use[sx][sy][0] = true;
	use[sx][sy][1] = true;
	
	queue<vector<int>> q;
	q.push({sx, sy, 0});
	q.push({sx, sy, 1});
	
	while(!q.empty()){
		auto v = q.front(); q.pop();
		int x = v[0], y = v[1], d = v[2];
		
		zep(i, 0, 4){
			if((d == 0 && i >= 2) || (d == 1 && i <= 1)){
				rep(j, 1, k){
					int nx = x + j * dx[i];
					int ny = y + j * dy[i];
					
					if(0 <= nx && nx < h && 0 <= ny && ny < w){
						if(c[nx][ny] == '@')break;
						
						if(!use[nx][ny][1 - d]){
							use[nx][ny][1 - d] = true;
							ans[nx][ny][1 - d] = ans[x][y][d] + 1;
							//rem[nx][ny][1 - d] = k - j;
							q.push({nx, ny, 1 - d});
						}else{
							if(ans[nx][ny][1 - d] < ans[x][y][d] + 1)break;
						}
						
						if(j == k && !use[nx][ny][d]){
							use[nx][ny][d] = true;
							ans[nx][ny][d] = ans[x][y][d] + 1;
							//rem[nx][ny][d] = k;
							q.push({nx, ny, d});
						}
					}
				}
			}
		}
	}
	
	//zep(i, 0, h){zep(j, 0, w){cout << ans[i][j][0] << " ";}cout << endl;}
	//cout << endl;
	//zep(i, 0, h){zep(j, 0, w){cout << ans[i][j][1] << " ";}cout << endl;}
	
	int res = h * w + 100;
	if(use[gx][gy][0]){
		res = min(res, ans[gx][gy][0]);
	}
	if(use[gx][gy][1]){
		res = min(res, ans[gx][gy][1]);
	}
	print((res == h * w + 100)? -1 : res)
	
	return 0;
}

Measured memory_bytes: 22404
//In the name of God

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 1e5 + 5;

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int w = 0;
	for (char c : s) {
		if (c == 'W') {
			w++;
		}
	}
	int ans = 0;
	int j = n - 1;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			while (j >= 0 && s[j] == 'W') {
				j--;
			}
			if (j <= i) {
				break;
			}
			swap (s[i], s[j]);
			ans++;
		}
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);	
    cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case " <<;
		solve();
		// cout << chk(2);
	}
}

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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

inline pair<int, int> min(pair<int, int> a, pair<int, int> b)
{
    return (a > b) ? b : a;
}

int n, ar[200001];
pair<int, int> t[800001][2];

void build(int tl, int tr, int v)
{
    if(tr == tl)
    {
        t[v][tl % 2].fr = ar[tl];
        t[v][(tl + 1) % 2].fr = 1e9;
        t[v][0].sc = tr;
        t[v][1].sc = tr;
    }else
    {
        int tm = (tr + tl) >> 1;
        build(tl, tm, v + v);
        build(tm + 1, tr, v + v + 1);

        t[v][1] = min(t[v + v][1], t[v + v + 1][1]);
        t[v][0] = min(t[v + v][0], t[v + v + 1][0]);
    }
}

pair<int, int> get(int tl, int tr, int l, int r, int v, int num)
{
    if(l > r)
        return mk(1e9, 0);
    if(tr == r && tl == l)
        return t[v][num];
    else
    {
        int tm = (tr + tl) >> 1;
        return min(get(tl, tm, l, min(tm, r), v + v, num), get(tm + 1, tr, max(l, tm + 1), r, v + v + 1, num));
    }
}

int timer = 0, sz[200001], p[200001];
vector<int> vec[100001];
pair<int, int> ars[200001];

void f(int l, int r)
{
    vector<pair<int, int> > ans;
    if(l > r)
        return;

    timer++;
    int x = timer;

    int a, b;
    a = get(1, n, l, r, 1, l % 2).sc;
    b = get(1, n, a + 1, r, 1, (l + 1) % 2).sc;

    ars[timer] = mk(ar[a], ar[b]);
    if(l < a - 1)
        vec[x].push_back(timer + 1), p[timer + 1] = x, f(l, a - 1), sz[x]++;
    if(a + 1 < b - 1)
        p[timer + 1] = x, vec[x].push_back(timer + 1), f(a + 1, b - 1), sz[x]++;
    if(b + 1 < r)
        p[timer + 1] = x, vec[x].push_back(timer + 1), f(b + 1, r), sz[x]++;
}

int main()
{
    sz[0] = 5;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> ar[i];

    build(1, n, 1);

    vector<pair<int, int> > ans;
    f(1, n);
    int inf = 1e9;
    set<pair<pair<int, int>, int> > st;
    st.insert(mk(ars[1], 1));
    while(!st.empty())
    {
        pair<pair<int, int>, int> k = *st.begin();
        st.erase(k);
        for(int i = 0; i < vec[k.sc].size(); i++)
        {
            int to = vec[k.sc][i];
            st.insert(mk(ars[to], to));
        }
        ans.push_back(k.fr);
    }

    //reverse(ans.begin(), ans.end());

    for(int i = 0; i < ans.size(); i++)
        cout << ans[i].fr << " " << ans[i].sc << " ";
    return 0;
}


Measured memory_bytes: 30836
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int a[0];
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int n;
bool isOK(int index,int key) {
    if ( a[index]>key )return true;
    else return false;
}
int binary_search(vector<int> l ,int i,int j){
  ll ng =-1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = j;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    
    if (isOK(mid, abs(a[i]-a[j]))) ok = mid;
    else ng = mid;
  }
  return ok ;
}

int main(){
  cin>>n;
  string s,t;
  cin>>s>>t;
  vector<char> ans;
  rep(i,n) {
    ans.push_back(s[i]);
    ans.push_back(t[i]);
  }
  rep(i,2*n) cout<< ans[i];
}
  


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0; i<n; ++i)
        cin >> a.at(i);

    for(int i=0,ic=0; i<(n-1); ++i) {
        if(a.at(i) >= a.at(i+1))
            b.at(ic) += 1;
        else
            ++ic;
    }

    int max = *max_element(b.begin(), b.end());
    cout << max;
}


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

using ll = long long;


int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N); for (int i = 0; i < N; i++) cin >> h[i];

	int c = 0;
	for (int i = 0; i < N; i++) {
		if (h[i] >= K) {
			c++;
		}
	}

	cout << c << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD = 1000000007;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<vector<int>> one(n),zero(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int x,y;
            cin >> x >> y;
            x--;
            if(y == 0) zero[i].push_back(x);
            else        one[i].push_back(x);
        }
    }

    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        bool ok = true;
        int num = 0;
        for(int j=0;j<n;j++){
            if(i>>j & 1){
                num++;
                for(int a : zero[j]){
                    if(i>>a & 1){
                        ok = false;
                    }
                }
                for(int a : one[j]){
                    if((i>>a&1) == 0){
                        ok = false;
                    }
                }
            }
        }
        if(ok) ans = max(ans,num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  for(int j=0;j<2;j++){
    for(int i=0;i<2;i++){
      int x=c[i][j]-c[i][j+1];
      int y=c[i+1][j]-c[i+1][j+1];
      if(x!=y){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      int x=c[i][j]-c[i+1][j];
      int y=c[i][j+1]-c[i+1][j+1];
      if(x!=y){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#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     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M, L[101010], R[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) cin >> L[i] >> R[i];
	
	int l = 0, r = N;
	rep(i, 0, M) {
		chmax(l, L[i]);
		chmin(r, R[i]);
	}
	
	int ans = 0;
	chmax(ans, r - l + 1);
	cout << ans << endl;
}


Measured memory_bytes: 1024
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let mut g = vec![vec![1 << 30; n]; n];
    let mut edges = Vec::new();
    for _ in 0..m {
        let a: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let c: usize = itr.next().unwrap().parse().unwrap();
        g[a][b] = c;
        g[b][a] = c;
        edges.push((a, b, c));
    }
    for i in 0..n {
        g[i][i] = 0;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..m {
        if g[edges[i].0][edges[i].1] != edges[i].2 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    map<int,int> mp;
    int cur=0;
    rep(i,N){
        CIN(a);
        if(1<=a&&a<400)mp[0]++;
        else if(400<=a&&a<800)mp[1]++;
        else if(800<=a&&a<1200)mp[2]++;
        else if(1200<=a&&a<1600)mp[3]++;
        else if(1600<=a&&a<2000)mp[4]++;
        else if(2000<=a&&a<2400)mp[5]++;
        else if(2400<=a&&a<2800)mp[6]++;
        else if(2800<=a&&a<3200)mp[7]++;
        else cur++;
    }
    int nmax,nmin;
    nmin=max(1,sz(mp));
    nmax=sz(mp)+cur;

    printf("%d %d\n",nmin,nmax);

    return 0;
}

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

public class Main {

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

		for (int i = 0; i < n; i++) {
			num[i] = scan.nextInt();
		}

		int count = 0;

		for (int i = 0; i < n; i++) {
			int mini = i;
			for (int j = i; j < n; j++) {
				if (num[j] < num[mini]) {
					mini = j;
				}
			}

			if (mini != i) {
				int tmp = num[i];
				num[i] = num[mini];
				num[mini] = tmp;
				count++;
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(num[i]);
			if (i != n - 1)
				System.out.print(" ");
		}

		System.out.println();
		System.out.println(count);
		scan.close();
	}

}

Measured memory_bytes: 19760
//２つの整数 x, y を読み込み、それらを値が小さい順に出力するプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iInputDataA;
    int iInputDataB;
    int iTemporary;
    int iCount;

    //変数の初期化
    iInputDataA = 1;
    iInputDataB = 1;
    iTemporary = 0;

    for (iCount = 0; (iInputDataA != 0) || (iInputDataB != 0); iCount++)
    {
        scanf("%d %d",&iInputDataA, &iInputDataB);
        if (iInputDataA > iInputDataB)
        {
            iTemporary = iInputDataA;
            iInputDataA = iInputDataB;
            iInputDataB = iTemporary;
        }
        else 
        {
            //何もしない
        }
        if ((iInputDataA != 0) || (iInputDataB != 0))
        {
            printf("%d %d\n",iInputDataA,iInputDataB);
        }
    }

    return 0;
}


Measured memory_bytes: 2036
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void probD() {
	int N; cin >> N;
	vi vec(N);
	rep(i, N) cin >> vec[i];
	sort(ALL(vec),greater<int>());
	
	ll ans = -vec[0];
	for (int i = 0; i < N; i++) {
		int label = i / 2;
		ans += vec[label];
	}

	cout << ans << endl;
}

vector<vector<int>> Bitwise_AllSearch(int digit) {
	vector<vector<int>> res;

	for (int bit = 0; bit < (1 << digit); bit++) {
		vector<int> S;
		for (int i = 0; i < digit; i++) {
			if (bit & (1 << i)) {
				S.push_back(i);
			}
		}

		res.push_back(S);
	}

	return res;
}
int calcBlackC(vvi& table) {
	int cnt = 0;
	for (auto row : table) {
		for (auto elem : row) {
			if (elem == 1) {
				cnt++;
			}
		}
	}
	return cnt;
}
int solve(vvi table, vi Ha, vi Wb, int K) {
	int H = table.size();
	int W = table[0].size();
	for (auto h : Ha) {
		for (int j = 0; j < W; j++)
			table[h][j] = 2;
	}
	for (auto w : Wb) {
		for (int i = 0; i < H; i++) {
			table[i][w] = 2;
		}
	}

	if (calcBlackC(table) == K) {
		return 1;
	}
	else {
		return 0;
	}
}

void probC() {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<int>> table(H, vector<int>(W));

	rep(i, H)rep(j, W) {
		char c; cin >> c;
		if (c == '.') {
			table[i][j] = 0;
		}
		else {
			table[i][j] = 1;
		}
	}
	// white is zero black is one
	vvi vecH, vecW;
	vecH = Bitwise_AllSearch(H);
	vecW = Bitwise_AllSearch(W);
	int ans = 0;

	for (auto elemH : vecH) {
		for (auto elemW : vecW) {
			ans += solve(table, elemH, elemW, K);
		}
	}

	cout << ans << endl;
}


int main() {
	probC();
}

Measured memory_bytes: 3616