akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=998244353;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1)
    {
        cout<<1<<'\n';
        return 0;
    }
    ll ans=(h*w+1)/2;
    cout<<ans<<'\n';










}


Measured memory_bytes: 3624
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        boolean f = true;
        for(int i=0; i<S.length(); i++) {
            if(S.charAt(i) != T.charAt(i)) f = false;
        }
        if(f == true && T.length() == S.length()+1) System.out.println("Yes");
        else System.out.println("No");
	}
}

Measured memory_bytes: 35696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int A[100000], a[50000], b[50000];
	pair<int, int> B[100000];
	rep(i, N) {
		cin >> A[i];
		B[i] = mp(A[i], i);
	}
	sort(B, B + N);
	rep(i, N) {
		A[B[i].second] = i;
	}

	int kotae = 0;
	rep(i, N) {
		if ((i + A[i]) % 2) kotae++;
	}
	co(kotae / 2);

	Would you please return 0;
}

Measured memory_bytes: 1408
N = int(input())
S =input()
M =len(S)
S = list(S)
def f(a):
    if a == "A":
        a = "B"
    elif a == "B":
        a = "C"
    elif a == "C":
        a = "D"
    elif a == "D":
        a = "E"
    elif a == "E":
        a = "F"
    elif a == "F":
        a = "G"
    elif a == "G":
        a = "H"
    elif a == "H":
        a = "I"
    elif a == "I":
        a = "J"
    elif a == "J":
        a = "K"
    elif a == "K":
        a = "L"
    elif a == "L":
        a = "M"
    elif a == "M":
        a = "N"
    elif a == "N":
        a = "O"
    elif a == "O":
        a = "P"
    elif a == "P":
        a = "Q"
    elif a == "Q":
        a = "R"
    elif a == "R":
        a = "S"
    elif a == "S":
        a = "T"
    elif a == "T":
        a = "U"
    elif a == "U":
        a = "V"
    elif a == "V":
        a = "W"
    elif a == "W":
        a = "X"
    elif a == "X":
        a = "Y"
    elif a == "Y":
        a = "Z"
    elif a == "Z":
        a = "A"
    return a

for i in range(M):
    if N != 0:
        for j in range(N):
            S[i] = f(S[i])

print(''.join(S))

Measured memory_bytes: 3188
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);

        var sunuke = new int[n];

        for(int i=0; i<k; i++) {
            var d = int.Parse(input.ReadLine());
            spl = input.ReadLine().Split(' ');
            for(int j=0; j<d; j++) {
                var a = int.Parse(spl[j]);
                sunuke[a - 1]++;
            }
        }

        return sunuke.Count(x => x == 0);
    }
}


Measured memory_bytes: 28000
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------
vector<int> p;
const int MAXN = 1000;

void init(){
    p.clear();
    bool f[MAXN+1];
    memset(f, false, sizeof(f));
    for(int i=2; i<= MAXN; ++i){
        if (f[i]) continue;
        p.push_back(i);
        for(int j=i*i; j<=MAXN; j+=i){
            f[j]=true;
        }
    }

}


int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    init();
    vector<int> d(168,0);
    map<int, int> mp;
    mp.clear();
    bool f1= true;
    int gcd;
    for(int i=0; i<n; ++i){
        int u;
        cin >> u;
        if (i==0) gcd=u; else gcd = __gcd(gcd, u);
        if (!f1) continue;
        if (u==1) continue;
        bool can= false;
        for(int j=0; j<168; ++j){
            if (u%p[j]==0){
                d[j]++;
                while (u%p[j]==0) u/=p[j];
                can=true;
            }

            if (d[j]>=2) f1=false;
        }

        if (!can){
            mp[u]++;
            if (mp[u]>=2) f1=false;
        } else {
               if(u>1) {
                mp[u]++;
                if (mp[u]>=2) f1=false;
            }
        }
    }
    if (f1) cout << "pairwise coprime"; else
    if (gcd==1) cout << "setwise coprime"; else cout << "not coprime";
    return 0;
}


Measured memory_bytes: 7272
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

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

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  ll N;
  ins(N);

  int ans = 0;
  map<int, int> factor;
  for (ll i = 2; i * i <= N; ++i) {
    while (N % i == 0) {
      N /= i;
      ++factor[i];
    }
  }
  if (N > 1)
    ++factor[N];
  for (const auto& [p, e]:factor) {
    int count = 0;
    rep(i, 30) {
      count += i+1;
      if (count > e) {
        ans += i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int H, W, D;
	cin >> H >> W >> D;
	vi px(H * W), py(H * W);
	rep(i, H) rep(j, W) {
		int A;
		cin >> A;
		A--;
		px[A] = j, py[A] = i;
	}

	vi d(H * W, 0);
	repr(i, D, H * W) {
		d[i] += d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
	}

	int Q;
	cin >> Q;
	rep(i, Q) {
		int L, R;
		cin >> L >> R;
		L--; R--;
		cout << d[R] - d[L] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int X[100010];
    rep(i, N) cin >> X[i];
    int ans = 0;
    rep(i, N - 1) ans += min((X[i + 1] - X[i]) * A, B);
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, M, a, b;

  cin >> N >> M;
  
  vector<int> vec(N);
  
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    vec.at(a - 1)++;
    vec.at(b - 1)++;
  }
  
  for(int i = 0; i < N; i++){
    cout << vec.at(i) << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> t(n+1),x(n+1),y(n+1);
    repi(i,1,n+1){
        cin>>t[i]>>x[i]>>y[i];
        int dx=abs(x[i]-x[i-1]),dy=abs(y[i]-y[i-1]),dt=t[i]-t[i-1];
        if(dt<dx+dy||dt%2!=(dx+dy)%2){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 4552
import bisect #bisectの典型的問題
a,b,q = map(int, input().split())

s  = [int(input()) for i in range(a)]
t  = [int(input()) for i in range(b)]

INF=10**18
s=[-INF]+s+[INF] #グリッド系の問題では、配列外を探索しないように
t=[-INF]+t+[INF]
x  = [int(input()) for i in range(q)]
for i in range(q):
  xi = x[i] #xを一気に読み込まなくてもfor loopの中の方が良い
  si = bisect.bisect_right(s, xi)
  ti = bisect.bisect_right(t, xi)
  ans=INF
  
  for S in [s[si-1], s[si]]:
    for T in [t[ti-1], t[ti]]:
      SX = abs(S-xi)
      TX = abs(T-xi)
      ST = abs(S-T)
      ans = min(ans, SX+ST, TX+ST)
  print(ans)

Measured memory_bytes: 16780
while 1:
    n=int(raw_input())
    if n==0:
        break
    m=int(raw_input())
    s=[map(int ,raw_input().split(',')) for i in range(m)]
    s=sorted(s, key=lambda x:x[2])
    ls=range(n)
    ref=ls[:]
    ans=0
    while s:
        x,y,d=s.pop(0)
        a,b=ref[x],ref[y]
        if a!=b:
            for j in ls:
                if ref[j]==a:
                    ref[j]=b
            ans+=d/100-1
    print ans

Measured memory_bytes: 6976
// ------------------------------------
// Date:2018/ 3/31
// Problem:Kagami mochi / c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
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__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

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

  sort(ALL(v));

  int tmp = v[0];
  int ans = 1;
  REP(i, v.size()) {
    if (tmp < v[i]) {
      ans++;
      tmp = v[i];
    }
  }

  cout << ans << endl;

  return 0;
}



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

using namespace std;

const int maxi=1e6+10;
vector<int> v[maxi];
int a[maxi];
string s;
int ans,n;
int x;
int main()
{
    cin>>n>>x;

    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    sort(a+1,a+n+1);

    long long sum=0;
    for (int i=1;i<=n;i++)
    {
        sum+=a[i];
        if (sum>x) {cout<<i-1<<endl; return 0;}
    }

     if (sum==x)
        cout<<n<<endl; else
        cout<<n-1<<endl;
    return 0;
}
//DZANAN MUUUUSA


Measured memory_bytes: 25600
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  fo  freopen("out.txt","w",stdout);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
ll ch=3234566667;
//string s,p;
//vector<int>v;
//map<int,int>mp;
ll a[12];
set<ll>s;
void go(ll x)
{
    if(x<=ch)
    {
        s.insert(x);
        for(int i=0; i<10; i++)
        {
            ll val=(x*10)+a[i];
            if(val>0)
            {
                if(val<10)
                {
                    go(val);
                }
                else
                {
                    ll k=abs(a[i]-(x%10));
                    if(k==0 || k==1)
                    {
                        go(val);
                    }
                }
            }
        }
    }
    return;
}
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    for(i=0; i<10; i++)
    {
        a[i]=i;
    }
    go(0ll);
    cin>>l;
    i=0;
    for(r:s)
    {
        if(i==l)
        {
            cout<<r<<"\n";
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            string[] lines = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(lines[i]);
            }

            long ans1 = 0;
            long ans2 = 0;
            int sign = 1;
            long sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (sign > 0)
                {
                    if (sum >= 0)
                    {
                        ans1 += 1 + sum;
                        sum = -1;
                    }
                }
                else
                {
                    if (sum <= 0)
                    {
                        ans1 += 1  -sum;
                        sum = 1;
                    }
                }
                sign *= -1;
            }

            sign = -1;
            sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (sign > 0)
                {
                    if (sum >= 0)
                    {
                        ans2 += 1 + sum;
                        sum = -1;
                    }
                }
                else
                {
                    if (sum <= 0)
                    {
                        ans2 += 1 - sum;
                        sum = 1;
                    }
                }
                sign *= -1;
            }

            Console.WriteLine(Math.Min(ans1, ans2));
        }
    }
}


Measured memory_bytes: 29276
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a;
	int x;
	scanf("%d", &x);
	a.push_back(x);
	int cnt = 0;
	for (int i = 2; i <= n; ++ i) {
		int x;
		scanf("%d", &x);
		if (x == a.back()) continue;
		if ((int) a.size() == 1) {
			a.push_back(x);
		}
		else {
			if ((a[0] < a[1]) == (a.back() < x)) a.push_back(x); else {
				a.clear();
				a.push_back(x);
				cnt ++;
			}
		}
	}
	cnt ++;
	printf("%d\n", cnt);
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,x[100],y[100],h[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int a = 0;
            for(int k=0;k<n;k++){
                if(h[k]>0){
                    a = h[k]+abs(x[k]-i)+abs(y[k]-j);
                    k=n;
                }
            }
            
            for(int k=0;k<n;k++){
                int d = abs(x[k]-i)+abs(y[k]-j);
                if(h[k]>0){
                    if(a!=h[k]+d){
                        //cout<<"OUT"<<endl;//
                        a=0;
                        k=n;
                    }
                }else{
                    if(a>d){
                        //cout<<"OUT"<<endl;//
                        a=0;
                        k=n;
                    }
                }
            }
            if(a>0){
                cout<<i<<" "<<j<<" "<<a<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	string t = s;
	reverse(s.begin(), s.end());
	int cnt = 0;
	if (s.size() % 2 == 0) {
		rep(i, s.size()/2) {
			if (s[i] != t[i]) {
				cnt++;
			}
		}
	}
	else {
		rep(i, (s.size()-1 )/ 2) {
			if (s[i] != t[i]) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    int tmp = distance(a.begin(), lower_bound(all(a), x));
    int y = m - tmp;
    cout << min(tmp, y) << endl;
}
int main(void)
{
    solve();
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

int main() {   
    Int n, k, s;
    cin >> n >> k >> s;
    for (Int i = 0; i < k; i++) {
        cout << s << " ";
    }
    Int x = 1e9;
    if (s == x) x--;
    for (Int i = k; i < n; i++) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll t,s;
    string str;
    cin>>d>>t>>s;
    if(d<=t*s) Yes;
    else No;


    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void){
int a, b, c;
 
scanf("%d %d %d", &a, &b, &c);
 
  if(a+b+c==17 && a*b*c==175){
      puts("YES");
  }
  else{
      puts("NO");
}
 
return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
"""
int #整数
float #小数

#標準入力
a=input()
a,b=map(int,input().split()) #入力は行ごと
#標準出力
print(a)
ptrint("Hello")
#for
for name in fruits: #fruitの頭から操作
    print(name)
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト内の2の数
abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値

extension_1 = []
for i in range(10):
    extension_1.append(i)
extension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

comprehension_1= [i for i in range(10)]
comprehension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
"""
a,b,c = map(int,input().split())
if a==b+c or b==a+c or c==a+b:
    print("Yes")
else:
    print("No")
    

     

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

int main(){
    ll n;
    cin >> n;
    auto _max = p<>(0,0);
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        if(_max.first<a){
            _max.first = a;
            _max.second = b;
        }
    }
    cout << _max.first + _max.second <<endl;    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;

void Main() {
  int n,m;
  while(cin >> n >> m && n) {
    vector<P> v[n];
    rep(i,m) {
      int x,y,z;
      cin >> x >> y >> z;
      x--,y--;
      v[x].pb(P(y,z));
      v[y].pb(P(x,z));
    }
    int d[n][3];
    rep(i,n)rep(j,3)d[i][j]=MAX;
    d[0][2]=0;
    priority_queue<PP,vector<PP>,greater<PP> > que;
    que.push(PP(0,P(0,2)));
    while(!que.empty()) {
      PP p=que.top();que.pop();
      int x=p.S.F,k=p.S.S,c=p.F;
      if(d[x][k]<c) continue;
      rep(i,v[x].size()) {
        int y=v[x][i].F;
        if(k) {
          if(d[y][k-1]>c) {
            d[y][k-1]=c;
            que.push(PP(d[y][k-1],P(y,k-1)));
          }
        }
        if(k!=1) {
          if(d[y][k]>c+v[x][i].S) {
            d[y][k]=c+v[x][i].S;
            que.push(PP(d[y][k],P(y,k)));
          }
        }
      }
    }
    pr(d[n-1][0]);
  }
}

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


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

int main() {
	//入力.
	int d, l;
	cin >> d >> l;
	//ジャンプ数を算出.
	int ans = d / l;
	d -= l * ans;
	//大ジャンプをできるだけしたとき、ちょうど巣穴にいればもう小ジャンプをしなくてもいい.
	if (d == 0) cout << ans << endl;
	else {
		//巣穴からの距離分だけ小ジャンプすればいい.
		ans += d;
		cout << ans << endl;
	}
	return 0;
	//↑上の1文はなくてもいい.
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int sum(int x) {
	if (x == 100000) {
		return  sum(99999);
	}
	else if (x>=10000) {
		return  (x-9999)+sum(9999);
	}
	else if (x >= 1000) {
		return sum(999);
	}
	else if (x >= 100) {
		return (x - 99)+9;
	}
	else if (x >= 10) {
		return 9;
	}
	else {
		return x;
	}
}

int main()
{
	int N;
	cin >> N;
	ce(sum(N))

    return 0;
}



Measured memory_bytes: 256
k,n = list(map(int, input().split(' ')))
places = list(map(int, input().split(' ')))
dists = []

sum = 0
max = 0
for i in range(n):
  if i < (n - 1):
  	tmp = places[i+1]-places[i]
  else:
    tmp = k - places[i] + places[0]
  dists.append(tmp)
  sum += tmp
  if max < tmp:
    max = tmp
print (sum - max)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vei a(N); rep(i,N) {cin >> a[i]; a[i]--;}

    int ans = 0;
    rep(i,N) {
        if(i < a[i] and a[ a[i] ] == i) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<string>

using namespace std;

string alpha="abcdefghijklmnopqrstuvwxyz";

int main(){
    int n;
    string s[51];
    map<char, int> m;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<26;i++){
        m[alpha[i]]=10000;
    }
    for(int i=0;i<n;i++){
        map<char, int> tmpm;
        for(int j=0;j<26;j++){
            tmpm[alpha[j]] = 0;
        }
        for(int j=0;j<s[i].length();j++){
            tmpm[s[i][j]]++;
        }
        for(int j=0;j<26;j++){
            m[alpha[j]] = min(m[alpha[j]], tmpm[alpha[j]]);
        }
    }
    for(int i=0;i<26;i++){
        while(m[alpha[i]]>0){
            cout << alpha[i];
            m[alpha[i]]--;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
  int key;
  struct Node *right, *left, *parent;
}Node;

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    
    scanf("%s",com);
    
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
import math
import sys
import os
# import numpy as np

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
MOD = 998244353    

# もらうDP, 区間の和を足しこむ
N,K = LI()
LRs = [LI() for _ in range(K)]

# S = set()
# for LR in LRs:
#     for i in range(LR[0],LR[1]+1):
#         S.add(i)

# cell = [0]*(N)
# cell[0] = 1

# Sa = sorted(list(S),reverse=True)
# for i in range(N):
#     for s in S:
#         if i+s<N:
#             cell[i+s]+=cell[i]

dp = [0]*(N+1)
# 組み合わせの数の累積和(区間和を足しこむため)
cum = [0]*(N+1)
dp[1] = 1
cum[1] = 1
for i in range(2, N+1):
    for j in range(K):
        l, r = LRs[j]
        start = max(0,i-r-1)
        end = max(0,i-l)
        # print('l,r: ',l,r)
        # print('start,end', start,end)
        dp[i] += cum[end] - cum[start]
        # dp[i] += cum[i-l]
        # if i - l >= 0:
        #     dp[i] += cum[i-l]
        # if i - (r+1) >= 0:
        #     dp[i] -= cum[i-(r+1)]
    # dp[i] = (dp[i] % MOD + MOD) % MOD
    dp[i] %= MOD
    # 累積和を更新
    cum[i] = (cum[i-1] + dp[i]) % MOD
print(dp[N])

# for s in Sa:
#     i = 0
#     while i+s<N:
#         # print(i,s)
#         cell[i+s] += cell[i]
#         i += 1
#     print(s,cell)
# ans = cell[-1]
# print(ans)

Measured memory_bytes: 24656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define er(n) cout << "error " << n << endl;
#define pbds tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007

void Abhay() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	//Abhay();
	int n; cin >> n;
	int a[n];
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i];
	}
	int dp[n];
	dp[0] = 0, dp[1] = abs(a[0] - a[1]);
	for (int i = 2 ; i < n ; i++) {
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		dp[i] = min(dp[i], abs(dp[i - 2] + abs(a[i] - a[i - 2])));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    int n, k, x, y, sum;
    cin >> n >> k >> x >> y;

    if (n < k) {
        sum = n * x;
    } else {
        sum = k * x + (n-k)*y;
    }

    cout << sum << endl;
}


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

int N;
int A[200005];
long long ans;

int main(){
	cin>>N;

	for(int i=0; i<N; i++){
		cin>>A[i];
	}
	
	long long mn=1LL*A[0];
	for(int i=1; i<N; i++){
		if(A[i]<mn){
			ans += mn - 1LL*A[i];
		}else{
			mn = 1LL*A[i];
		}
	}	
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,d;
  cin>>n>>d;
  int a[n][d];int c=0;
  for(int i=0;i<n;i++)
  {
  for(int j=0;j<d;j++)
  {cin>>a[i][j];}}int sum=0;
  int i=0;
  int k=i+1;
  while(i<n)
  {while(k<n)
  { for(int j=0;j<d;j++)
  {sum=sum+((a[k][j]-a[i][j])*(a[k][j]-a[i][j]));}float m=sqrt(sum);
  if(m==int(sqrt(sum)))
    c++;
  k++;sum=0;}i++;k=i+1;}
  cout<<c;
}

Measured memory_bytes: 256
package main

import "fmt"

const INF int64 = 100000000007

func digit_sum(x, b int64) int64 {
    if b <= 1 {
        return 0
    }
    ret := int64(0)
    for x > 0 {
        ret += x % b
        x /= b
    }
    return ret
}

func solve(n, s int64) int64 {
    if s > n {
        return -1
    }
    if s == n {
        return n + 1
    }
    for b := int64(2); b * b <= n; b++ {
        if digit_sum(n, b) == s {
            return b
        }
    }
    var ret int64 = INF
    for p := int64(1); p * p < n; p++ {
        b := (n - s) / p + 1
        if digit_sum(n, b) == s {
            if ret > b {
                ret = b
            }
        }
    }
    if ret < INF {
        return ret
    }
    return -1
}

func main() {
    var n, s int64
    fmt.Scan(&n, &s)
    fmt.Println(solve(n, s))
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>

using namespace std;
bool visit[100001]={};
long dis[100001];
vector<vector<int>> vec1(100001);
vector<vector<long>> vec2(100001);

int dfs(int x){
  int i;
  visit[x]=true;
  for(i=0;i<vec1[x].size();i++){
    if(visit[vec1[x][i]]==false){
      dis[vec1[x][i]]=dis[x]+vec2[x][i];
      dfs(vec1[x][i]);
    }
  }
}

int main(){
  int n,a,b,q,k,x,y,i;
  long c;

  cin >> n;
  for(i=0;i<n-1;i++){
    cin>>a>>b>>c;
    vec1[a].push_back(b);
    vec1[b].push_back(a);
    vec2[a].push_back(c);
    vec2[b].push_back(c);
  }
  cin>>q>>k;
  dis[k]=0;
  dfs(k);
  for(i=0;i<q;i++){
    cin>>x>>y;
    cout<<dis[x]+dis[y]<<endl;
  }
}

Measured memory_bytes: 16768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long MOD = 1000000007;

int main()
{
  int A, B, C;
  std::cin >> A >> B >> C;
  if (A == B && B == C)
    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 main(){
	int n, r[200100], maxv = -1000000000;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>r[i];
	}
	int minv = r[0];
	for(int j = 1; j < n; j++){
		if(r[j] - minv > maxv) maxv = r[j] - minv;
		if(r[j] < minv) minv = r[j];
	}
	cout<<maxv<<endl;
	return 0;
}


Measured memory_bytes: 3884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int max = -200, min = 200;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, sc.nextInt());
		}
		for (int i = 0; i < m; i++) {
			min = Math.min(min, sc.nextInt());
		}

		for (int i = x + 1; i <= y; i++) {
			if (max < i && min >= i) {
				System.out.println("No War");
				return;
			}
		}

		System.out.println("War");

	}

}


Measured memory_bytes: 23380
n=int(input())
name={}
name["M"]=0
name["A"]=0
name["R"]=0
name["C"]=0
name["H"]=0
for _ in range(n):
    s=list(input())
    if s[0] not in name:
        name[s[0]]=1
    else:
        name[s[0]]+=1
cnt=[name["M"],name["A"],name["R"],name["C"],name["H"]]
ans=0
n=5
for i in range(n-2):
    for j in range(n-i-2):
        j+=i+1
        for k in range(n-j-1):
            k+=j+1
            ans+=cnt[i]*cnt[j]*cnt[k]
print(ans)





Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int h,w,k;cin>>h>>w>>k;
    char s[h][w];REP(i,h)REP(j,w)cin>>s[i][j];
    vector<vector<int> >ans(h,vector<int>(w));
    int mark=1;
    bool flag=0;
    int st;
    REP(i,h){
        if(flag)mark++;
        int c1=0,c2=0;
        REP(j,w)if(s[i][j]=='#')c1++;
        if(c1!=0&&!flag){flag=1;st=i;}
        if(c1==0&&flag){REP(j,w)ans[i][j]=ans[i-1][j];mark--;}
        else REP(j,w){
            ans[i][j]=mark;
            if(s[i][j]=='#'&&c2!=c1-1){mark++;c2++;}
        }
    }
    for(int i=st;i>0;i--)REP(j,w)ans[i-1][j]=ans[i][j];
    REP(i,h){REP(j,w)cout<<ans[i][j]<<' ';cout<<endl;}
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1280
s = input()
s = s.replace("LR", "L R").split()

ans = []
for ss in s:
    a = b = 0
    c = d = 0
    for i in range(len(ss)):
        if ss[i] == 'R':
            a += 1
        else:
            b += 1

    if a % 2 == 0:
        c += a // 2
        d += a // 2
    else:
        c += (a + 1) // 2
        d += (a - 1) // 2

    if b % 2 == 0:
        c += b // 2
        d += b // 2
    else:
        c += (b - 1) // 2
        d += (b + 1) // 2

    ans += [0]*(a-1) + [c, d] + [0]*(b-1)

print(' '.join([str(ai) for ai in ans]))


Measured memory_bytes: 13728
#include <stdio.h>

int A[100000], n;
int search(int key){
  int l = 0;
  int r = n;
  int m;
  while (l < r) {
    m = (l + r) / 2 ;
    if (A[m] == key) {
      return 1;
    }
    else if (key > A[m]) {
      l = m + 1;
    }
    else if (key < A[m]) {
      r = m;
    }
  }
  return 0;
}

int main() {
  int i,q,key,cnt=0;

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

  scanf("%d",&q);
  for (i = 0; i < q; i++) {
    scanf("%d",&key);
    if (search(key)) {
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2096
line,col = map(int,input().split(" "))

list_col = [0 for i in range(col+1)]
for _ in range(line):
	#行ループ
	data = list(map(int,input().split(" ")))
	data.append(sum(data))

	str_data = list(map(str,data))
	print(" ".join(str_data))

	#列ループ
	for j in range(col+1):
		list_col[j] += data[j]

str_col = list(map(str,list_col))
print(" ".join(str_col))




Measured memory_bytes: 5620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] cost=new int[N];
		int[] vote=new int[N];
		Arrays.fill(cost, 0);
		Arrays.fill(vote, 0);
		for(int i=0; i<N; i++) {
			cost[i]=sc.nextInt();
		}
		for(int i=0; i<M; i++) {
			int b=sc.nextInt();
			for(int j=0; j<N; j++) {
				if(b>=cost[j]) {
					vote[j]++;
					break;
				}
			}
		}
		int maxindex=0;
		int maxnum=0;
		for(int i=0; i<N; i++) {
			if(maxnum<vote[i]) {
				maxnum=vote[i];
				maxindex=i;
			}
		}
		pl(maxindex+1);
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 25512
import java.util.*;

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


Measured memory_bytes: 35704
#include <stdio.h>


int num[100]={0};

int data=0;

int max=0;

int i=0;




int main(void){

	
	while((scanf("%d", &data))!=EOF){

		num[data]++;

		if(max<num[data])
			max=num[data];
						}

	for(i=0;i<100;i++){
		if(num[i]==max)
			printf("%d\n",i);
				}




	return 0;

}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Mysterious Dungeons
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
		for(;;){
			int w = sc.nextInt(), h = sc.nextInt();
			if((w|h)==0)break;
			char[][] m = new char[h][];
			int si = 0, sj = 0, gi = 0, gj = 0;
			boolean[] u = new boolean[26];
			for(int i=0;i<h;i++){
				m[i]=sc.next().toCharArray();
				for(int j=0;j<w;j++){
					if(m[i][j]=='@'){
						si = i; sj = j; m[i][j] = '.';
					}
					if(m[i][j]=='<'){
						gi = i; gj = j; m[i][j] = '.';
					}
					if(Character.isUpperCase(m[i][j]))u[m[i][j]-'A']=true;
				}
			}
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(Character.isLowerCase(m[i][j])&&!u[m[i][j]-'a'])m[i][j]='.';
			int id = 0;
			int[] b = new int[26];
			for(int i=0;i<26;i++)if(u[i])b[i]=id++;
			boolean[][][] v = new boolean[h][w][256];
			int step = 0, res = -1;
			List<int[]> l = new ArrayList<int[]>();
			l.add(new int[]{si, sj, 0});
			v[si][sj][0] = true;
			while(!l.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int[]a:l){
					int i = a[0], j = a[1], s = a[2];
					if(i==gi&&j==gj){
						res = step; next.clear(); break;
					}
					for(int k=0;k<4;k++){
						int ni = i+d[k][0], nj = j+d[k][1], ns = s;
						if(m[ni][nj]=='#')continue;
						if(Character.isUpperCase(m[ni][nj])){
							if(((s>>b[m[ni][nj]-'A'])&1)==0)continue;
						}
						else if(Character.isLowerCase(m[ni][nj])){
							if(((s>>b[m[ni][nj]-'a'])&1)==0)ns+=1<<b[m[ni][nj]-'a'];
							else ns-=1<<b[m[ni][nj]-'a'];
						}
						if(!v[ni][nj][ns]){
							v[ni][nj][ns] = true; next.add(new int[]{ni, nj, ns});
						}
					}
				}
				step++;
				l = next;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 998244353;

// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    mint tmp = m, ans = 0;
    combination c(n-1);
    repr(i, n) {
        if (i <= k) ans += tmp * c(n-1, i);
        tmp *= m - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6364