akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int dp1[3001][3000], dp2[3001][3000];

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


	int N, T;
	cin >> N >> T;
	int A[3000], B[3000];
	rep(i, N) cin >> A[i] >> B[i];


	rep(i, N + 1) rep(j, T) dp1[i][j] = -1e9;
	dp1[0][0] = 0;
	rep(i, N) {
		rep(j, T) {
			if (dp1[i][j] >= 0) {
				if (j + A[i] < T) chmax(dp1[i + 1][j + A[i]], dp1[i][j] + B[i]);
				chmax(dp1[i + 1][j], dp1[i][j]);
			}
		}
	}
	rep(i, N + 1) rep(j, T) dp2[i][j] = -1e9;
	dp2[N][0] = 0;
	for (int i = N - 1; i >= 0; i--) {
		rep(j, T) {
			if (dp2[i + 1][j] >= 0) {
				if (j + A[i] < T) chmax(dp2[i][j + A[i]], dp2[i + 1][j] + B[i]);
				chmax(dp2[i][j], dp2[i + 1][j]);
			}
		}
	}

	rep(i, N + 1) rep1(j, T - 1) chmax(dp1[i][j], dp1[i][j - 1]);
	rep(i, N + 1) rep1(j, T - 1) chmax(dp2[i][j], dp2[i][j - 1]);

	int saidai = 0;
	rep(i, N) {
		rep(j, T) {
			chmax(saidai, dp1[i][j] + dp2[i + 1][T - j - 1] + B[i]);
		}
	}
	co(saidai);

	Would you please return 0;
}

Measured memory_bytes: 70656
use utf8;
use strict;
use warnings;
use feature qw/say/;

sub main {
    chomp(my $inp = <>);
    my @s = split(//, $inp);
    say calc(\@s);
}

sub calc {
    my ($s) = @_;
    my @s = @$s;
    for my $i (1..scalar(@s)) {
        if ($i%2 == 1) {
            return 'No' unless ($s[$i-1] =~ /R|U|D/);
        } else {
            return 'No' unless ($s[$i-1] =~ /L|U|D/);
        }
        
    }
    return 'Yes';
}

main();

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

struct edge{
  int t;
  int h;
  int c;
  int r;
};

int main(){
  while(1){
    int n,m,h,k;
    cin >> n >> m >> h >> k;
    if(n==0) return 0;
    vector<list<edge>> e(n);
    int a,b,c,hh,r;
    for(int i=0;i<m;i++){
      cin >> a >> b >> c >> hh >> r;
      e[a-1].push_back({b-1,hh,c,r-1});
      e[b-1].push_back({a-1,hh,c,r-1});
    }
    int s,t;
    cin >> s >> t;
    s--,t--;
    int p;
    cin >> p;
    vector<int> val(1<<k,INF);
    val[0]=0;
    int l,x,d,kk;
    for(int i=0;i<p;i++){
      cin >> l >> d;
      x=0;
      for(int j=0;j<l;j++){
        cin >> kk;
        x|=(1<<(kk-1));
      }
      for(int j=(1<<k)-1;j>=0;j--){
        val[j|x]=min(val[j|x],val[j]+d);
      }
    }
    vector<vector<int>> cost(n,vector<int>(h+1,INF));
    int ans=INF;
    for(int i=0;i<(1<<k);i++){
      for(int j=0;j<n;j++){
        for(int k=0;k<=h;k++) cost[j][k]=INF;
      }
      priority_queue<pair<int,pair<int,int>>> dijk;
      dijk.push({0,{s,0}});
      pair<int,pair<int,int>> now;
      while(!dijk.empty()){
        now=dijk.top();
        dijk.pop();
        if(cost[now.second.first][now.second.second]==INF){
          cost[now.second.first][now.second.second]=-now.first;
          for(auto ee:e[now.second.first]){
            if(now.second.second+ee.h<=h){
              if(cost[ee.t][now.second.second+ee.h]==INF){
                if(i&(1<<ee.r)){
                  dijk.push({now.first,{ee.t,now.second.second+ee.h}});
                }else{
                  dijk.push({now.first-ee.c,{ee.t,now.second.second+ee.h}});
                }
              }
            }
          }
        }
      }
      for(int j=0;j<=h;j++){
        ans=min(ans,val[i]+cost[t][j]);
      }
    }
    if(ans!=INF) cout << ans << endl;
    else cout << -1 << endl;
  }
  return 0;
}



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

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  int ans = 0;

  for (int i = L; i <= R; i++){
    if (i%d == 0){
      ans++;
    }
  }

  cout << ans << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


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

int h, w;
string s[400];
int a[400][400];
int b = 0;
pair<int, int> dyx[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

void bfs(int y, int x) {
  queue<pair<int,int>> q;
  q.push(make_pair(y, x));
  a[y][x] = b;
  while (!q.empty()) {
    int x, y;
    tie(y, x) = q.front();
    q.pop();
    for (auto d: dyx) {
      int ny = y + d.first;
      int nx = x + d.second;
      if (ny < 0 || ny >= h || nx < 0 || nx >= w) {
        continue;
      }
      if (a[ny][nx] > -1) {
        continue;
      }
      if (s[y][x] != s[ny][nx]) {
        a[ny][nx] = b;
        q.push(make_pair(ny, nx));
      }
    }
  }
}
int main() {
  cin>>h>>w;
  for (int i=0; i<h; i++) cin>>s[i];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      a[i][j] = -1;
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (a[i][j] == -1) {
        bfs(i, j);
        ++b;
      }
    }
  }
  map<int, pair<int,int>> cnt;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i][j] == '#') {
        ++cnt[a[i][j]].first;
      } else {
        ++cnt[a[i][j]].second;
      }
    }
  }
  long long ans = 0;
  for (auto e: cnt) {
    ans += 1LL * e.second.first * e.second.second;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n >> m;
    if(m >= n){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[200100],b[200500];
int main()
{
	int n,i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i]-i;
	}
	sort(b+1,b+1+n);
	int tmp=(n+1)/2,minnum=b[tmp];
	long long ans=0;
	for (i=1;i<=n;i++)
	    ans+=abs(minnum-b[i]);
	//cout << minnum << endl;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

using t = long long;

int main() {
    int n,k,c;
    string s;
    cin>>n>>k>>c;
    cin>>s;
    vector<int> l,r;
    for (int i=0; i<n;++i) {
        if (s[i]=='o') {
            if (l.empty() || i-l.back()>c)
                l.push_back(i);
            if ((int)l.size()>=k)
                break;
        }
    }
    for (int i=n-1; i>=0;--i) {
        if (s[i]=='o') {
            if (r.empty() || r.back()-i>c)
                r.push_back(i);
            if ((int)r.size()>=k)
                break;
        }
    }
    for (int i = 0; i<k;++i){
        if (l[i]==r[k-i-1]){
            cout<<l[i]+1<<"\n";
        }
    }
}

Measured memory_bytes: 3448
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    p = list(map(int, input().split())) + [N+1]

    ans = 0
    for i in range(N):
        if p[i] == i+1:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 13876
from collections import deque
S = input()
aaa = list(S)
aaa.reverse()
sss = "".join(aaa)

Q = int(input())
d = deque()
d.append(S)
rev = 1
cnt = 0

for i in range(Q):
  List = list(input().split())
  a = int(List[0])
  if a == 1:
    rev = rev * -1
  else:
    b = int(List[1])
    if (b == 1 and rev == 1) or (b == 2 and rev == -1):
      d.appendleft(List[2])
      cnt = cnt + 1
    else:
      d.append(List[2])

if rev == -1:
  d[cnt] = sss
  d.reverse()
string = "".join(list(d))
print(string)

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

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

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

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

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

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

const int NMAX = 100;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    CIN(N);
    map<char,int> mp;
    rep(i,N){
        char c;cin>>c;
        mp[c]++;
    }
    printf(mp.size()==4?"Four":"Three");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
	int a[3];
	int x,y,z;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);

	y=0;
	while(y<3){
		x=0;
		while(x<3){
			if(a[y]<a[x]){
				z=a[y];
				a[y]=a[x];
				a[x]=z;
			}
			x++;
		}
		y++;
	}

	printf("%d %d %d\n",a[0],a[1],a[2]);


	return 0;
}

Measured memory_bytes: 596
$n,$m,$q = gets.split.map(&:to_i)
$x = []
$q.times do
   $x << gets.split.map(&:to_i)
end

$ans = 0

def check(arr)
  pt = 0
  $x.each do |a,b,c,d|
    pt += d if arr[b-1] - arr[a-1] == c
  end
  $ans = [$ans, pt].max
end

def dfs(cur,last)
  if cur.size == $n
    check(cur)
  else
    last.upto($m) do |i|
      dfs(cur + [i], i)
    end
  end
end

1.upto($m) do |i|
  dfs([i], i)
end

p $ans

Measured memory_bytes: 14472
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int[] p=new int[m];
		String[] s=new String[m];
		for(int i=0; i<m; i++){
			p[i]=sc.nextInt()-1;
			s[i]=sc.next();
		}
		int t=0;
		int f=0;
		boolean[] tf=new boolean[n];
		int[] countf=new int[n];
		for(int i=m-1; i>=0; i--){
			if(s[i].equals("AC")){
			if(!tf[p[i]]){
				tf[p[i]]=true;
				t++;
				}else{
					countf[p[i]]=0;
				}
			}else if(tf[p[i]] && s[i].equals("WA")){
				countf[p[i]]++;
			}
		}
		for(int i=0; i<n; i++){
			f+=countf[i];
		}
		System.out.println(t+" "+f);
	}	
}


Measured memory_bytes: 70632
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;


vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}


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

    vector<vector<int> > next = calcNext(S);

    vector<vector<ll>> dp(n+1, vector<ll>(5,0));
    dp[0][0] = 1; 
  
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
          for(int k = 0; k <= 3; k++){
            if (next[i][j] >= n){continue;}
            dp[next[i][j] + 1][k+1] += dp[i][k];
          }
        }
    }

    ll res = 0;
  
    for (int i = 0; i <= n; ++i){ res += dp[i][3];}

    cout << res << endl;
}


Measured memory_bytes: 4480
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      // スペース区切りの整数の入力
      string s = Console.ReadLine();
      int c = 0;
      for(int i = 0; i < s.Length; i++)
        if(s[i] == '1')
          c++;
      Console.WriteLine(c);
    }

  }
}

Measured memory_bytes: 25820
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll ans=0;
	REP(i,n) {
		auto ite1=lower_bound(ALL(a),b[i]);
		auto ite2=upper_bound(ALL(c),b[i]);
		ans+=(ll)(ite1-a.begin())*(ll)(n-(ite2-c.begin()));
	}
	cout<<ans<<endl;
}


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

ll ans, n, x, y, d;

int main() {
  cin >> n >> d;
  ans = 0;
  rep (i, n) {
    cin >> x >> y;
    if (x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int r,g,b;
  cin >> r >> g >> b;

  if((100*r + 10*g +b) % 4 == 0)
    cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3556
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2e5 + 7;
int n, c, a[N], dp[N];

struct line {
    int k = 0, b = 0;
    line(int k, int b) {
        this -> k = k;
        this -> b = b;
    }
    db intersect(const line & l) const {
        return (db)(l.b - b) / (k - l.k);
    }
    bool del(const line & l1, const line & l2) const {
        return intersect(l2) > l1.intersect(l2);
    }
    int val(int x) {
        return k * x + b;
    }
};

vector <line> h;

void add(line l) {
    while (h.size() > 1 && l.del(h[sz(h) - 1], h[sz(h) - 2])) {
        h.ppb();
    }
    h.pb(l);
}

int getmin(int x) {
    if (h.empty()) {
        return 0;
    }
    int l = 0, r = sz(h) - 1;
    while (l < r) {
        int mid = l + r >> 1;
        if (h[mid].val(x) > h[mid + 1].val(x)) {
            l = mid + 1;
        }   else {
            r = mid;
        }
    }
    return h[l].val(x);
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> c;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[1] = 0;
    add(line(a[1], dp[1] + a[1] * a[1]));
    for (int i = 2; i <= n; i++) {
        int tmp = a[i] * a[i] + c;
        dp[i] = getmin(-2 * a[i]) + tmp;
        add(line(a[i], dp[i] + a[i] * a[i]));
    }
    cout << dp[n];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 9200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n + 2];
            int total = 0;
            for (int i = 1; i <= n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n + 1; i++) {
                total += Math.abs(a[i] - a[i + 1]);
            }
            for (int i = 1; i < n + 1; i++) {
                int ans = 0;

                ans = total + Math.abs(a[i - 1] - a[i + 1]) - Math.abs(a[i] - a[i + 1]) - Math.abs(a[i - 1] - a[i]);
                // 出力
                out.println(ans);
            }


        }

    }
}



Measured memory_bytes: 59084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const long INF = 1e10 + 1;
const long MOD = 1e9 + 7;
const long dx[] = {1, -1, 0, 0};
const long dy[] = {0, 0, 1, -1};
typedef long long ll;
using namespace std;
long func(long i, long j)
{
	long a = 0, b = 0;
	while(i > 0)
	{
		i /= 10;
		a++;
	}
	while(j > 0)
	{
		j /= 10;
		b++;
	}
	return max(a, b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long n;
	cin >> n;
	long j;
	long ans = INF;
	for(long i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			j = n / i;
			long tmp = func(i, j);
			if(tmp < ans)
				ans = tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a ^ b) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
int a[N],b[N],c[N];
int main()
{
    int i,j,k,n,l,r,mid,p1,p2;
    long long s;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&b[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&c[i]);
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    sort(c+1,c+1+n);
    s=0;
    for(i=1;i<=n;i++)
    {
        if(b[i]<=a[1])
        continue;
        if(b[i]>=c[n])
        continue;
        p1=1;
        l=1;
        r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(a[mid]<b[i])
            {
                p1=max(p1,mid);
                l=mid+1;
            }
            else
            r=mid-1;
        }
        p2=n;
        l=1;
        r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(c[mid]>b[i])
            {
                p2=min(p2,mid);
                r=mid-1;
            }
            else
            l=mid+1;
        }
        s=s+(long long)p1*(n-p2+1);
    }
    printf("%lld\n",s);
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

char c[13][13];

void saiki(int x, int y){
	c[x][y] = '0';
	if(x > 0){
		if(c[x - 1][y] == '1'){
			saiki(x - 1, y);
		}
	}
	if(x < 11){
		if(c[x + 1][y] == '1'){
			saiki(x + 1, y);
		}
	}
	if(y > 0){
		if(c[x][y - 1] == '1'){
			saiki(x, y - 1);
		}
	}
	if(y < 11){
		if(c[x][y + 1] == '1'){
			saiki(x, y + 1);
		}
	}
}

int main(void)
{
	int ans;
	while(scanf("%s", c[0]) != EOF){
		for(int i = 1; i < 12; i++){
			scanf("%s", c[i]);
		}
		ans = 0;
		for(int i = 0; i < 12; i++){
			for(int j = 0; j < 12; j++){
				if(c[i][j] == '1'){
					ans++;
					saiki(i, j);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 976
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

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; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

template<typename F>
struct FixPoint : F {
  FixPoint(F&& f) :F(forward<F>(f)) {}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f) {
  return FixPoint<F>{forward<F>(f)};
}
// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M, Q;
  cin >> N >> M >> Q;

  vector<int> a(Q), b(Q), c(Q), d(Q);
  F0R(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }

  auto calc = [&](const vector<int>& ns)->int {
    int score = 0;
    F0R(i, Q) {
      if (ns[b[i]] - ns[a[i]] == c[i]) {
        score += d[i];
      }
    }
    return score;
  };

  vector<int> ns(N, 1);
  int result = 0;
  while (true) {
    chmax(result, calc(ns));

    int i = N - 1;
    while (i >= 0 && ++ns[i] > M) {
      --i;
    }
    if (i < 0) break;
    while (i < N - 1) {
      ns[i + 1] = ns[i];
      i++;
    }
  }
  cout << result;
}
#endif


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

using namespace std;

#define int long long

int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int a = 1; a <= n; ++a)
    {
        for (int b = 1; b <= n; ++b)
        {
            for (int c = 1; c <= n; ++c)
            {
                int g = gcd(a, b);
                ans += gcd(g, c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
coo_dis = [int(input()) for i in range(6)]
a = coo_dis[0]
b = coo_dis[1]
c = coo_dis[2]
d = coo_dis[3]
e = coo_dis[4]
k = coo_dis[5]
if (b - a) and (c - a) and (d - a) and (e - a) <= k:
    if (c - b) and (d - b) and (e - b) <= k:
        if (d - c) and (e - c) <= k:
            if (e - c) <= k:
                print("Yay!")
            else:
                print(":(")
        else:
            print(":(")
    else:
        print(":(")
else:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int a[3];
  int res=0;
  rep(i,3) cin >> a[i];

  sort(a,a+3);
  rep(i,3){
    a[i]-=a[2];
  }

  while(a[0]!=0 && a[1]!=0){
    a[0]++;
    a[1]++;
    res++;
  }
  sort(a,a+3);
  while(a[0]<0){
    a[0]+=2;
    res++;
  }
  if(a[0]==1) res++;

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++) 
int main()
{
    ll t;
    t = 1;
    while(t--)
    {
    	ll i,n,b,x=0,t;
		cin>>n;
		ll arr[n];
		ff(i,n)
			cin>>arr[i];
		for(i=1;i<n;i++)
		{
			if(arr[i-1]>arr[i])
			{
				x += (arr[i-1]-arr[i]);
				arr[i] = arr[i-1];
			}
		}	
		cout<<x;			    
    }
    return 0;
} 

Measured memory_bytes: 5196
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, T; cin >> n >> T;
    vi t(n); for(auto& e : t) cin >> e;
    t.emplace_back(t.back() + T);

    int res = 0;
    rep(i, n){
        res += min(T, t[i+1] - t[i]);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	for(int i = 1;i <= 3500;i++) {
      	bool A = true;
		for(int j = 1;j <= 3500;j++) {
          	int K = 4 * i * j - N * (i + j);
			if(K != 0 && ((N * i * j) / K) * K == N * i * j && (N * i * j) / K > 0) {
				cout << i << " " << j << " " << (N * i * j) / K << endl;
              	A = false;
				break;
			}
		}
      	if(A == false) {
          	break;
        }
	}
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
bool ch[51][51];
int h, w;

void dfs(vector<vector<bool>> mp, int i, int j){
  //prt3("--->", i, j);
  ch[i][j] = true;
  bool up=true, down=true, left=true, right=true;

  if(i==0) up=false;
  if(i==h-1) down=false;
  if(j==0) left=false;
  if(j==w-1) right=false;

  if(up && left){if(mp[i-1][j-1] && !ch[i-1][j-1]) dfs(mp, i-1, j-1);}
  if(up) {if(mp[i-1][j] && !ch[i-1][j]) dfs(mp, i-1, j);}
  if(up && right) {if(mp[i-1][j+1] && !ch[i-1][j+1]) dfs(mp, i-1, j+1);}
  if(left) {if(mp[i][j-1] && !ch[i][j-1]) dfs(mp, i, j-1);}
  if(right) {if(mp[i][j+1] && !ch[i][j+1]) dfs(mp, i, j+1);}
  if(down && left) {if(mp[i+1][j-1] && !ch[i+1][j-1]) dfs(mp, i+1, j-1);}
  if(down) {if(mp[i+1][j] && !ch[i+1][j]) dfs(mp, i+1, j);}
  if(down && right) {if(mp[i+1][j+1] && !ch[i+1][j+1]) dfs(mp, i+1, j+1);}
}

int main(void) {
  while(1){
    rep(i,51){
      rep(j,51){
        ch[i][j]=false;
      }
    }
    cin >> w >> h;

    if(w==0 && h==0){break;}
    vector<vector<bool>> mp(h, vector<bool>(w, false));
    rep(i,h){
      rep(j,w){
        int tmp;
        cin >> tmp;
        mp[i][j] = (tmp>0 ? true : false);
      }
    }

    int ans=0;
    rep(i,h){
      rep(j,w){
        if(!ch[i][j] && mp[i][j]){
          ans++;
          dfs(mp, i, j);
        }
      }
    }
    prt(ans);
  }
}



Measured memory_bytes: 12084
#include <iostream>
#include <vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#define ff(i,m,n) for(int i=m;i<n;i++)
#define i64 int64_t
using namespace std;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a <= b) {
		cout << a * c << endl;
		return 0;
	}
	cout << b * c + (a-b) * d << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main (void)
 
 
{
 
 
int a,b,c,i;
 
 
int count=0;
 
 
scanf("%d %d %d",&a,&b,&c);
 
 
for(i=a;i<=b;i++){
 
 
if(c%i==0) count++;
 
 
}
 
 
printf("%d\n",count);
 
 
return 0;
 
 
}
 

Measured memory_bytes: 596
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 998244353
a = [tuple(map(int, input().split())) for _ in range(K)]
dp = [0] * (N + 1)
dp[1] = 1
imos = [0] * (N + 1)
for i in range(1, N):
  dp[i] += imos[i]
  dp[i] %= mod
  for l, r in a:
    if i + l > N: continue
    imos[i + l] += dp[i]
    imos[i + l] %= mod
    if i + r + 1 > N: continue
    imos[i + r + 1] -= dp[i]
    imos[i + r + 1] %= mod
  imos[i + 1] += imos[i]
  imos[i + 1] %= mod
dp[-1] += imos[-1]
dp[-1] %= mod
print(dp[-1])

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

//////////////////////////// templejt /////////////////////////////////

// krotsze nazwy dlugich typow

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

// rzeczy z io

#define endl "\n";
#define newio() ios_base::sync_with_stdio(false); cout.tie(NULL); cerr.tie(NULL); cin.tie(NULL)
#define precision(x) cout << fixed << setprecision(x)

// kontenery, które często używam

// pary
#define PR pair
#define PII PR<int, int>
#define fi first
#define se second
#define mp make_pair

// wektory
#define VEC vector
#define VL VEC<ll>
#define VI VEC<int>
#define VPI VEC<PII>
#define pb emplace_back
#define rb pop_back
#define bk back()
#define ft front()

// sety
#define SI set<int>
#define SL set<ll>

// mapy
#define umap unordered_map
#define MII map<int, int>
#define MLI map<ll, int>
#define MIL map<int, ll>
#define MSI map<string, int>
#define UMII umap<int, int>
#define UMLI umap<ll, int>
#define UMIL umap<int, ll>
#define UMIS umap<int, string>

// pętle

#define rep(N) for(auto i = 0; i < N; ++i)
#define repp(I, N) for(auto i = I; i < N; ++i)

#define repi(N) for(auto i = N - 1; i >= 0; --i)
#define reppi(I, N) for(auto i = N - 1; i >= I; --i)

#define repk(K) for(auto &v : K)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)

// funkcje do kontenerów

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

template<class T>
ostream &operator<<(ostream& os, vector<T> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T>
ostream &operator<<(ostream& os, set<T> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T, class Y>
ostream &operator<<(ostream& os, map<T, Y> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T, class Y>
ostream &operator<<(ostream& os, umap<T, Y> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

// debugowanie

#define _DEV // usuń to przed wysłaniem
#ifdef _DEV
    #define debug(x) { cerr << #x << " == " << x << endl; }
#else
    #define debug(x)
#endif

// kilka liczb pierwszych

VL primes = {
    7, 17, 33, 257, 65537, 1000000007, 1000000009
//  0,  1,  2,   3,     4,          5,          6
};

///////////////////////////////////////////////////////////////////////


int N;
int a;

VI tasks;


int main() {
    newio();

    rep(3) {
        cin >> a;
        tasks.pb(a);
    }
    sort(all(tasks));

    int min_cost = 1e9;
    do {
        int cost = 0;
        rep(2)
            cost += abs(tasks[i] - tasks[i + 1]);

        min_cost = min(min_cost, cost);
    } while(next_permutation(all(tasks)));


    cout << min_cost << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int a, b, op;
	int ans;	
	
	while (1) {
		
		scanf("%d %c %d", &a, &op, &b);
		
		if (op == '?') {
			break;
		}
		
		else if(op == '+'){
			ans = a + b;
		}

		else if (op == '-') {
			ans = a - b;
		}
		else if (op == '*') {
			ans = a * b;
		}

		else if(op == '/') {
			ans = a / b;
		}
		
		printf("%d\n", ans);
		
	}

	


	return(0);

}


Measured memory_bytes: 2044
# Jasmine_ss's code modified by centipede_human

using DataStructures
parseline(str) = parse.(Int, split(str))
function WizardInMaze()
    data = readlines()
    H, W = parseline(data[1])
    start = parseline(data[2])
    goal = parseline(data[3])
    S = zeros(Int, H, W)
    for h in 1:H
        S[h, :] = [d=='.' ? 0 : 1 for d in data[3+h]]
    end
    queue = Deque{Vector{Int}}()
    push!(queue, start)
    que_dist = Deque{Int}()
    push!(que_dist, 0)
    inf = typemax(Int)
    cost = fill(inf, H, W)
    cost[start[1], start[2]] = 0
    direction_walk = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    direction_warp = [[i, j] for i in -2:2, j in -2:2 if [i, j]≠[0,0] && [i, j]∉direction_walk]
    while !isempty(queue)
        node = popfirst!(queue)
        now = popfirst!(que_dist)
        now > cost[node[1], node[2]] && continue
        for edge in 0:1
            Wa = edge==0 ? direction_walk : direction_warp
            for d in Wa
                h, w = node + d
                !(1≤h≤H) && (h = min(max(h, 1), H))
                !(1≤w≤W) && (w = min(max(w, 1), W))
                next_cost = cost[node[1], node[2]] + edge
                S[h, w]≡0 && (cost[h, w] > next_cost) && (
                    edge==0 ? (pushfirst!(queue, [h, w]);pushfirst!(que_dist, next_cost)) : (push!(queue, [h, w]);push!(que_dist, next_cost)); 
                    cost[h, w] = next_cost
                )
            end
        end
    end
    ans = cost[goal[1], goal[2]]==inf ? -1 : cost[goal[1], goal[2]]
    println(ans)
end
WizardInMaze()


Measured memory_bytes: 285720
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    ll a,b;cin>>a>>b;
    if(500*a>=b)cout<<"Yes\n";
    else cout<<"No\n";
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 51000100
using namespace std;
inline bool cmp ( int x , int y ) {
    return x > y;
}
int main()
{
    int a[5];
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    sort ( a+1,a+4,cmp);
    int ans = a[1]*10+a[2]+a[3];
    printf("%d\n",ans);
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (S.substr(S.size() / 2) == S.substr(0,S.size() / 2)) {
    cout << "Yes" <<endl;
  }  
  else {
    cout << "No" <<endl;
  }  
  
  
}


Measured memory_bytes: 256
def check(pairs, N):
    games = set()
    for p1, p2 in pairs:
        l = abs(p2 - p1) - 1
        r = N - l - 2
        if l > r:
            l, r = r, l
        if (l, r) in games:
            return False
        games.add((l, r))
    return True


def main() -> None:
    N, M = map(int, input().split())
    left, right = (1, M + 1), (M + 2, M + M + 1)
    ans = []
    for i in range(M):
        if i % 2 == 0:
            ans.append(left)
            left = (left[0] + 1, left[1] - 1)
        else:
            ans.append(right)
            right = (right[0] + 1, right[1] - 1)
    # print(ans)
    # assert check(ans, N)
    for p in ans:
        print(*p)


if __name__ == '__main__':
    main()


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> ai(n, 0);
  rep(i, n) {
    cin >> ai[i];
  }
  std::sort(ai.begin(), ai.end());
  int total= 0;
  rep(i, k) {
    total += ai[i];
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 3628
require 'matrix'

$stdin = DATA if $stdin.eof?

gets
ARGF.each_line do |line|
  x1, y1, x2, y2, x3, y3 = line.split.map(&:to_r)
  a = Vector[x1, y1]
  b = Vector[x2, y2]
  c = Vector[x3, y3]

  ab = b - a
  bc = c - b
  ca = a - c

  ar = bc.r
  br = ca.r
  cr = ab.r

  as = ar**2
  bs = br**2
  cs = cr**2

  q1 = (as * (bs + cs - as) * a + bs * (as + cs - bs) * b + cs * (as + bs - cs) * c)
  q2 = 2 * (as * bs + bs * cs + cs * as) - (as**2 + bs**2 + cs**2)
  rcc =  q1 / q2

  s1 = ar * br * cr
  s2 = Math.sqrt((ar + br + cr) * (-ar + br + cr) * (ar - br + cr) * (ar + br - cr))
  r = s1 / s2

  puts [*rcc.to_a, r].map{|e| format("%.3f", e) }.join("\s")
end

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int N,C;
    cin >> N >> C;
    vector< vector<int> > D( C, vector<int>(C) );
    vector< vector<int> > c( N, vector<int>(N) );
    for ( int i = 0; i < C; i++ ) {
    for ( int j = 0; j < C; j++ ) {
        cin >> D[i][j];
    }
    }
    for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
        cin >> c[i][j];
        c[i][j]--;
    }
    }

    vector< vector<int> > CS( 3, vector<int>(C,0) );

    for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
        CS[ (i+j)%3 ][ c[i][j] ]++;
    }
    }

    long long ans = LLONG_MAX;
    for ( int i = 0; i < C; i++ ) {
    for ( int j = 0; j < C; j++ ) {
    for ( int k = 0; k < C; k++ ) {
        
        if ( i == j || j == k || k == i ) { continue; }

        long long cost = 0;
        for ( int x = 0; x < C; x++ ) {
            cost += D[x][i] * CS[0][x];
        }
        for ( int x = 0; x < C; x++ ) {
            cost += D[x][j] * CS[1][x];
        }
        for ( int x = 0; x < C; x++ ) {
            cost += D[x][k] * CS[2][x];
        }
        ans = min( ans, cost );

    }
    }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
while (n1 = gets.to_i) != 0
  h = Hash.new
  n1.times do
    c1, c2 = gets.split(' ')
    h[c1] = c2
  end
  n2 = gets.to_i
  str = ''
  n2.times do
    c = gets.chomp!
    c = h[c] if h[c]
    str << c
  end
  puts str
end

Measured memory_bytes: 2888
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;

void solve()
{ long long int a=-1,b=-1,c=-1,n,l,r,m,k,i,j,ans=0,ans1,ans2;
  cin>>n;
  ll dp[n][3],v[n][3];
  for(i=0;i<n;i++)
  {
    cin>>a>>b>>c;
    v[i][0]=a;
    v[i][1]=b;
    v[i][2]=c;
  }
  for(i=n-1;i>=0;i--)
  {
    if(i==n-1)
    {
      dp[i][0]=v[i][0];
      dp[i][1]=v[i][1];
      dp[i][2]=v[i][2];
      continue;
    }
    dp[i][0]=max(dp[i+1][1],dp[i+1][2])+v[i][0];
    dp[i][1]=max(dp[i+1][0],dp[i+1][2])+v[i][1];
    dp[i][2]=max(dp[i+1][1],dp[i+1][0])+v[i][2];

  }
  cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
  
}
             
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
       


Measured memory_bytes: 8172