akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;
    cin>>n;
    ll res = 1;
    for(int i=1; i<=n; ++i)
    {
    	res = (res*i)%MOD;
    }
    cout<<res<<"\n";
 	   
}

Measured memory_bytes: 7296
read = input
n = int(read())
ans = 0
B = 0
A = 0
BA = 0
for i in range(n):
    s = read()
    ans += s.count("AB")
    if s[0] == 'B' and s[-1] == 'A': BA += 1
    elif s[0] == 'B':B += 1
    elif s[-1] == 'A':A += 1
#关键在于分类，选分类选取BA，因为A，B是对称的
if BA == 0:
    ans += min(A,B)
else  :
    if A + B == 0:
        ans += BA - 1
    else :
        ans += BA + min(A,B)
print(ans)

Measured memory_bytes: 3064
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val S = in.next
  def isPalindrome(s: String) = s.reverse.zip(s).forall{case (l, r) => l == r}
  val result = isPalindrome(S) && isPalindrome(S.substring(0, (S.size - 1) / 2))
  println(if (result) "Yes" else "No")
}

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

int n, sz[100010];
long long d[100010];
map<long long, int> mp;
vector<int> e[100010];

long long dfs(int x, int f)
{
    long long ans = 0;
    for (int y : e[x])
    {
        if (y == f) continue;
        ans += dfs(y, x) + sz[y];
    }
    return ans;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &d[i]);
        mp[d[i]] = i;
        sz[i] = 1;
    }
    for (int i = 1; i < n; i++)
    {
        auto it = mp.rbegin();
        long long hh = it->first + 2 * sz[it->second] - n;
        // printf("%d %d\n", mp[hh], it->second);
        if (!mp.count(hh) || hh == it->first)
        {
            puts("-1");
            return 0;
        }
        // ans.emplace_back(mp[hh], it->second);
        e[mp[hh]].push_back(it->second);
        e[it->second].push_back(mp[hh]);
        sz[mp[hh]] += sz[it->second];
        mp.erase(it->first);
    }
    if (dfs(mp.begin()->second, 0) == mp.begin()->first)
    {
        for (int i = 1; i <= n; i++)
            for (int j : e[i])
                if (j > i)
                    printf("%d %d\n", i, j);
    }
    else puts("-1");
}

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

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define FORR( i, m, n ) for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

signed main() {
	int n; cin >> n;
	vector<int> a( n );

	REP( i, n ) cin >> a[i];

	int sum = 0, ans = INF;
	REP( i, n ) {
		sum += a[i];
		ans = min( sum / ( i + 1 ), ans );
	}

	cout << ans << endl;
}


Measured memory_bytes: 3080
#define L long long
m[31][50];main(n,p,d,x){L a[50],b;for(;scanf("%d",&n),n;){memset(m,0,6200);for(p=0;p<n;a[p]=(L)1<<p,p++)for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;for(d=1;d<31;d++){for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];for(p=0;p<n;p++)if(m[d][p]&&(a[p]=b)==((L)1<<n)-1){printf("%d\n",d);goto s;}}puts("-1");s:;}exit(0);}

Measured memory_bytes: 616
a = input()

def main():
    ed = []
    for i in range(int(a)):
        neww = input()
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,y,f=0,a,b,c;
    cin>>n>>y;
    for(long long int i=0;i<=2000;i++)
    {
        for(long long int j=0;j<=2000&&i+j<=n;j++)
        {
            if(i*10000+j*5000+(n-i-j)*1000==y)
            {
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;

int x, a, b;

int main()
{
	scanf ("%d %d %d", &x, &a, &b);
	int l = abs(a - x);
	int r = abs(b - x);
	if (l < r)	printf ("A\n");
	else	printf ("B\n");
}
	
	

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long n = in.nextLong();
        long ans = n - 1;
        for (long x = 2; x * x <= n; x++) {
            if (n % x == 0) {
                ans = Math.min(ans, x + n / x - 2);
            }
        }
        out.println(ans);
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 23380
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

if A > B:
    W = -W
    V = -V

if V == W:
    print("NO")
elif A > B:
    if A + V * T <= B + W * T:
        print("YES")
    else:
        print("NO")
else:
    if A + V * T >= B + W * T:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 61756
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
    int n, i, max=0, second=0, maxnum;
    scanf("%d", &n);
    int a[200000];
    for(i=0; i<n; i++) scanf("%d", &a[i]);

    for(i=0; i<n; i++)
    {
        if(a[i]>=max)
        {
            second=max;
            max=a[i];
            maxnum=i;
        }
        else if(a[i]>=second)
        {
            second=a[i];
        }
    }
    if(max==second)
    {
        for(i=0; i<n; i++) printf("%d\n", max);
    }
    else
    {
        for(i=0; i<n; i++)
        {
            if(i==maxnum) printf("%d\n", second);
            else printf("%d\n", max);
        }
    }
    

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  map<string, int> w;
  w["SUN"] = 7;
  w["MON"] = 6;
  w["TUE"] = 5;
  w["WED"] = 4;
  w["THU"] = 3;
  w["FRI"] = 2;
  w["SAT"] = 1;
  string s;
  cin >> s;
  cout << w[s] << endl;
}


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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    int n,m;
    cin>> n >> m;
    vector<int> A(n);
    vector<int> B(n);
    rep(i,m){ 
        int a,b;
        cin >> a>>b;
        A[a-1]++;
        B[b-1]++;
        
    }
    
    rep(i,n){
        
        cout <<  A[i]+B[i] << endl;
     }

}

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

int main()
{
  int64_t N, a = 0, ans = 0;
  cin >> N;
  while (N > 0)
  {
    ans += (N % 10);
    a += (N % 10);
    N /= 10;
  }
  if (a == 1)
    ans *= 10;
  cout << ans << endl;
}

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

namespace Competition
{
    public class Program
    {
        
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            string res = "";

            for(int i = 0; i < S.Length; i++)
            {
                var s = (int)S[i] + N;
                if (s > 90)
                {
                    s -= 26;
                }
                res += (char)s;
            }
            Console.WriteLine(res);
        }

    }
}


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

int func(int n) {
  int total = 0;
  while (n > 0) {
    total += n % 10;
    n /= 10;
  }
  return total;
}

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

  int result = N % func(N);

  if (!result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int b[1000005];

int main()
{
	
	int n;
	memset(b,0,sizeof(b));	
	cin >> n;
	int a[n],max = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		
		if(max < a[i])
		max = a[i];
		b[a[i]]++;
		b[a[i]-1]++;
		b[a[i]+1]++;
	
	}
	
	int max1 = 0;
	for(int i = 0;i <= max + 1;i++){
		if(max1<b[i])
			max1 = b[i];
	}
	cout << max1;
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N,M;
    cin >> N >> M;
    if(N <= M/2) cout << N + (M-2*N)/4 << endl;
    else cout << M/2 << endl;
}

Measured memory_bytes: 3568
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

int n, m;
int x;
int[] c;
int[][] a;

int check(int flag) {
  int[] res = new int[m];
  int cost = 0;
  for(int i=0; i<n; i++) {
    if(((1<<i)&flag) > 0) {
      for(int j=0; j<m; j++) res[j] += a[i][j];
      cost += c[i];
    }
  }
  foreach(ri;res) if(ri<x) return int.max;
  return cost;
}

void main() {
  readf("%d %d %d\n", &n, &m, &x);
  c = new int[n];
  a = new int[][n];
  for(int i=0; i<n; i++) {
    readf("%d ", &c[i]);
    a[i] = readln.chomp.split.to!(int[]);
  }
  int mini = int.max;
  for(int flag=0; flag<(1<<n); flag++) {
    mini = min(mini, check(flag));
  }
  if(mini<int.max) writeln(mini);
  else writeln(-1);
}


Measured memory_bytes: 2944
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
struct edge{
  int to,id;
  edge(int to,int id): to(to),id(id) {}
};
 V<edge> g[55];
int main(){
 int n,m;
 cin>>n;
 ll sum=(1ll<<(n-1));
 for(int i=0;i<n-1;i++){
   int a,b;
   cin>>a>>b;
   g[--a].emplace_back(--b,i);
   g[b].emplace_back(a,i);
 }
 set<P> s;
 cin>>m;
 V<P> a(m);
 for(int i=0;i<m;i++){
   cin>>a[i].fi>>a[i].se;
   --a[i].fi;--a[i].se;
 }
 V<ll> idx(m,0);
 for(int i=0;i<m;i++){
   V<int> d(n,1e5);
   d[a[i].fi]=0;
   queue<int> q;
   q.emplace(a[i].fi);
   while(q.size()){
     int now=q.front();
     q.pop();
     for(auto v:g[now]){
       if(d[v.to]>d[now]+1){
         d[v.to]=d[now]+1;
         q.emplace(v.to);
       }
     }
   }
   int val=d[a[i].se];
   sum-=(1ll<<val);
   int cur=a[i].se;
   while(val){
     for(auto v:g[cur]){
       if(d[v.to]==d[cur]-1){
         idx[i]|=(1ll<<v.id);
         val=d[v.to];cur=v.to;
         break;
       }
     }
   }
 }
V<ll> bit(m+1,0);
 for(int i=1;i<(1<<m);i++){
   ll mask=0;
   int d=__builtin_popcount(i);
   for(int j=0;j<m;j++){
       if(i&(1<<j)){
         mask|=idx[j];
       }
   }
   int com=__builtin_popcountll(mask);
   bit[d]+=(1ll<<(n-1-com));
 }
 ll ans=(1ll<<(n-1));
 for(int i=1;i<=m;i++){
   if(i%2==1)ans-=bit[i];
   else ans+=bit[i];
 }
 cout<<ans<<"\n";
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
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;}

int main(){
    string n;
    cin >> n;
    n = " " + n;

    ll dp[n.size()][2];
    dp[0][0] = 0;
    dp[0][1] = 1000000007;
//
//    // 0はその桁の紙幣を払う
//    // 1は一桁上の紙幣を払う
    for(int i=1; i<n.size(); i++) {
        int k = n[i] - '0';
        dp[i][0] = min(dp[i-1][0] + k, dp[i-1][1] + k);
        dp[i][1] = min(dp[i-1][0] + 11 - k, dp[i-1][1] + 9 - k);
    }

    cout << min(dp[n.size()-1][0], dp[n.size()-1][1]) << endl;

    return 0;
}

Measured memory_bytes: 16944
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> A;
    int a;
    for(int i = 1; i <= N; i++){
        cin >> a;
        A[a] = i;
    }


    for(auto p : A){
        cout << p.second << (p.first == N ? "\n" : " "); 
    }



    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    rep(i, n - 1) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n; ++i) {
        int res = 0;
        for (int j = i; j < n - 1; ++j) {
            if (res < s[j]) res = s[j];
            if (res % f[j] == 0);
            else res += f[j] - res % f[j];
            res += c[j];
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        string Input;
        string[] SplittedInput;
        int a,b,gcd,lcm;
        while((Input = System.Console.ReadLine()) != null){
            SplittedInput = Input.Split(' ');
            a = int.Parse(SplittedInput[0]);
            b = int.Parse(SplittedInput[1]);
            gcd = EuclideanAlgorithm(a,b);
            lcm = b * (a / gcd); 
            System.Console.WriteLine(gcd + " " + lcm);
        }
    }
    
    public static int EuclideanAlgorithm(int a, int b){
        int Modulo = a % b;
        if(Modulo == 0){
            return b;
        }
        return EuclideanAlgorithm(b, Modulo);
    }
}

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main()
{  
  string s;
  cin>>s;
  int flag=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=='7')
       flag=1;
  }
  if(flag==0)
     cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  
  

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){
  ll x;
  cin >> x;
  set<ll> se;
  ll p = x;
  se.insert(0);
  while(not se.count(p)){
    se.insert(p);
    p += x;
    p %= 360;
  }
  cout << se.size() << endl;

}



Measured memory_bytes: 3536
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[1000100][2];


int main(){
    int n;
    cin>>n;
    vector<vector<P> > v(n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        while(a){
            a--;
            int x,y;
            cin>>x>>y;
            x--;
            v[i].push_back(P(x,y));
        }
    }
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> justice;
        vector<int> unjus;
        for(int i=0;i<n;i++){
            if(1 & bit>>i){
                justice.push_back(i);
            }else{
                unjus.push_back(i);
            }
        }

        vector<int> f(n,0);
        bool flag=true;

        for(int i:justice){
            f[i]=2;
        }

        for(int i:unjus){
            f[i]=1;
        }

        for(int i:justice){
            for(int j=0;j<v[i].size();j++){
                int x=v[i][j].first;
                int y=v[i][j].second;
                if(f[x]==0){
                    f[x]=y+1;
                }else{
                    if(f[x]!=y+1){
                        flag=false;
                        break;
                    }
                }
            }
            if(!flag) break;
        }


        if(flag) ans=max(ans,(int)justice.size());
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3600
N = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(N-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        count += 1
        
if p[N-1] == N:
    p[N-1], p[N-2] = p[N-2], p[N-1]
    count += 1

print(count)

Measured memory_bytes: 13880
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

using namespace std;

const ll INF = 1e9 + 10;
const ll INF2 = 3e18 + 10;
const int MOD = 1e9 + 7;
const ld EPS = 1e-4;

const int LOGN = 19;
const int MAXN = 305;

int dp[10000][100][2];

inline void add_self(int &a, int b) {
	a = (a + b) % MOD;
}

int main() {
	FAST;

	vector<int> a;
	int n, d;
	{
		string s;
		cin >> s >> d;
		n = s.size();
		a.resize(n);
		for (int i = 0; i < n; i++) {
			a[i] = (int) (s[i] - '0');
		}
	}
	for (int i = 0; i < a[0]; i++) {
		dp[0][i % d][0] += 1;
	}
	dp[0][a[0] % d][1] += 1;

	for (int i = 1; i < n; i++) {
		for (int k = 0; k < d; k++) {
			//cout << i << ' ' << k << endl;
			for (int j = 0; j < 10; j++) {
				add_self(dp[i][k][0], dp[i - 1][(k + 10*d - j) % d][0]);
			}
			for (int j = 0; j < a[i]; j++) {
				add_self(dp[i][k][0], dp[i - 1][(k + 10*d - j) % d][1]);
			}
			add_self(dp[i][k][1], dp[i - 1][(k + 10*d - a[i]) % d][1]);
		}
	}

	int ans = MOD - 1;
	for (int j = 0; j < 2; j++) {
		add_self(ans, dp[n - 1][0][j]);
	}
	cout << ans;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
using Data = pair<long long, vector<int> >;

int main() {
  vector<ll> N(3);
  int K;
  for (int i = 0; i < 3; ++i) cin >> N[i];
  cin >> K;
  vector<vector<ll> > v(3);
  for (int iter = 0; iter < 3; ++iter) {
    v[iter].resize(N[iter]);
    for (int i = 0; i < N[iter]; ++i) cin >> v[iter][i];
    sort(v[iter].begin(), v[iter].end(), greater<ll>());
  }
  priority_queue<Data> que;
  set<Data> se;
  que.push(Data(v[0][0] + v[1][0] + v[2][0], vector<int>({0, 0, 0})));
  for (int k = 0; k < K; ++k) {
    auto c = que.top();
    que.pop();
    cout << c.first << endl;

    // 次の三候補
    for (int iter = 0; iter < 3; ++iter) {
      if (c.second[iter] + 1 < N[iter]) {
        ll sum =
            c.first - v[iter][c.second[iter]] + v[iter][c.second[iter] + 1];
        auto num = c.second;
        num[iter]++;
        auto d = Data(sum, num);

        // すでに push されたもの以外
        if (!se.count(d)) se.insert(d), que.push(d);
      }
    }
  }
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

class UnionFind{
  public:
  //親の番号を格納する 親だった場合-1*集合のサイズ
  vector<int> Parent;

  //コンストラクタ 初めはバラバラの状態
  UnionFind(int N){
    Parent = vector<int>(N,-1);//要素数N,要素の値-1で初期化
  }

  //Ａがどのグループに属しているか調べる
  int root(int A){
    if(Parent[A] < 0)return A;//Aが親だったらA自身を返す
    return Parent[A] = root(Parent[A]);//親に繋ぎなおす
  }

  //頂点数を調べる
  int size(int A){
    return -Parent[root(A)];//Aの根×-1=集合のサイズ
  }

  //AとBをくっつける
  bool connect(int A, int B){
    //Aの根とBの根をくっつける
    A = root(A);
    B = root(B);
    if(A==B)return false;//既に同じグループならそのままでfalseを返す

    //Aのサイズ>=Bのサイズとする  
    if(size(A)<size(B))swap(A,B);

    Parent[A] += Parent[B];//AのサイズにBのサイズを足す
    Parent[B] = A;//Bの親をAに変更する
    return true;
  }

  //AとBが同じグループかどうか調べる
  bool same(int A,int B){
    if(root(A)==root(B))return true;
    else return false;
  }

};

int main(){
  ll N,M;
  cin >> N >> M;
  int A[100010],B[100010];
  rep(i,M){
    cin >> A[i] >> B[i];
    A[i]--;B[i]--;
  }
  
  UnionFind UF(N);
  ll ans[100010] = {};
  ans[M-1] = N*(N-1)/2;
  for(int i=M-2; i>=0; i--){
    ll a = UF.size(A[i+1]),b = UF.size(B[i+1]);
    //cout << a << " " << b << endl;
    if(UF.same(A[i+1],B[i+1])){
      ans[i] = ans[i+1];
    }else{
      ans[i] = ans[i+1]-a*b;
    }
    UF.connect(A[i+1],B[i+1]);
  }
  rep(i,M){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = [LI() for _ in range(n)]
    r = sum(sorted([c[0]+c[1]+c[2] for c in a], reverse=True)[:m])
    tr = sum(sorted([c[0]+c[1]-c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([c[0]-c[1]-c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([c[0]-c[1]+c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([-c[0]+c[1]-c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([-c[0]+c[1]+c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([-c[0]-c[1]-c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    tr = sum(sorted([-c[0]-c[1]+c[2] for c in a], reverse=True)[:m])
    if r < tr:
        r = tr
    return r


print(main())



Measured memory_bytes: 7688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,m;
    cin>>n>>m;
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        double a,b;
        cin>>a>>b;
        double aa=a*a;
        double  bb=b*b;
        double  cc=aa+bb;
        double  x= sqrt(cc);
       // cout<<x<<endl;
        if(x<=m)
        {
            cnt++;
        }


    }
    cout<<cnt<<endl;




}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e12;


int main(){

    int N,W;
    cin>>N>>W;
    vector<ll> v(N),w(N);
    for(int i=0;i<N;i++)cin>>w[i]>>v[i];
    vector<vector<ll> > dp(2,vector<ll>(W+1,0) );
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
	for(int j=W;j>=w[i];j--){
	    dp[(i+1)%2][j] = max( dp[i%2][j] , dp[i%2][j-w[i]] + v[i] );
	}
	for(int j=0;j<w[i];j++) dp[(i+1)%2][j] = dp[i%2][j]; 
    }
    cout<<dp[N%2][W]<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
        a /= 2;
        b += a;
    }
    else{
        b /= 2;
        a += b;
    }
  }

  cout << a << " " << b << endl;
}

Measured memory_bytes: 1024
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

const ll mod = 998244353;
int main(){
  FASTIO;
  ll n, x, m; cin >> n >> x >> m;
  bool dp[m]; memset(dp, 0, sizeof dp);
  vector<ll> mods;
  ll ans = 0;
  while (n) {
    if (dp[x])
      break;
    ans += x;
    dp[x] = true;
    mods.pb(x);
    x = (x * x) % m;
    n--;
  }
  if (n == 0)
    return cout << ans << endl, 0;
  ll sum = 0;
  ll idx = 0;
  while (mods[idx] != x) idx++;
  for ( int k = idx; k < sz(mods); k++ )
    sum += mods[k];
  ll cnt = sz(mods) - idx;
  ans += (n / cnt) * sum;
  for ( int k = 0; k < n % cnt; k++ )
    ans += mods[idx + k];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  	long long a, b, c, d;
  	cin >> a >> b >> c >> d;
  	long long ans=a*c;
  	ans=max(ans, a*d);
  	ans=max(ans, b*c);
  	ans=max(ans, b*d);
  	cout << ans << endl;
  	
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){

  string ans,o,e;
  cin >> o >> e;
  FOR(i,o.size()){
    ans+=o[i];
    if(i==e.size()){break;}
    ans+=e[i];
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>

using namespace std;

long long pow10(int n){
	long long res=1;
	while(n--)
		res*=10;
	return res;
}

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

int main(){
	ostringstream out;

	int n,m;
	cin >> n >> m;
	vector<int> boy;
	for(int i=0;i<n;i++)
		boy.push_back(9);

/*
	vector<bool> prime(pow10(m>=0?2*n+1:2*n));
	for(int i=2;i<prime.size();i++){
		if(prime[i])continue;
		for(int j=i*2;j<prime.size();j+=i)
			prime[j]=true;
	}
*/
/*
	for(int i=0;i<prime.size();i++)
		cout << i << " "<<prime[i] << endl;

	if(true)
		return 0;
*/

	while(true){
		vector<int>num;
		for(int i=0;i<n;i++)
			num.push_back(boy[i]);
		if(m>=0)
			num.push_back(m);
		for(int i=n-1;i>=0;i--)
			num.push_back(boy[i]);
		unsigned long long number=0;
		for(int i=0;i<num.size();i++)
			number+=num[i]*pow10(num.size()-1-i);
//		if(!prime[number]){
		if(isPrime(number)){
			out << number << endl;
			break;
		}

		int i=boy.size()-1;
		for(;i>=0;i--){
			if(boy[i]<0){
				boy[i]=9;
				if(i>0)
					boy[i-1]--;
				continue;
			}else{
				boy[i]--;
				break;
			}
		}

		if(i<0||boy[i]==0){
			for(int i=0;i<n;i++)
				out << 9;
			if(m>=0)
				out << m;
			for(int i=0;i<n;i++)
				out << 9;
			out << endl;
			break;
		}

	}

	cout << out.str();
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, k;
  vector<int> r;
  cin >> n >> k;

  while(1) {
    int a = n / k;
    if(n == 0)
      break;
    r.push_back(n % k);
    n = a;
  }
  cout << r.size() << endl;

  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  string a;
  cin >> a;
  int tmp;
  string baka;
  int ans = 10000;
  rep(i, a.length() - 2) {
    baka = "";
    baka += a[i];
    baka += a[i+1];
    baka += a[i+2];
    tmp=stoi(baka);
    ans = min(ans,abs(tmp-753));
  }
  cout << ans;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;


*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,k; cin >> n >> k;
    vector<ll> x(n),y(n),posx,posy;
    rep(i,n){
        cin >> x[i] >> y[i];
        posx.push_back(x[i]);
        posy.push_back(y[i]);
    }
    sort(ALL(posx));
    sort(ALL(posy));
    ll ans = (posx[n-1] - posx[0]) * (posy[n-1] - posy[0]);
    rep(xl,n){
        FOR(xr,xl+1,n){
            rep(yl,n){
                FOR(yr,yl+1,n){
                    int cnt = 0;
                    rep(i,n) if(posx[xl] <= x[i] && x[i] <= posx[xr] && posy[yl] <= y[i] && y[i] <= posy[yr]) cnt++;
                    if(cnt >= k) ans = min(ans, (posx[xr] - posx[xl]) * (posy[yr] - posy[yl]));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

int main() {
    ll N, K;
    string S;
    cin >> N >> K >> S;
    V<pair<ll, bool>> cnt;
    S += '2';
    char now = S[0];
    ll ncnt = 0;
    for(char c : S) {
        if(c != now) {
            bool b = (now == '1');
            cnt.emplace_back(ncnt, b);
            ncnt = 0;
        }
        now = c;
        ncnt++;
    }
    V<ll> sum(cnt.size() + 1);
    for(ll i = 0; i < cnt.size(); i++) sum[i + 1] = sum[i] + cnt[i].first;
    ll ans = 0;
    DEBUG(sum);
    for(ll i = 0; i < sum.size(); i++) {
        bool b = cnt[i].second;
        ll right = i + 2 * K + b;
        chmin(right, (ll)sum.size() - 1);
        DEBUG(right);
        DEBUG(sum[right], sum[i]);
        chmax(ans, sum[right] - sum[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2752
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;

const int N=200005;

int n,l,r,mid,m;
int a[N],b[N];

bool check(int w){
	int i,l,r;
	for (i=1;i<=m;i++) b[i]=(a[i]>w);
	l=r=n;
	while (l>1&&b[l]!=b[l-1]) l--;
	while (r<m&&b[r]!=b[r+1]) r++;
	if (m-r+1>=l) return b[r];
	return b[l];
}

int main(){
	int i;
	scanf("%d",&n); m=n+n-1;
	for (i=1;i<=m;i++) scanf("%d",&a[i]);
	l=1; r=m;
	while (l<r){
		mid=l+(r-l)/2;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	printf("%d\n",r);
	return 0;
}

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

string s;
int a[4];

int main(){
	cin >> s;
	for(int i=0; i<4; ++i)
		a[i] = s[i] - '0';
	for(int i=0; i<8; ++i){
		int sign[3] = {};
		for(int j=0; j<3; ++j)
			sign[j] = (i>>j)%2*2-1;
		int tmp = a[0];
		for(int j=0; j<3; ++j)
			tmp += sign[j] * a[j+1];
		if(tmp == 7){
			printf("%d%s%d%s%d%s%d=7\n", a[0], sign[0] == 1 ? "+" : "-", a[1], sign[1] == 1 ? "+" : "-", a[2], sign[2] == 1 ? "+" : "-", a[3]);
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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()
{
  int a; cin >> a;
  cout << a + a*a + a*a*a << "\n";
  return 0;
}


Measured memory_bytes: 3640
a = input()
b = input()
la = len(a)
lb = len(b)
if la > lb:
  print('GREATER')
elif la==lb:
  if a > b:
    print('GREATER')
  elif a==b:
    print('EQUAL')
  else:
    print('LESS')  
else:
  print('LESS')

  
  
  

Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int main()
{
    int[][string] T;
    string[] t;
    while (true) {
        string[] s = readln.chomp.split;
        if (stdin.eof) break;
        string str = s[0];
        int p = s[1].to!int;
        T[str] ~= p;
        t ~= str;
    }
    t.sort();
    int i = 0;
    string tmp = t[0];
    while (i < t.length) {
        tmp = t[i];
        writeln(tmp);
        sort(T[tmp]);
        write(T[tmp][0]);
        for (int j = 1; j < T[tmp].length; j++) write(" ", T[tmp][j]);
        while (tmp == t[i]) {
            i++;
            if (i >= t.length) break;
        }
        writeln();
    }

    return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a,b;
    int tmp,flag =0;
    cin >> a >> b;
    if(b/10 == 0){ tmp =10;}
    else if(b/100 == 0){ tmp =100;}
    else tmp =1000;
    a = a*tmp +b;
    FOR(i,0,10001){
        if(i*i ==a)
            flag = 1;
    }
    if(flag == 0)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	int loop;
	int nowHeight,MaxShift=0,hinput,nowshift=0;
	cin >> nowHeight;
	for(loop=1;loop<N;loop++){
		cin >> hinput;
		if(nowHeight>=hinput){
			nowHeight=hinput;
			nowshift++;
		}else{
			if(nowshift>MaxShift){
				MaxShift=nowshift;
			}
			nowHeight=hinput;
			nowshift=0;
		}
	}
	if(nowshift>MaxShift){
		MaxShift=nowshift;
	}
	cout << MaxShift << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    lint x, k, d;
    std::cin >> x >> k >> d;
    x = std::abs(x);

    auto y = x % d;
    auto dist = (x - y) / d;
    if (dist > k) {
        std::cout << x - k * d << "\n";
        return;
    }

    lint ans = -1;
    for (int i = 0; i < 2; ++i) {
        if (dist % 2 == k % 2) ans = std::abs(y);
        y -= d;
        ++dist;
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int cnt(int x) {
	int cnt = 0;
	while (x) {
		++cnt;
		x /= 10;
	}
	return cnt;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	int answer = 0;
	for (int i = n; i >= 1; --i) {
		if (cnt(i) % 2 == 1) {
			++answer;
		}
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
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)
        {
            new Program().Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            var ansNumbers = Enumerable.Range(1, 55555)
                .Where(x => IsPrimeNumber(x))
                .Where(x => x % 5 == 1)
                .Take(n)
                .ToArray();
            Console.WriteLine(string.Join(" ", ansNumbers));


        }

        bool IsPrimeNumber(int n)
        {
            if (n <= 1)
                return false;
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var st = Reads();
            WriteLine(st[1] +st[0]);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for(int i = 0; i < S.size()-2; ++i) if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ++res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
  #include<math.h>
  using namespace std;
  int main()
  {
    int a,b;
    cin>>a>>b;
    int len = to_string(b).length();
    int sq = a * pow(10, len) + b;
    int h = 0;
    for(int i = sq; i > 0; i-- ){
      if(i * i == sq) {
        puts("Yes");
        h = 1;
      }
    }
    if(h == 0) puts("No");
    return 0;
  }


Measured memory_bytes: 256