akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int cnt[100010];

void solve() {
    int n,k,q;
    cin >> n >> k >> q;
    REP(i,q) {
        int kk;
        cin >> kk;
        cnt[kk-1]++;
    }
    REP(i,n) {
        cout << (k - (q-cnt[i]) > 0?"Yes":"No") << endl;
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

const int MOD = 1000000007;
int64_t dp[1100][1100];

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    dp[0][0] = 1;
    rep(i,h) {
        rep(j,w) {
            if (f[i][j] == '#') continue;
            int rig = j+1;
            int dow = i+1;
            if (rig < w) dp[i][rig] += (dp[i][j]) % MOD;
            if (dow < h) dp[dow][j] += (dp[i][j]) % MOD;
        }
    }
    int64_t ans = dp[h-1][w-1] % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int A,B,C;

void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}

/*--- *n1≦*n2≦*n3となるように並べ替える ---*/
void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}
int cunt;
int main(){

    cin>>A>>B>>C;
    sort3(&C,&B,&A);
    while(1){
        if(A>=B+2){
            cunt++;    
            B+=2;
        }else
            break;
   }     
   while(1){
        if(A>=C+2){
            C+=2;
            cunt++;
        }else
            break;
    }
    sort3(&C,&B,&A);
    if(A==B&&B==C)
        cout<<cunt<<"\n";
    else if(A==B&&B>C)
        cout<<cunt+2<<"\n";
    else
        cout<<cunt+1<<"\n";
    return 0;    

}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A % 2 == 0 | B % 2 == 0 | C % 2 == 0) print(0);
    else {
        print(min (A*B, min(B*C, A*C)));
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
    	int b = sc.nextInt();
	    int c = sc.nextInt();
      	if(c>=a && c<=b){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35720
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*len(h)

for i in range(1,min(k,n)):
    temp=10**10
    for j in range(i):
        temp=min(temp,dp[j]+abs(h[i]-h[j]))
    dp[i]+=temp 
for p in range(min(k,n),n):
    temp=10**10
    for q in range(k):
        temp=min(temp,dp[p-k+q]+abs(h[p]-h[p-k+q]))
    dp[p]+=temp 
print(dp[-1])
               

Measured memory_bytes: 84744
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String h = sc.next();
        String n = sc.next();
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String u = sc.next();
        if(u.equals(h)){
            a--;
        }else{
            b--;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21844
#-*-coding:utf-8-*-

def main():
    #入力
    X = int(input())

    exp_list = [1]
    i = 2
    flag = 0

    while True:
        j = 2
        while True:
            if i ** j <= X:
                exp_list.append(i ** j)
                j += 1
            elif i ** 2 > X:
                flag = 1
                break
            else:
                break
        i += 1
        if flag == 1:
            break
    
    print(max(exp_list))

if __name__ == '__main__':
    main()

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

int main() {
    int n;
    int number;
    char type;
    bool cards[4][14];

    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 0; j < 14; j++ ) {
            cards[i][j] = false;
        }
    }

    cin >> n;

    for ( int i = 0; i < n; i++ ) {
        cin >> type >> number;
        if ( type == 'S' )      cards[0][number] = true;
        else if ( type == 'H' ) cards[1][number] = true;
        else if ( type == 'C' ) cards[2][number] = true;
        else if ( type == 'D' ) cards[3][number] = true;
    }

    // ??????
    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 1; j < 14; j++ ) {
            if (cards[i][j] == false) {
                if ( i == 0 ) cout << "S " << j << '\n';
                else if ( i == 1 ) cout << "H " << j << '\n';
                else if ( i == 2 ) cout << "C " << j << '\n';
                else if ( i == 3 ) cout << "D " << j << '\n';
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C, X);
  int ans = 0;
  rep(i, 0, A + 1) {
    rep(j, 0, B + 1) {
      int d = X - i * 500 - j * 100;
      if (d >= 0 && d % 50 == 0 && C >= d / 50) {
        ans++;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    string s; ll k;
    cin >> s >> k;
    int n = s.size();
    
    if(s.size()==1) {
        cout << k/2 << endl;
    } else {
        ll cnt = 1;
        for(int i=n-2; i>=0; i--) {
            if(s[i] == s[n-1]) cnt++;
            else break;
        }
        ll cnt2 = 1;
        for(int i=1; i<n; i++) {
            if(s[i] == s[0]) cnt2++;
            else break;
        }
        ll res = 0;
        for(int i=cnt2; i<s.size()-cnt; i++) {
            if(s[i] == s[i-1]) {
                res++;
                i++;
            }
        }
        if(cnt==n) {
            cout << (cnt * k) / 2 << endl;
            return 0;
        }
        if(s[n-1] == s[0]) {
            if(cnt2 & 1) {
                cout << res + cnt / 2 + (res + (cnt+cnt2) / 2) *(k-1) + cnt2/2 << endl;
            } else {
                cout << (res + cnt/2 + cnt2/2) * k << endl;
            }
        } else {
            cout << (res + cnt/2 + cnt2/2) * k << endl;
        }
    }
}


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

int main(){
  int N,D,T;
  cin>>N>>D>>T;
  vector<vector<int>> Gd(N);
  vector<vector<int>> Gt(N);
  for(int i=0;i<D;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    Gd[a].push_back(b);
    Gd[b].push_back(a);
  }
  for(int i=0;i<T;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    Gt[a].push_back(b);
    Gt[b].push_back(a);
  }
  vector<int> ans(N);
  vector<tuple<int,int,int>> p(N);
  vector<int> q(N);
  for(int i=0;i<N;i++){
    get<2>(p[i])=i;
    if(!get<0>(p[i])){
      queue<int> q;
      q.push(i);
      get<0>(p[i])=i+1;
      while(!q.empty()){
        int a=q.front();
        q.pop();
        for(int x:Gd[a]){
          if(!get<0>(p[x])){
            get<0>(p[x])=i+1;
            q.push(x);
          }
        }
      }
    }
  }
  for(int i=0;i<N;i++){
    if(!get<1>(p[i])){
      queue<int> q;
      q.push(i);
      get<1>(p[i])=i+1;
      while(!q.empty()){
        int a=q.front();
        q.pop();
        for(int x:Gt[a]){
          if(!get<1>(p[x])){
            get<1>(p[x])=i+1;
            q.push(x);
          }
        }
      }
    }
  }
  sort(p.begin(),p.end());
  int A=1;
  for(int i=0;i<N-1;i++){
    if(get<0>(p[i])==get<0>(p[i+1])&&get<1>(p[i])==get<1>(p[i+1])){
      A++;
    }
    else{
      q[i]=A;
      A=1;
    }
  }
  q[N-1]=A;
  for(int i=N-2;i>=0;i--){
    if(!q[i]&&q[i+1]){
      q[i]=q[i+1];
    }
  }
  for(int i=0;i<N;i++){
    ans[get<2>(p[i])]=q[i];
  }
  for(int i=0;i<N;i++){
    cout<<ans[i];
    if(i!=N-1){
      cout<<" ";
    }
    else{
      cout<<endl;
    }
  }
}

Measured memory_bytes: 22556
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int mn = 0;
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	int ans = 0;
	REP(i, N) {

		if (A[i] < mn) {
			ans += mn - A[i];
		}
		chmax(mn, A[i]);
	}
	print(ans);
}



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

}


Measured memory_bytes: 4728
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << "0\n";
  } else {
    cout << min({1LL * a * b, 1LL * b * c, 1LL * c * a}) << '\n';
  }
  return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = long.Parse(Console.ReadLine());
            var B = long.Parse(Console.ReadLine());
            var C = long.Parse(Console.ReadLine());
            var D = long.Parse(Console.ReadLine());
            var E = long.Parse(Console.ReadLine());
            var min = Math.Min(Math.Min(Math.Min(Math.Min(A, B), C), D), E);
            Console.WriteLine(4+((N%min==0)?N/min:N/min+1));
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

ll solve(int N, int A[300][300]) {
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            bool ok = true;
            for (int k = 0; k < N; k++) {
                if (i == k || j == k) continue;

                if (A[i][k] + A[k][j] < A[i][j]) {
                    return -1;
                }

                if (A[i][k] + A[k][j] == A[i][j]) {
                    ok = false;
                }
            }
            if (ok) ans += A[i][j];
        }
    }
    return ans;
}

int main(int argc, char **argv) {
    int N;
    int A[300][300];
    cin >> N;

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

    ll ans = solve(N, A);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n, vector<int>(0));
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      v[i].push_back(s);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int count = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    bool f = 1;
    int a[n] = {};
    int s[n] = {};
    for (int i = 0; i < n; i++) {
      if (bit & (1<<i)) {
        s[i] = 1;
      }
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < v[i].size(); j++) {
        int b = v[i][j];
        if (s[b] == 1) {
          a[i]++;
        }
      }
      a[i]%=2;
      if (a[i]!=p[i]) {
        f = 0;
        break;
      }
    }
    if (f) {
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
main = getContents >>= print . solve 0 0 1000000000 . map read . tail . words

solve cnt s m [] =
    if cnt `mod` 2 == 0 then s else s - 2 * m
solve cnt s m (a:as) =
    if a <= 0
    then solve (cnt + 1) (s - a) (min m (-a)) as
    else solve cnt (s + a) (min m a) as

Measured memory_bytes: 15740
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
typedef tuple<ll, ll, ll> T;


int main() {
	ll M;
 cin >> M;
	cout << 48 - M << endl;
	return 0;
}


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

typedef long long ll;

ll same[10][10];

int main() {
    ll n;
    ll ans = 0;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        ll l = i % 10;
        ll f = i;
        while (f >= 10) {
            f /= 10;
        }
        same[f][l]++;
    }

    for (int i = 1; i <= 9; i++) {
        ans = ans + same[i][i]*same[i][i];
    }

    for (int i = 1; i <= 9; i++) {
        for (int j = i+1; j <= 9; j++) {
            ans = ans + 2 * same[i][j]*same[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,f1[111111],f2[111111];
int d1[111111],d2[111111];
vector<int> v[111111];

signed main(){
	cin>>n;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<P> q1,q2;
	int cnt1=0,cnt2=0,colcnt1=0,colcnt2=0;
	q1.push(P(0,0));q2.push(P(n-1,0));
	
	f1[0]=1;f2[n-1]=1;
	int str1,str2;
	bool is_fen;
	while(q1.size()){
			P p1=q1.front();
			q1.pop();
			for(auto x:v[p1.first]){
				if(f1[x]!=1){
					q1.push(P(x,p1.second+1));
					d1[x]=p1.second+1;
					f1[x]=1;
				}
			}
	}
	while(q2.size()){
			P p2=q2.front();
			q2.pop();
			for(auto x:v[p2.first]){
				if(f2[x]!=1){
					q2.push(P(x,p2.second+1));
					d2[x]=p2.second+1;
					f2[x]=1;
				}
			}
	}
	/*int extra1=cnt1-colcnt1,extra2=cnt2-colcnt2;
	
	if(is_fen){
		if(extra1>extra2)cout<<"Fennec"<<endl;
		else cout<<"Snuke"<<endl;
	}
	else{
		if(extra2>extra1)cout<<"Snuke"<<endl;
		else cout<<"Fennec"<<endl;
	}*/
	rep(i,n){
		if(d1[i]<=d2[i])cnt1++;
		else cnt2++;
	}
	if(cnt1>cnt2)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	
	//cout<<cnt1<<" "<<cnt2<<endl;
	/*cout<<colcnt1<<" "<<colcnt2<<endl;
	cout<<str1<<" "<<str2<<endl;*/
}

Measured memory_bytes: 10112
#include <iostream>
#include <stdio.h>
#include<vector>
using namespace std;
#define pb(a) push_back(a)
int main(){
  int p,q,res;
  int a;
  while(cin >> p >> q){
    vector<int> v,s;
    v.pb(p);
    bool f=false,l=false;
    int c =0 ;
    int k=0;
    while(1){
      p*=10;
      s.pb(p/q);
      p%=q;
      if(p==0){
        f=true;
        break;
      }
      for(int i=0;i<v.size();i++) 
        if(v[i]==p){
          k=i;
          l=true;
          break;
        } 
      if(l) break;
      v.pb(p);
      c++;
    }
    double x= (double) p/q;
    if(f) {
      for(int i=0;i<s.size();i++) cout << s[i];
      cout << endl;
    }else{
      //printf("%0.lf\n",x);
      for(int i=0;i<s.size();i++) cout << s[i];
      cout << endl;
      for(int i=0;i<k;i++) cout << " ";
      for(int i=k;i<s.size();i++) cout << "^";
      cout << endl;
    }
    //cout << res << endl;
    //printf("%.79f\n",res);
  }
  return 0;
}

Measured memory_bytes: 1220
n = int(input())
a = [[tuple(map(int, input().split())) for i in range(int(input()))]
     for j in range(n)]

# bit全探索
res = 0
for bit in range(2**n):
    for i in range(n):
        if bit & (1 << i):
            for x, y in a[i]:
                if (bit >> x-1) & 1 != y:
                    break
            else:
                continue
            break
    else:
        res = max(res, bin(bit).count('1'))

print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace  std;
int primes[1000010];
bool isPrime(int p)
{
	bool flag = true;
	for (int i = 2; i * i <= p; i++)
	{
		if (p % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	for (int i = 0; i <= 999999; i++)primes[i] = 0;
	for (int i = 2; i <= 999999; i++)if (isPrime(i))primes[i] = 1;
	for (int i = 0; i <= 999999; i++)primes[i + 1] += primes[i];
	while (cin >> n)cout << primes[n] << endl;
	return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<ll> ans(n);
  ll c[2] = {-1, 1};

  rep(i, n) {
    queue<ll> q;
    vector<ll> dist(n, INF);
    dist[i] = 0;
    q.push(i);

    while(!q.empty()) {
      ll pos = q.front();
      q.pop();
      rep(i, 2) {
        ll next = pos + c[i];
        if (next == -1 || next == n) continue;
        if (dist[next] == INF) {
          dist[next] = dist[pos] + 1;
          ans[dist[next]]++;
          q.push(next);
        }
      }
      if (pos == x) {
        if (dist[y] == INF) {
          dist[y] = dist[pos] + 1;
          ans[dist[y]]++;
          q.push(y);
        }
      }
      if (pos == y) {
        if (dist[x] == INF) {
          dist[x] = dist[pos] + 1;
          ans[dist[x]]++;
          q.push(x);
        }
      }
    }
  }

  reps1(i, n) {
    cout << ans[i] / 2 << endl;
  }


  return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
coords = [list(map(int, input().split())) for _ in range(n)]

pic = [[1 for _ in range(w)] for _ in range(h)]

for x, y, a in coords:
    if a == 1:
        for row in pic:
            for i in range(x):
                row[i] = 0

    elif a == 2:
        for row in pic:
            for i in range(x, w):
                row[i] = 0

    elif a == 3:
        for i in range(y):
            for j in range(w):
                pic[i][j] = 0

    elif a == 4:
        for i in range(y, h):
            for j in range(w):
                pic[i][j] = 0
    

print(sum(sum(i) for i in pic))


Measured memory_bytes: 3188
import sys
import random
s = input()
t = input()
sl = len(s)
tl = len(t)

l = 0
r = 1500000//tl + 1
r2 = r
s *= 1499999//sl + 1
n = len(s)

base1 = 1007
mod1 = 10**9+7
modTank1 = [3000012541,3000012553,3000012563,3000012649,3000012683,3000012709]
mod1 = modTank1[random.randint(0,5)]
base1 = 1007
mod1 = 10**9+7
hash1 = [0]*(n+1)
power1 = [1]*(n+1)
for i,e in enumerate(s):
    hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
    power1[i+1] = (power1[i]*base1)%mod1

def rolling_hash(i, j):
    return (hash1[j]-hash1[i]*power1[j-i]%mod1)%mod1


while r - l > 1:
    m = l + (r-l)//2
    lt = len(t)*m
    hash2 = [0]*(lt+1)
    power2 = [1]*(lt+1)
    for i,e in enumerate(t*m):
        hash2[i+1] = (hash2[i]*base1 + ord(e))%mod1
        power2[i+1] = (power2[i]*base1)%mod1
    r_hash = hash2[-1]%mod1

    lt = len(t)*m
    flag = 0
    for i in range(len(s)-lt+1):
        if r_hash == rolling_hash(i, i+lt):
            flag = 1
            break

    if flag == 1:
        l = m
    else:
        r = m

if l*tl >= 1000000:
    print(-1)
else:
    print(l)


Measured memory_bytes: 172792
arr = gets.chomp.split('')
prev = arr[0]
index = 0
list = []
(1..arr.count).each do |i|
  if i < arr.count
    if prev + arr[i] == '><'
      list << arr.slice(index...i)
      index = i
    end
    prev = arr[i]
  else
    list << arr.slice(index...i)
  end
end
sum = 0
list.each do |i|
  l = i.count('<')
  r = i.count - l
  tmp = (l + 1) * l / 2
  tmp += (r + 1) * r / 2
  tmp -= [l, r].min
  sum += tmp
end
puts sum

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

void dfs(const vector<int> &c, vector<vector<int>> &best, vector<int> &part, int n, int index) {
  if (index == c.size()) {
    for (int i = 0; i < part.size(); i++) {
      n -= part.at(i) * c.at(i + 1);
    }
    if (n < 0 or n % c.at(0) != 0) return;
    best.push_back(part);
    return;
  }
  for (int i = 0; i < c.at(0); i++) {
    part.push_back(i);
    dfs(c, best, part, n, index + 1);
    part.pop_back();
  }
}

int main() {
  const vector<int> k = {6,2,5,5,4,5,6,3,7,6};
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  vector<int> s(8, -1);
  for (int i = 0; i < m; i++) {
    s.at(k.at(a.at(i))) = max(s.at(k.at(a.at(i))), a.at(i));
  }
  vector<int> c;
  for (int i = 0; i < 8; i++) {
    if (s.at(i) != -1) {
      c.push_back(i);
    }
  }
  vector<vector<int>> best;
  vector<int> part;
  dfs(c, best, part, n, 1);
  int ms = 0;
  for (int i = 0; i < best.size(); i++) {
    int cache = 0, rest = n;
    for (int j = 0; j < best.at(i).size(); j++) {
      cache += best.at(i).at(j);
      rest -= best.at(i).at(j) * c.at(j + 1);
    }
    ms = max(ms, cache + rest / c.at(0));
  }
  vector<int> b(10);
  for (int i = 0; i < best.size(); i++) {
    int cache = 0, rest = n;
    for (int j = 0; j < best.at(i).size(); j++) {
      cache += best.at(i).at(j);
      rest -= best.at(i).at(j) * c.at(j + 1);
    }
    if (cache + rest / c.at(0) < ms) continue;
    vector<int> p(10);
    for (int j = 0; j < best.at(i).size(); j++) {
      p.at(s.at(c.at(j + 1))) = best.at(i).at(j);
    }
    p.at(s.at(c.at(0))) = rest / c.at(0);
    reverse(p.begin(), p.end());
    if (b < p) b = p;
  }
  for (int i = 9; i > 0; i--) {
    for (int j = 0; j < b.at(9 - i); j++) {
      cout << i;
    }
  }
  cout << endl;
}


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

int main(){
    int N,M;
    int X[110000];
    cin >> N >> M;
    for(int i=0;i<M;++i) cin >> X[i];

    if(N >= M){
        cout << "0" << endl;
        return 0;
    }

    sort(X,X+M);
    int diff[110000];
    for(int i=0;i<M-1;++i){
        diff[i] = X[i+1] - X[i];
    }

    sort(diff,diff+M-1);
    int sum = 0;
    for(int i=0;i<M-N;++i){
        sum += diff[i];
    }

    cout << sum << endl;
    return 0;
    

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
#include <cassert>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

vector<string> split(const string& s, char c = '/'){
	vector<string> ret;
	string t;
	stringstream ss(s);
	while(getline(ss, t, c)) ret.pb(t);
	return ret;
}

int main(){
	string s;
	while(cin>>s && s!="#"){
		vector<string> t = split(s);
		vector<string> v(t.size());
		for(int i = 0; i < t.size(); i++){
			int cnt = 0;
			for(int j = 0; j < t[i].size(); j++){
				if(t[i][j] >= '0' && t[i][j] <= '9') (cnt *= 10)+=(t[i][j]-'0');
				else{
					if(cnt != 0) v[i] += string(cnt,'.');
					v[i] += 'b';
					cnt = 0;
				}
			}
			if(cnt != 0)v[i] += string(cnt, '.');
		}
		int a, b, c,d;
		cin>>a>>b>>c>>d;
		a--; b--; c--; d--;
		// cout<<endl;
		// for(int i = 0; i < v.size(); i++){
		// 	cout<<v[i]<<endl;
		// }
		assert(v[a][b]=='b');
		v[a][b] = '.';
		v[c][d] = 'b';
		string ans;
		for(int i = 0; i < v.size(); i++){
			int cnt = 0;
			for(int j = 0; j < v[i].size(); j++){
				if(v[i][j] == 'b'){
					if(cnt != 0) ans += ('0'+cnt);
					ans += 'b';
					cnt = 0;
				}
				else cnt++;
			}
			if(cnt != 0) ans += ('0'+cnt);
			if(i + 1 != v.size()) ans += '/';
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 3212
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto &x : a)
        cin >> x;

    sort(all(a), greater<int>());
    ll ans = a[0];
    int j = 1;
    n-=2;
    while (n) {
        ans += a[j];
        n--;
        if (!n)
            break;
        ans += a[j];
        j++;
        n--;
    }
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3984
#include <iostream>

using namespace std;

#define int long long

int a[20005];
int dp[20005];

signed main()
{
    int N, M, K; cin >> N >> M >> K;

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        dp[i + 1] = 3e18;
    }

    for (int i = 0; i < N; ++i) {
        int mi = 1e9, ma = -1e9;

        for (int j = 0; j < M; ++j) {
            if (i + j >= N) continue;

            mi = min(mi, a[i + j]);
            ma = max(ma, a[i + j]);

            dp[i + j + 1] = min(dp[i + j + 1], dp[i] + (j + 1) * (ma - mi) + K);
        }
    }

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

Measured memory_bytes: 3316
#include <cstdio>
#pragma GCC optimize("Ofast")
#define rep(i,n)for(int i=0;i<(int)(n);i++)
int main(){
    int n,m,x,c[12]={},a[12][12]={},y,z[12],b,d=2e9;
    scanf("%d%d%d",&n,&m,&x);
    rep(i,n){
    scanf("%d",&c[i]);
        rep(j,m){
            scanf("%d",&a[i][j]);
        }
    }
    rep(i,2){rep(j,2){rep(k,2){rep(l,2){rep(o,2){rep(p,2){rep(q,2){rep(r,2){rep(s,2){rep(t,2){rep(u,2){rep(v,2){
        y=i*c[0]+j*c[1]+k*c[2]+l*c[3]+o*c[4]+p*c[5]+q*c[6]+r*c[7]+s*c[8]+t*c[9]+u*c[10]+v*c[11];
        for(b=0;b<m;b++){
            z[b]=i*a[0][b]+j*a[1][b]+k*a[2][b]+l*a[3][b]+o*a[4][b]+p*a[5][b]+q*a[6][b]+r*a[7][b]+s*a[8][b]+t*a[9][b]+u*a[10][b]+v*a[11][b];
            if(z[b]<x)break;
        }
        if(b==m&&y<d)d = y;
    }}}}}}}}}}}}
    if(d==(int)2e9)printf("-1");
    else printf("%d",d);
    return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 string s;int n, a=0,w=0,t=0;
 cin>>n;
 rep(i, n) {
   cin>>s;
   if(s[0] == 'A') a++;
   if(s[0] == 'W') w++;
   if(s[0] == 'T') t++;
 }

 cout << "AC x " << a << endl;
 cout << "WA x " << w << endl;
 cout << "TLE x " << t << endl;
 cout << "RE x " << n-a-w-t << endl;

 return 0;
}


Measured memory_bytes: 3660
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		int n = h[0], k = h[1];
		var rsp = read();
		var t = Console.ReadLine();
		var win = "spr";

		var r = 0;
		var u = new char[n];
		for (int i = 0; i < n; i++)
		{
			if (i >= k && u[i - k] == t[i])
			{
				u[i] = '?';
			}
			else
			{
				r += rsp[win.IndexOf(t[i])];
				u[i] = t[i];
			}
		}
		Console.WriteLine(r);
	}
}


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

int main(){
    int n;
    cin >> n;

    int a[n];
    map<int, int> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        auto itr = m.find(a[i]);

        if(itr == m.end()){
            m[a[i]] = 1;
        }else{
            m[a[i]]++;
        }
    }

    int k = 0;
    int cou = 0;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        if(itr->second != 1){
            if(itr->second % 2 == 1){
                int t = itr->second / 2;
                k += t * 2;
                itr->second = 1;
            }else{
                int t = itr->second / 2;
                t--;
                k += t * 2;
                if(cou == 0){
                    cou++;
                }else{
                    cou = 0;
                    k += 2;
                }
            }
        }
    }

    if(cou != 0){
        k += 2;
    }

    cout << n - k << endl;
}

Measured memory_bytes: 8712
fun main(args: Array<String>) {
    val n = readLine()!!

    println(op141a(n))
}

fun op141a(n: String): String {
    val weather = mutableListOf("Sunny","Cloudy","Rainy")
    val index = if (weather.indexOf(n) == weather.size -1) 0 else weather.indexOf(n) + 1
    return weather[index]
}





Measured memory_bytes: 33372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (isPalindrome(i)) {
                count++;
            }
        }
        System.out.println(count);
    }

    boolean isPalindrome(int n) {
        char[] cs = String.valueOf(n).toCharArray();
        for (int i = 0; i < cs.length / 2; i++) {
            if (cs[i] != cs[cs.length - i - 1]) {
                return false;
            }
        }
        return true;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 30164
#include<stdio.h>

float abs(float x){
  
  if(x<0) return -x;
  else return x;
  
}

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

   
  float ave=sum/(float)(N);
  float min=1000.0;
  int ans;
  float d;
  
  for(i=0;i<N;i++){
    
    d=abs(a[i]-ave);
    
    if(d<min){
      
      min=d;
      
      ans=i;
    }

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

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
map<string,int> tmp;
//int cc=0;
//#define edg(a,b) ((abs((a)-(b))==1))
int ask(string s)
{
	int r=0;
	for(int i=0;i<s.size();i++) r+=(s[i]=='1');
	if(r<=1) return 0;
	if(tmp.count(s)) return tmp[s];
	/*
	++cc; vi rp;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1') rp.pb(i);
	if(rp.size()==2)
	return tmp[s]=edg(rp[0],rp[1]);
	if(rp.size()!=3) throw "RE";
	bool a=edg(rp[0],rp[1]),b=edg(rp[0],rp[2]),
	c=edg(rp[1],rp[2]);
	return tmp[s]=a+b+c;*/
	cout<<"? "<<s<<endl;
	int x; cin>>x; return tmp[s]=x;
}
int n,ff[SZ]; vector<int> vs[SZ],rs;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{int ga=gf(a),gb=gf(b);if(ga^gb)ff[ga]=gb;}
int cnt()
{
	int ans=0; rs.clear();
	for(int i=1;i<=n;i++) vs[i].clear();
	for(int i=1;i<=n;i++)
	{
		vs[gf(i)].pb(i);
		if(gf(i)==i);else continue;
		++ans; rs.pb(i);
	}
	random_shuffle(rs.begin(),rs.end());
	for(int i=1;i<=n;i++)
		random_shuffle(vs[i].begin(),vs[i].end());
	return ans;
}
const int B=6;
vector<pii> es;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) vs[i].pb(i);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<i;j+=B)
		{
			string s; s.resize(n);
			for(int i=0;i<n;i++) s[i]='0';
			for(int k=0;k<B&&j+k<i;++k) s[j+k-1]='1';
			int a=ask(s); s[i-1]='1';
			int b=ask(s);
			if(a==b) continue;
			for(int k=0;k<B&&j+k<i;++k)
			{
				for(int i=0;i<n;i++) s[i]='0';
				s[j+k-1]=s[i-1]='1';
				if(ask(s)==1)
					es.pb(pii(j+k,i));
			}
		}
	}
	cout<<"!";
	for(auto r:es) printf(" (%d,%d)",r.fi-1,r.se-1);
	puts("");
	//cerr<<cc<<"\n";
}


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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second
const int MAXN = 100005;
int t[MAXN], x[MAXN], y[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    cin >> n;
    t[0] = 0, x[0] = 0, y[0] = 0;
    for (int i=1;i<=n;i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    for (int i=1;i<=n;i++)
    {
        int tt = t[i] - t[i-1];
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (tt < dist)
        {
            cout << "No" << endl;
            return 0;
        }

        if ((tt & 1) != (dist & 1))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] arg)throws IOException{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 //br.readline(); = 入力された１行分を日本語変換して返してくれる。
		 String str = br.readLine();

		 //おなじみの文字列から数値への変換。
		 int S =  Integer.parseInt(str);

		 //h = hour(○時間に直す)
		 int h = S/3600;

		 //m = minutes（○時間分を引いてから○分に直す）
		 int m = (S-h*3600)/60;

		 //s = second （○時間、○分を引く）
		 int s = S-h*3600-m*60;

		 /*いつも通りの出力。面積と周の長さを表示してる。
		 今回は/h、m、s を :（コロン）区切りで１行に出力してください。
		 数値が１桁の場合、0 を付けて２桁表示をする必要はなしとのことなのでこのような具合に。*/
		 System.out.println(h + ":" +m + ":" +s);
    }
}

Measured memory_bytes: 17024
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < (N); ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;

LL A[3];
int main(){
    RIII(A[0],A[1],A[2]);
    sort(A,A+3);
    printf("%lld",A[0]+A[1]);
    
    
}

Measured memory_bytes: 256
while True:
    n,m=map(int,input().split())
    if(n == 0 and m == 0):
        break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if(i+j+k == m):
                    ans=ans+1
    print(ans)


Measured memory_bytes: 5592
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, K;
  string s;
  cin >> N >> K;
  cin >> s;
  ll res = 0;
  ll num_zero = 0;
  ll prev_zero = 0;
  ll i = 0;
  ll prev_one = 0;
  if (s[0] == '0')
    num_zero++;
  for (auto i = 1; i < N; i++)
  {
    res = max(res, i - prev_one);
    if (s[i] == '0' && s[i-1] == '1')
      {
        num_zero++;
        if (num_zero > K)
        {
          // cout << "i==" << i
          //      << " prev_one=" << prev_one
          //      << endl;
          for (; prev_one < N && s[prev_one] == '1'; prev_one++)
            ;
          for (; prev_one < N && s[prev_one] == '0'; prev_one++)
            ;
        }
      }
    }
  res = max(res, N - prev_one);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int A,B;
	int pay;
	scanf("%d %d",&A,&B);
	if(A>=13){
    	pay=B;
    }else if(A<=5){
    	pay=0;
    }else{
    	pay=B/2;
    }
	printf("%d",(int)pay);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = sorted(list(map(int, input().split())))

from collections import Counter
c = Counter(A)
w = 0
h = 0
for k, v in sorted(c.items(), key=lambda x: -x[0]):
    if v < 2:
        continue
    if v >= 4:
        if w == 0:
            w = h = k
            break
        else:
            h = k
            break
    elif v >= 2:
        if w == 0:
            w = k
        elif h == 0:
            h = k
            break
print(w*h)

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

void main_()
{
    ll N, T;
    vector<ll> ts;
    cin >> N >> T;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(ts));

    // tsはソート済み
    ll ans = 0;
    for (auto start_it = begin(ts); start_it != end(ts);) {
        auto overrap_it = lower_bound(start_it, end(ts), *start_it + T) - 1;
        if (overrap_it == start_it) {
            ans += T;
            start_it++;
        } else {
            ans += *overrap_it - *start_it;
            start_it = overrap_it;
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2420