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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string result = S=="ABC" ? "ARC" : "ABC";
  cout << result << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> as(N + 1);
  for(int i = 1; i <= N; ++i) {
    cin >> as[i];
  }
  vector<int> ans(N + 1, 0);
  for(int i = as.size() - 1; i > 0; --i) {
    int count = 0;
    for(int j = 2; i * j < as.size(); ++j) {
      // cout << i * j << " ";
      if(ans[i * j] > 0) {
        count++;
      }
    }
    // cout << count << endl;
    ans[i] = count % 2 != as[i];
  }
  int count = count_if(ans.begin(), ans.end(), [](const auto& n) { return n > 0; });
  cout << count << endl;
  if(count > 0) {
    for(int i = 0; i < ans.size(); ++i) {
      if(ans[i] > 0) {
        cout << i << " ";
      }
    }
    cout << endl;
  }
  return 0;
}


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

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> data(h+2,vector<char>(w+2,'.'));
    for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
            cin >> data[i][j];
        }
    }
    
    bool isYes = true;
    for(int i = 1;i <=h;i++){
        for(int j = 1;j <= w;j++){
            if(data[i][j] == '.') continue;
            bool isExist = false;
            for(int k = 0;k < 4;k++){
                if(data[i+dx[k]][j+dy[k]] == '#') isExist = true;
            }
            if(!isExist){
                isYes = false;
                break;
            }
        }
        if(!isYes) break;
    }
    if(isYes) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
long long int gcd(long long int a,long long int b)
{
	if(a<b)
	{
		long long int t=a;a=b;b=t;
	}
	return b==0?a:gcd(b,a%b);
}
long long int lcm(long long int a,long long int b)
{
	return a/gcd(a,b)*b;
}
int main()
{
	long long int i,j,k,l,n,m,t,a;
	scanf("%lld",&n);
	m=1;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a);
		m=lcm(m,a);
	}
	printf("%lld",m);
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d)
		printf("Left\n");
	if(a+b==c+d)
		printf("Balanced\n");
	if(a+b<c+d)
		printf("Right\n");
	return 0;
}

Measured memory_bytes: 128
from fractions import gcd
n=int(input())
c=list(map(int,input().split()))
a=[c[0]]
b=[c[-1]]
for i in c[1:]:
    a.append(gcd(a[-1],i))
for i in c[:-1][::-1]:
    b.append(gcd(b[-1],i))
b=b[::-1]+[a[-2]]
a=[b[1]]+a
k=1
for i in range(n):
    k=max(k,gcd(a[i],b[i+1]))
print(k)

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

int main() {
int N;
cin >> N;
vector<int> d(N);
for (int i = 0; i < N; i++) {
    cin >> d.at(i);
}
int count = 0;
for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
        if (j <= i) {
            continue;
        }
        count += d.at(i) * d.at(j);
    }
}
cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

int main(int argc, char *argv[]){
	int x; cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    evena=[False]*n
    for i in range(n):
        if a[i]%2==0:
            evena[i]=True
    count=0
    for i in range(3**n):
        #print(i)
        neven=0
        for bit in range(n):
            mask=3**bit
            if (i//mask)%3 == 0:
                #print('mask0')
                if evena[bit]==False:
                    neven+=1
            elif (i//mask)%3 == 1:
                #print('mask1')
                if evena[bit]==True:
                    neven+=1
            elif (i//mask)%3 == 2:
                #print('mask2')
                if evena[bit]==False:
                    neven+=1
            #else:
                #print('????')
        if neven>0:
            count+=1
    return count

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)
  
        

Measured memory_bytes: 9136
# encoding: utf-8
n = int(input())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n): b[(n - 1) // 2 + (i + 1) // 2 if i % 2 else (n - 1) // 2 - (i + 1) // 2] = a[i]

if n % 2: print(" ".join(list(map(str, b))))
else:print(" ".join(list(map(str, reversed(b)))))

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/
static const int N = 3, N2 = 9;

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < ( const Puzzle &p ) const {
        rep(i, N2){
            if(f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
    rep(i,N2){
        if(p.f[i] != i+1) return false;
    }
    return true;
}

string bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle, bool> V;    // 自作した構造体に関するmapを定義
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while(!Q.empty()){
        u = Q.front(); Q.pop();
        // もしパズルuがターゲットと合致していれば
        if(isTarget(u)) return u.path;
        int sx = u.space / N;   // space x
        int sy = u.space % N;   // space y
        rep(r, 4){
            int tx = sx + dx[r];    // transfer x
            int ty = sy + dy[r];    // transfer y
            if(tx<0 || ty<0 || tx>=N || ty>=N) continue;    // 移動先がパズルの枠を超えてしまわないようにする
            v = u;
            swap(v.f[u.space], v.f[tx*N + ty]);
            v.space = tx*N + ty;    // spaceの位置も移動
            if( !V[v] ){    // 既に同じ配置のパズルを動かし済みの場合はスルーする
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}


int main()
{
    Puzzle in;

    rep(i,N2){
        cin >> in.f[i];
        if(in.f[i] == 0){
            in.f[i] = N2;   // set space
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    // cout << ans << endl;
    return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
  if (s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

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

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(k - n>= 0){
        cout << n * x << endl;
    }else{
        n -= k;
        cout << k * x + n * y << endl;
    }


    return 0;
}

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

public class Main implements Runnable {

	static long mod = (long)(1e9 + 7L);

	public long Pow(long x, long y) {
		
		if(y == 0L)
			return 1L;
		
		if(y == 1L)
			return x;

		long pow = y;
		long ans = 1L;

		while (pow > 0) {

			if ((pow & 1) == 1)
				ans = (ans * x) % mod;

			pow /= 2;
			x = (x * x) % mod;
		}
		return ans % mod;
	}

	public static void main(String[] args) throws Exception {

		new Thread(null, new Main(), "SwapnilGanguly", 1 << 26).start();
	}

	public void run() {

		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);

		int n = sc.nextInt();
		pr.println(n ^ 1);
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			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: 33016
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  var data = chunk.split( " " ).map( Number );
  var a = data[0];
  var b = data[1];
  var C = data[2]*(Math.PI/180);
  
  var h = Math.sin( C )*b;
  var ta = Math.cos( C )*b;
  var c = Math.sqrt( Math.pow( (a-ta), 2 )+Math.pow( h, 2 ) );
  
  var S = (a*h)/2;
  var L = a+b+c;
  console.log( S+'\n'+L+'\n'+h );
});

Measured memory_bytes: 15672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  string s;
  cin >> s;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';
  if(a+b+c+d == 7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
  else if(a+b+c-d == 7) printf("%d+%d+%d-%d=7\n", a,b,c,d);
  else if(a+b-c+d == 7) printf("%d+%d-%d+%d=7\n", a,b,c,d);
  else if(a+b-c-d == 7) printf("%d+%d-%d-%d=7\n", a,b,c,d);
  else if(a-b+c+d == 7) printf("%d-%d+%d+%d=7\n", a,b,c,d);
  else if(a-b+c-d == 7) printf("%d-%d+%d-%d=7\n", a,b,c,d);
  else if(a-b-c+d == 7) printf("%d-%d-%d+%d=7\n", a,b,c,d);
  else if(a-b-c-d == 7) printf("%d-%d-%d-%d=7\n", a,b,c,d);
  return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;

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

  int ans = 0;
  FOR(n,1,sqrt(N)) {
    int m = (N-n)/n;
    // cerr << n << " " << m << " " << N/m << " " << N%m << endl;
    // if(m <= N/n && N/(n+1) < m) ans += m;
    if((N-n)%n == 0 && m <= N/n && N/(n+1) < m) ans += m;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] problems = new int[N];
        for (int i = 0; i < N; i++) {
            problems[i] = 1;
        }
        for (int i = 0; i < M; i++) {
            int prob = in.nextInt()-1;
            String result = in.next();
            if (result.equals("AC") && problems[prob] > 0) {
                problems[prob] = (problems[prob] * -1);
            }
            else if (result.equals("WA") && problems[prob] > 0){
                problems[prob]++;
            }
        }

        int correct = 0;
        int penalty = 0;
        for (int i = 0; i < N; i++) {
            if (problems[i] < 0) {
                correct++;
            }
            if (problems[i] < 0) {
                problems[i]++;
                penalty += (problems[i]*-1);
            }
        }
        System.out.println(correct + " " + penalty);
    }
}


Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll mod = 998244353 ;
ll dp[4000] ;
int main()
{
  ll n , s ;
  cin >> n >> s ;
  ll ans = 0 ;
  for(int i = 1; i <= n ;i ++)
   {
     dp[0] += 1 ;
     int a ;
     cin >> a ;
     for(int j = s ;j >= a; j --)
      dp[j] = (dp[j] + dp[j - a]) % mod ;
     (ans += dp[s]) % mod ;
   }
   cout << ans % mod << endl ;
  return 0 ;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  bool is_odd = false; 
  int count = 0;
  
  while (true) {
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 != 0) {
		is_odd = true;
        break;
      }
    }
    if (is_odd) break;
    
    for (int i = 0; i < N; i++) A.at(i) /= 2;
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int N;
  cin>>N;
  vector<int> p(N+1);
  int judge=0;
  rep(i,1,N+1){
    cin>>p[i];
    if(p[i]!=i)judge++;
  }
  if(judge<=2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
    
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);


int main() {
	cin.sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	if (K == 0) {
		cout << N*N<< endl;
		return 0;
	}
	reps(i, K, N) {
		ans += N - i;
	}
	int x;
	reps(i, K, N + 1) {
		if (N - i < i + 1)break;
		reps(j, i+1, N-i+1) {
			x = (N - i) / j;
			ans += ((N-i)/x - j +1)*x;
			j = (N - i) / x;

		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){ 
  
  ll N,A,B; cin >> N >> A >> B;
  
  if( A > B){ swap(A,B);}
  
  if( ( A+B ) % 2 == 0 ){ 
    cout << abs(B-A)/2 << endl;
    
    return 0;
  }
 
  else{
    
    cout << min(A-1,N-B)+1+(B-A-1)/2 << endl;
    
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n;

/* add your algorithm here */

int main() {
  cin >> n;
  vector<string> v;
  string s;
  bool flag = false;
  rep(i,n) {
    cin >> s;
    v.pb(s);
  }

  rep(i,n) {
    rep(j,n) {
      if (i == j) continue;
      if (v[i] == v[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  for (int i = 1; i < n; ++i) {
    string a = v[i-1], b = v[i];
    if (a.back() != b[0]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int ans=0;
	string N;
	cin >> N;
	rep(i,N.size()){
		if(N[i] == '2')ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main (){
	scanf("%d",&n);
	int a[n+5],b[n+5];
	memset(b,0,sizeof(b));
	for (int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int bN=n,j=0;
	while (bN>0)	{
		printf("%d",a[bN-1]);
		bN-=2;
		j++;
		if (j<n)
			printf(" ");
	}
	if (bN%2==0){
		bN=1;
	}
	else {
		bN=2;
	}
	while (bN<n)	{
		printf("%d",a[bN-1]);
		bN+=2;
		j++;
		if (j<n)
			printf(" ");
	}
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
int a,b,c;
do{
scanf("%d %d %d",&a,&b,&c);
}while(a<0 || a>100 || b<0 || b>100 || c<0 || c>100);
if(a<b && b<c){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fori(i,a,b) for(int i=a;i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)

void solve(ll m, ll d){
    int ans=0;
    fori(i,1,d+1){
        int d1=i/10;
        int d2=i%10;
        if(d1>=2&&d2>=2&&d1*d2<=m)ans++;
    }
    cout<<ans<<endl;
}

int main(){
    ll m;
    scanf("%lld",&m);
    ll d;
    scanf("%lld",&d);
    solve(m, d);
    return 0;
}


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

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int &i: t) cin >> i;
    sort(t.begin(), t.end());
    int ans = 1;
    int cnt = 1;
    int fride = t[0];
    for (int i=1; i<n; ++i) {
        if (cnt == c) {
            ans++;
            cnt = 1;
            fride = t[i];
        }
        else if (t[i] > fride + k) {
            ans++;
            cnt = 1;
            fride = t[i];
        }
        else cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import math
from decimal import *
A,B = list(map(int, input().split()))
ans = -1
for x in range(1, 10001):
    a = math.floor(x * Decimal(0.08))
    b = math.floor(x * Decimal(0.1))
    if a == A and b == B:
        ans = x
        break
print(ans)

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    if (s.front() == s.back()) {
        if (s.size() % 2 == 0) {
            print("First");
        } else {
            print("Second");
        }
    } else {
        if (s.size() % 2 == 1) {
            print("First");
        } else {
            print("Second");
        }
    }
    return 0;
}

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

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);

		// input
		int num = scan.nextInt();
		int m = scan.nextInt();
		
		// check
		int answer = (1900 * m + 100 * (num - m)) * (int)Math.pow(2, m);
		
		// answer
		System.out.println(answer);
		
	}
		
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(){

	int count=0;;
	int k, n;
	long i, v, d;


	scanf( "%d", &n );

	for( k=0; k<n; k++ ){

		scanf( "%ld", &v );

		d = 0;
		for( i=2l; i<=sqrt(v); i++ ){
			//printf( " %ld / %ld = %ld\n", v, i, v%i );
			if( v%i == 0l ){ 
				d++; break;
			}	
		}

		//printf( " [%ld]\n", d );

		if( d == 0 ) count++;

	}

	printf( "%d\n", count );

	return 0;

}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

struct edge {
    int from, to; ll cost;
    edge(int from, int to, ll cost) : from(from), to(to), cost(cost) {}
};

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

    int n, m; cin >> n >> m;
    vector<edge> es;
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        es.emplace_back(a, b, -c);
    }

    vector<ll> d(n, linf);
    d[0] = 0;
    for (int i = 0; i < n * 2; i++) {
        for (auto &e: es) {
            if (d[e.from] < linf && d[e.from] + e.cost < d[e.to]) {
                if (i < n - 1) {
                    d[e.to] = d[e.from] + e.cost;
                } else {
                    d[e.to] = -linf;
                }
            }
        }
    } 

    if (d[n - 1] <= -linf) cout << "inf" << endl;
    else cout << -d[n - 1] << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;

    vector<ll > T(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> T[i];
    }

    ll M;
    cin >> M;
    vector<ll > P(M, 0);
    vector<ll > X(M, 0);

    for(ll i = 0; i < M; i++){
        cin >> P[i] >> X[i];
    }

    ll sum = INF;

    for(ll i = 0; i < M; i++){
        ll t_sum = 0;
        for(ll j = 0; j < N; j++){
            if(j == P[i]-1) t_sum += X[i];
            else t_sum += T[j];
        }        
        //sum = min(sum, t_sum);
        cout << t_sum << endl;
    }
}

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

int main(){
  int N;
  cin >>N;
  
  int a,b,c,d,e,f,g,h,i;
  a = N/100000000;
  b = (N/10000000)%10;
  c = (N/1000000)%10;
  d = (N/100000)%10;
  e = (N/10000)%10;
  f = (N/1000)%10;
  g = (N/100)%10;
  h = (N/10)%10;
  i = N%10;
  
  int x;
  x = a+b+c+d+e+f+g+h+i;
  
  if (N%x == 0){
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl;
  }
    
  
}

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

int r,c,n;
vector<pair<int,int> > a;
stack<int> q;

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	r=read();c=read();n=read();
	for (int i=1;i<=n;i++){
		int x=read(),y=read();
		if (y==0) a.push_back(make_pair(x,i));
		else if (x==r) a.push_back(make_pair(r+y,i));
		else if (y==c) a.push_back(make_pair(r+c+r-x,i));
		else if (x==0) a.push_back(make_pair(r+c+r+c-y,i));
		x=read(),y=read();
		if (y==0) a.push_back(make_pair(x,i));
		else if (x==r) a.push_back(make_pair(r+y,i));
		else if (y==c) a.push_back(make_pair(r+c+r-x,i));
		else if (x==0) a.push_back(make_pair(r+c+r+c-y,i));
		if (a.size()&1) a.pop_back();
	}
	sort(a.begin(),a.end());
	for (int i=0;i<(int)a.size();i++)
		if (!q.empty()&&q.top()==a[i].second) q.pop();
		else q.push(a[i].second);
	printf(q.empty()?"YES\n":"NO\n");
	return 0;
}

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

using namespace std;
const int N = 2000 + 10;

int n, m, q;
int a[N][N], s1[N][N], s2[N][N], s3[N][N], s4[N][N]; 

int main(void)
{
	scanf("%d %d %d", &n, &m, &q);
	for (int i=1;i<=n;++i)
	    for (int j=1;j<=m;++j)
	        scanf("%1d", &a[i][j]);
	for (int i=1;i<=n;++i)
	    for (int j=1;j<=m;++j)
	        s1[i][j] = s1[i-1][j] + s1[i][j-1] - s1[i-1][j-1] + a[i][j];
	//统计点的前缀和
	for (int i=1;i<=n;++i)
	    for (int j=1;j<=m;++j)
		    s2[i][j] = s2[i-1][j] + s2[i][j-1] - s2[i-1][j-1] + (a[i][j] & a[i-1][j]) + (a[i][j] & a[i][j-1]); 
	//统计边的前缀和
	for (int i=1;i<=n;++i) 
	    for (int j=1;j<=m;++j) 
			s3[i][j] = s3[i][j-1] + (a[i][j] & a[i-1][j]);
	//统计横向向上的边
	for (int j=1;j<=m;++j)
	    for (int i=1;i<=n;++i)
		    s4[i][j] = s4[i-1][j] + (a[i][j] & a[i][j-1]);
	//统计纵向向左的边 
	while (q --)
	{
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		int S_point = s1[x2][y2] - s1[x1-1][y2] - s1[x2][y1-1] + s1[x1-1][y1-1];
		int S_edge = s2[x2][y2] - s2[x1-1][y2] - s2[x2][y1-1] + s2[x1-1][y1-1];
		printf("%d\n", S_point - S_edge + s3[x1][y2] - s3[x1][y1-1] + s4[x2][y1] - s4[x1-1][y1]);
		//还需要减去除该矩形外多余的边 
	} 
	return 0;
}

Measured memory_bytes: 80640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int a, b, v, w;
    cin >> a >> v >> b >> w;
    int t;
    cin >> t;
    if (abs(a - b) <= (v - w) * t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    int x,a,b;
    cin >>x >>a >>b;
    
    if(b<=a){
        cout <<"delicious";
    }
    else if(b<=x+a){
        cout <<"safe";
    }
    else{
        cout <<"dangerous";
    }
    return 0;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;

int n;
string S;

int dp[N][2];

// D, P

main()
{
    ios_base::sync_with_stdio(0);
    cin >> S;
    n = S.size();
    S = "#" + S;
    dp[0][0] = 0;
    dp[0][1] = -n-1;
    for (int i = 1; i <= n; i++){
        dp[i][0] = -n-1;
        dp[i][1] = -n-1;
        vector < int > v;
        if (S[i] == 'D')
            v.pb (0);
        else if (S[i] == 'P')
            v.pb (1);
        else {
            v.pb (0);
            v.pb (1);
        }
        for (int x : v)
            for (int j = 0; j < 2; j++){
                int pas = dp[i-1][j];
                if (x == 0)
                    pas++;
                if (x == 0 && j == 1)
                    pas++;
                dp[i][x] = max (dp[i][x], pas);
            }
    }
    int ind=n, t=0;
    if (dp[n][1] > dp[n][0])
        t=1;
    while (ind){
        if (t == 0)
            S[ind] = 'D';
        else
            S[ind] = 'P';
        for (int j = 0; j < 2; j++){
            int pas = dp[ind-1][j];
            if (t == 0)
                pas++;
            if (t == 0 && j == 1)
                pas++;
            if (dp[ind][t] == pas){
                ind--;
                t = j;
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        cout << S[i];
    cout << endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// https://www.hamayanhamayan.com/entry/2019/02/03/234144

ll dp[100][2];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  
  vll a(n);
  rep(i,n) cin>>a[i];
  
  rep(i,41) rep(j,2) dp[i][j]=-LINF;
  dp[0][0]=0;
  
  rep(i,40) rep(j,2){
    if(dp[i][j]<0) continue;
    ll d=40-i-1;
    ll msk=1LL<<d;
    
    ll one=0, zero=0;
    rep(i,n){
      if(a[i]&msk) one++;
      else zero++;
    }
    
    ll nj=j;
    if(k&msk) nj=1;
    
    chmax(dp[i+1][nj],dp[i][j]+one*msk);
    
    if((k&msk) or j==1) chmax(dp[i+1][j],dp[i][j]+zero*msk);
  }
  
  cout<<max(dp[40][0],dp[40][1])<<endl;
}

Measured memory_bytes: 1024
a,b,c,d=map(int,input().split())

if a<=c<=b:
    if d<=b:
        print(d-c)
    else:
        print(b-c)
elif c<=a<=d:
    if b<=d:
        print(b-a)
    else:
        print(d-a)
else:
    print(0)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

int gcd(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    int m = a % b;
    if (m == 0) {
        return b;
    } else {
        return gcd(b, m);
    }
}

void solve()
{
    int A, B, K;
    cin >> A >> B >> K;
    
    int d = gcd(A, B);

    vector<int> vec;
    for (int i=d; i>=1; --i) {
        if ((A % i == 0) && (B % i == 0)) { 
            vec.push_back(i);
        }
    }
    print(vec[K-1]);
}

int main()
{
    solve();

    return 0;
}


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

int main()
{
  int N, D1, D2;
  cin >> N;
  
  int count = 0;
  bool pos = false;
  
  for(int i = 0; i < N; i++)
  {
    cin >> D1 >> D2;
    if(D1 == D2) count++;
    else count = 0;
    if(count == 3)
    {
      pos = true;
      break;
    }
  }
  
  if(pos) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<int> dp(H + 1, INF);
    dp[H] = 0;
    for (int i = H - 1; i >= 0; --i) {
        rep(j, N) {
            int index = min(H, i + A[j]);
            dp[i] = min(dp[i], dp[index] + B[j]);
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

int n, m, a, b;
int d[1005][1005];

void solve() {
    cin >> n >> m >> a >> b;

    int b1 = b, a1 = a;

    for (int j = 1; j <= m; j++) {
        if (a1) {
            d[1][j] = 1;
            a1--;
        }
        else {
            d[1][j] = 0;
        }
        int cur = d[1][j];
        b1 = b - 1;
        for (int i = 2; i <= n; i++) {
            if (b1) {
                d[i][j] = cur;
                b1--;
            }
            else {
                d[i][j] = cur ^ 1;
            }
        }

    }

    for (int i = 1; i <= n; i++) {
        int c1 = 0, c0 = 0;
        for (int j = 1; j <= m; j++) {
            if (d[i][j] == 1) c1++;
            else c0++;
        }
        if (a != min(c0, c1)) {
            cout << -1;
            return;
        }
    }

    for (int j = 1; j <= m; j++) {
        int c1 = 0, c0 = 0;
        for (int i = 1; i <= n; i++) {
            if (d[i][j] == 1) c1++;
            else c0++;
        }
        if (b != min(c1, c0)) {
            cout << -1;
            return;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cout << d[i][j];
        }
        cout << '\n';
    }

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


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



int main(){
  int n;
  map<string, bool> mp;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    string s1, s2;
    cin >> s1 >> s2;
    if(s1 == "insert") mp[(s2)] = true;
    else{
      if(mp[(s2)]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 52412
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include<cstring>
#include<tuple>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//AGC19 B

int main(void) {
	string a;
	cin >> a;
	vector<vector<ll>> pos = vector<vector<ll>>('z' - 'a' + 1, vector<ll>());
	rep(i, 0, a.size()) {
		pos[a[i] - 'a'].push_back(i);
	}
	ll count = 0;
	rep(i, 0, pos.size()) {
		ll n = pos[i].size();
		if (n > 1) {
			count += n * (n - 1) / 2;
		}
	}
	cout << a.size()* (a.size() - 1) / 2 - count + 1<< endl;
}

Measured memory_bytes: 3444
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,m;
	cin>>n>>m;
	if(n*2>m) {
		cout<<m/2<<endl;
		return 0;
	}
	if(n*2==m) {
		cout<<n<<endl;
		return 0;
	}
	cout<<n+((m-(2*n))/4)<<endl;
}

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

#define ll long long
#define mod 1000000007

int main(){
	int n;
	ll k,res=0;
	cin>>n>>k;
	ll mul_k=k*(k-1);
	mul_k/=2;
	mul_k%=mod;
	int a[n+1],c[2001];
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=1;i<=2000;i++){
		c[i]+=c[i-1];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[i]>a[j]){
				res+=k;
				if(res>=mod) res-=mod;
			}
		}
		res+=(c[a[i]-1]*mul_k)%mod;
		if(res>=mod) res-=mod;
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
max1=1
m=0
for i in range(n):
  if max1<a[i]:
    max1=a[i]
    m=i
a.pop(m)
max2=max(a)
a.insert(m,max1)
for i in range(n):
  if i!=m:
    print(max1)
  else:
    print(max2)

Measured memory_bytes: 12532
import java.io.*
import java.io.IOException
import java.util.*
import kotlin.system.measureTimeMillis
var out = PrintWriter(System.out)
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
fun solve() {
    var N = readLine()!!.toInt()
    var S = ns()

    var pre = ""
    var cnt = 0
    S.forEach {
        cnt += if(it == '(') 1 else -1
        if(cnt < 0) {
            pre += "("
            cnt++
        }
    }
    var post = ""
    for(i in 0 until cnt) post += ")"

    out.println(pre + S + post)
}












//---------------------------------------------------------------------------------------------------
fun main(args: Array<String>) {
    var time = measureTimeMillis {
        solve()
        out.flush()
    }
    //println("$time ms")
}
//---------------------------------------------------------------------------------------------------
private var inbuf = ByteArray(1024)
private var lenbuf = 0
var ptrbuf = 0

var `is` = System.`in`

fun readByte(): Byte {
    if (lenbuf === -1) throw InputMismatchException()
    if (ptrbuf >= lenbuf) {
        ptrbuf = 0
        try {
            lenbuf = `is`.read(inbuf)
        } catch (e: IOException) {
            throw InputMismatchException()
        }

        if (lenbuf <= 0) return -1
    }
    return inbuf[ptrbuf++]
}


private fun isSpaceChar(c: Byte): Boolean {
    return !(c >= 33 && c <= 126)
}

private fun skip(): Byte {
    var b: Byte
    while (true) {
        b = readByte()
        if(b < 0 && isSpaceChar(b)) break
    }
    return b
}

private fun ns(): String {
    /*var b = skip()
    val sb = StringBuilder()
    while (!isSpaceChar(b)) {
        sb.appendCodePoint(b.toInt())
        b = readByte()
    }
    return sb.toString()*/
    return readLine()!!
}

fun na(n: Int) = IntArray(n, {ni()})

fun ni(): Int {
    var num = 0
    var b: Byte
    var minus = false
    while (true) {
        b = readByte()
        if(b < 0) break
        if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break

        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
    }

    while (true) {
        if (b >= '0'.toByte() && b <= '9'.toByte()) {
            num = num * 10 + (b - '0'.toByte())
        } else {
            return if (minus) -num else num
        }
        b = readByte()
    }
}

Measured memory_bytes: 31776
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n, m;
    cin >> n >> m;
    if ( n == m){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    char s[51][51];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if (s[i][j] == '.') continue;
            bool Linked = false;
            for (int k = 0; k < 4; k++) {
                int x = i + dx[k];
                int y = j + dy[k];
                if (x < 0 || x >= H) continue;
                if (y < 0 || y >= W) continue;
                if (s[x][y] == '#') Linked = true;
            }
            if (!Linked) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val Ss = List.fill(N)(in.next)
  def formatCount(judge: String): String = s"$judge x ${Ss.count(_ == judge)}"
  println(List("AC", "WA", "TLE", "RE").map(formatCount).mkString("\n"))
}

Measured memory_bytes: 65056
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int a, b;
    cin >> a >> b;
    bool flag = false;
    rep(i, 3) {
        int tmp = a * b * (i+1);
        if (tmp % 2 == 1){
            flag = true;
        }
    }
    if(flag == true){
        print("Yes");
    } else {
        print("No");
    }
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
V = LI()
V.sort()
tmp = V[0]
for v in V:
    tmp = (tmp + v) / 2

print(tmp)

Measured memory_bytes: 38512
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string s,t,u;
	cin >> s >> t;
	map<string, int> m;
	int a, b;
	cin >> a >> b;
	m[s] = a;
	m[t] = b;
	cin >> u;
	m[u] --;
	cout << m[s] << " " << m[t] << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline
h,w=[int(j) for j in input().split()]
a=[]
b=[]
a=[[int(j) for j in input().split()] for i in range(h)]
b=[[int(j) for j in input().split()] for i in range(h)]
x=(h+w)*80
l=2*x+1
dp=[[0]*w for i in range(h)]
dp[0][0]=np.zeros(l,np.bool)
d=abs(a[0][0]-b[0][0])
dp[0][0][x+d]=1
for i in range(h):
    for j,(s,t) in enumerate(zip(a[i],b[i])):
        if i==j==0:
            continue
        d=abs(s-t)
        p=np.zeros(l,np.bool)
        if i!=0:
            p[d:]|=dp[i-1][j][:l-d]
            p[:l-d]|=dp[i-1][j][d:]
        if j!=0:
            p[d:]|=dp[i][j-1][:l-d]
            p[:l-d]|=dp[i][j-1][d:]
        dp[i][j]=p

ans=np.abs(np.where(dp[-1][-1])[0]-x).min()
print(ans)









Measured memory_bytes: 173772
#include<iostream>
using namespace std;
int t,e;

bool solve(int x){
  for(int i=t-e;i<=t+e;i++){
    if(i%x==0)return 1;
  }
  return 0;
}

int main(){
  int n;
  cin>>n;
  int ans=0;
  cin>>t>>e;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(solve(x)){
      ans=i+1;
    }
  }
  if(ans){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 1164