akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1e9 + 7;
const int MAX_N = 1000005;
int fact[MAX_N];
int fact_inv[MAX_N];
int bin_pow_mod(int x, int y) {
      if (x == 0) return 0;
      int prod=1;
      while(y>0) {
          if (y & 1) prod = (prod * x) % MOD;
          x = (x * x) % MOD;
          y >>= 1;
      }
      return prod % MOD;
}
struct init_fact {
    init_fact() {
        fact[0] = 1, fact_inv[0] = 1;
        for (int i = 1; i < MAX_N; ++i) {
            fact[i] = (fact[i - 1] * i) % MOD;
            fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
        }
    }
} init_fact;
int combination(int n, int r) {
    return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}
signed main() {
    int n;
    cin >> n;
    int ans = 0, pre = 0;
    REP(i, n) {
        if (i - 1 >= n - 1 -i) {
            int tmp = combination(i - 1, n - 1 -i) * fact[i] % MOD * fact[n - 1 - i] % MOD;
            ans += i * ((tmp - pre + MOD) % MOD) % MOD;
            ans %= MOD;
            pre = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15872
s = int(input())
count1=-1
count2=-1
while s>=0:
 s=s-500
 count1=count1 +1
s=s+500
if s==0:
  yasashisa=count1*1000
  print(yasashisa)
else:
   while s >=0:
     s=s-5
     count2=count2 +1
   yasashisa=count1*1000+count2* 5
   print(yasashisa)





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int a,b,c; cin>>a>>b>>c;
	swap(a,b); swap(a,c);
	cout<<a<<' '<<b<<' '<<c;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d1,d2;
  int count=0;
  for(int i=0 ; i<N ; i++){
  	  cin >> d1 >> d2;
    if(d1==d2){
      count++;
    }else{
      count=0;
    }
    if(count==3)break;
  }
  if(count!=3){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    map<char,int> m;
    rep(i,n) m[s[i]]++;
    bool flag = true;
    for(char c = 'a'; c <= 'z'; ++c) if(m[c] % 2) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    
	char c;
	cin >> c;
	
	if (c >= 'A' && c<= 'Z')
            cout << "A" << endl;
    else
            
            cout << "a" << endl;
}


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    if(a < 6) cout << 0 << endl;
    else if(a >= 6 && a <= 12) cout << b / 2 << endl;
    else cout << b << endl;
}

/**
*/


Measured memory_bytes: 256
s = input()

count = 0
ans = [0]
for i in range(len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        count += 1
        if i == (len(s)-1):
            ans.append(count)
        
    else:
        ans.append(count)
        count = 0
print(max(ans))


Measured memory_bytes: 38384
#include<iostream>
using namespace std;
long long a[100005];
long long xabs(long long x){
	if(x>=0) return x;
	else return x*-1;
}
int main()
{
	int n,i,t=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<0) t++; 
	}
	
	long long ans=0;
	if(t%2==0){
		for(i=1;i<=n;i++)
			ans+=xabs(a[i]);
		cout<<ans;
	}
	else{
		long long minv=0x7ffffffff;
		for(i=1;i<=n;i++){
			ans+=xabs(a[i]);minv=min(minv,xabs(a[i]));
		}
		cout<<ans-minv*2;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<string>
#include <iostream>

using namespace std;

int main(void) {
	while (1){

		int a = 0, b = 0;
		string op;
		cin >> a >> op >> b;
		
		if (op == "?"){ break; }
		else if (op == "+"){ 
			cout << a + b << endl; 
		}
		else if (op == "-"){
			cout << a - b << endl;
		}
		else if (op == "*"){
			cout << a * b << endl;
		}
		else if (op == "/"){
			cout << a / b << endl;
		}


	
		
		
	}

	
	//system("pause");
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

const int N = 188;
const int MAX = 16;
int a[N][N];
unsigned char d[N][N][N][MAX + 1];

const int DEBUG = 0;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n = 186, m = 186;
  if (!DEBUG) cin >> n >> m;
  vs s(n, string(m, '.'));
  for (int i = 0; i < n; ++i) {
    if (!DEBUG) cin >> s[i];
    else for (int j = 0; j < m; ++j) s[i][j] = rand() % 2 ? '#' : '.';
    for (int j = 0; j < m; ++j) {
      a[i][j] = s[i][j] == '#';
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int c = 0; c < m; ++c) {
      for (int t = 0; t <= MAX; ++t) {
        d[i][i][c][t] = m;
      }
    }
  }
  vvi sum(m, vi(n + 1));
  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      sum[j][i + 1] = sum[j][i] + a[i][j];
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int c = m - 1; c >= 0; --c) {
        int cnt1 = sum[c][j] - sum[c][i];
//        cerr << cnt1 << endl;
        if (cnt1 != 0 && cnt1 != j - i) {
          d[i][j][c][0] = c;
        } else {
          d[i][j][c][0] = c + 1;
          if (c + 1 < m && a[i][c] == a[i][c + 1]) {
            d[i][j][c][0] = d[i][j][c + 1][0];
          }
        }
        d[i][j][c][MAX] = m;
        for (int t = 1; t < MAX; ++t) {
          d[i][j][c][t] = d[i][j][c][t - 1];
          if (d[i][j][c][t - 1] < m) {
            d[i][j][c][t] = d[i][j][d[i][j][c][t - 1]][t - 1];
          }
          int l = i, r = j;
          while (r - l > 1) {
            int mid = (l + r) / 2;
            if (d[i][mid][c][t - 1] > d[mid][j][c][t - 1]) {
              l = mid;
            } else {
              r = mid;
            }
          }
          d[i][j][c][t] = max(d[i][j][c][t], d[l][j][c][t - 1]);
          if (l + 1 <= j) {
            d[i][j][c][t] = max(d[i][j][c][t], d[i][l + 1][c][t - 1]);
          }
        }
        /*for (int t = 0; t <= MAX; ++t) {
          cerr << i << ' ' << j << ' ' << c << ' ' << t << ' ' << (int)d[i][j][c][t] << endl;
        }*/
      }
    }
  } 
  for (int t = 0; t <= MAX; ++t) {
//    cerr << t << ' ' << (int)d[0][n][0][t] << endl;
    if (d[0][n][0][t] >= m) {
      cout << t << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 109184
n, k = map(int, input().split())
p = [tuple(map(int, input().split())) for _ in range(n)]
xlist = []
ylist = []
for x, y in p:
    xlist.append(x)
    ylist.append(y)
xlist.sort()
ylist.sort()
cum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + ((xlist[i], ylist[j]) in p)
minarea = 10 ** 20
for l in range(n-1):
    for r in range(l+2, n+1):
        for u in range(n-1):
            for d in range(u+2, n+1):
                point = cum[r][d] - cum[l][d] - cum[r][u] + cum[l][u]
                if point == k:
                    minarea = min(minarea, (xlist[r-1] - xlist[l]) * (ylist[d-1] - ylist[u]))
print(minarea)

Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let y: usize = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let squares: Vec<Vec<char>> = (0..y)
        .map(|_| {
            let str: String = iter.next().unwrap().parse().unwrap();
            str.chars().collect::<Vec<char>>()
        })
        .collect();

    let mut result: Vec<Vec<char>> = Vec::new();
    for (i, line) in squares.iter().enumerate() {
        let mut result_line: Vec<char> = Vec::new();
        for (j, &square) in line.iter().enumerate() {
            let mut count = 0;
            if square == '#' {
                result_line.push('#');
                continue;
            }
            count += check_count(&squares[i], j, x);
            if i != 0 {
                count += check_count(&squares[i - 1], j, x);
            }
            if i < y - 1 {
                count += check_count(&squares[i + 1], j, x);
            }
            result_line.push(std::char::from_digit(count, 10).unwrap());
        }
        result.push(result_line);
    }

    /*result
    .iter()
    .map(|line| line.iter().collect::<String>())
    .for_each(|line| println!("{}", line));*/
    for line in result {
        for word in line {
            print!("{}", word);
        }
        print!("\n");
    }
}

fn check_count(line: &Vec<char>, current_index: usize, line_length: usize) -> u32 {
    let mut count = 0;
    if current_index != 0 {
        if line[current_index - 1] == '#' {
            count += 1;
        }
    }
    if line[current_index] == '#' {
        count += 1;
    }
    if current_index < line_length - 1 {
        if line[current_index + 1] == '#' {
            count += 1;
        }
    };
    count
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 10;
pair<ll, ll> p[maxn];
ll par[maxn];
ll s[maxn];
ll sum;
ll ans[maxn];
ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }
int main() {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= n; i++) {
    par[i] = i;
    s[i] = 1;
    }
    for (int i = 0; i < m; i++) {
    scanf("%lld%lld", &p[i].first, &p[i].second);
    }
    sum = 1LL * n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; i--) {
    ans[i] = sum;
    int x = find(p[i].first), y = find(p[i].second);
    if (x != y) {
    par[y] = x;
    sum -= s[x] * s[y];
    s[x] += s[y];
    }
    }
    for (int i = 0; i < m; i++) printf("%lld\n", ans[i]); 
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define MAX_V 30000
#define INF 1e9

struct edge{
    int to, cap, rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

int dfs(int v, int t, int f){
    if (v==t) return f;
    used[v] = 1;
    REP(i,G[v].size()){
        edge &e = G[v][i];
        if (!used[e.to] && e.cap>0){
            int d = dfs(e.to, t, min(f, e.cap));
            if (d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f==0) return flow;
        flow += f;
    }
}

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    int si, sj, gi, gj;
    REP(i,h) REP(j,w){
        if (s[i][j] == 'S'){
            si = i;
            sj = j;
        }
        if (s[i][j] == 'T'){
            gi = i;
            gj = j;
        }
    }
    if (si == gi || sj == gj){
        cout << -1 << endl;
        return 0;
    }
    int start = 20010, goal = 20011;
    VI x, y;
    REP(i,h) REP(j,w){
        if (s[i][j] == 'o'){
            x.push_back(i);
            y.push_back(j);
        }
    }

    int n = x.size();
    REP(i,n) add_edge(i,i+n,1);
    REP(i,n){
        if (x[i] == si || y[i] == sj) add_edge(start,i,INF);
        if (x[i] == gi || y[i] == gj) add_edge(i+n,goal,INF);
    }

    REP(i,n) REP(j,n){
        if (i == j) continue;
        if (x[i] == x[j] || y[i] == y[j]) add_edge(i+n,j,INF);
    }

    cout << max_flow(start, goal) << endl;

    return 0;
}

Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
inline int lowbit(int x) { return (x & (-x));}
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;
int n;
ll a[maxn];
ll check(int x)
{
	ll ret = 0;
	for(int i = 1; i <= n; ++i) ret += (a[i] - x) * (a[i] - x);
	return ret;
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	ll ans = check(1);
	for(int i = 2; i <= 100; ++i)
		ans = min(ans, check(i)); 
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

   // cin>>testCase;
    while(testCase--) {
        string a,b;
        cin>>a;
        b=a;
        int cnt1=0,cnt2=0;
        for(int i=1; i<a.size(); i++){
            if(a[i]==a[i-1]){
                cnt1++;
                if(a[i-1]=='0') a[i]='1';
                else a[i]='0';
            }
        }
        reverse(all(b));
        for(int i=1; i<b.size(); i++){
            if(b[i]==b[i-1]){
                cnt2++;
                if(b[i-1]=='0') b[i]='1';
                else b[i]='0';
            }
        }
        cout<<min(cnt1,cnt2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Point2D p = new Point2D.Double(0, 0);
        Point2D r = new Point2D.Double(100,0);
        System.out.printf("%.8f %.8f\n",p.getX(),p.getY());
        curve(n, p, r);
        System.out.printf("%.8f %.8f",r.getX(),r.getY());
    }
    private static void curve(int n, Point2D a, Point2D b) {
        if (n > 0) {
            Point2D s = new Point2D.Double();
            Point2D t = new Point2D.Double();
            Point2D u = new Point2D.Double();
            double th = (Math.PI / 180) * 60;
            s.setLocation(((2.0 * a.getX() + 1.0 * b.getX()) / 3.0), ((2.0 * a.getY() + 1.0 * b.getY()) / 3.0));
            t.setLocation(((1.0 * a.getX() + 2.0 * b.getX()) / 3.0), ((1.0 * a.getY() + 2.0 * b.getY()) / 3.0));
            u.setLocation(((t.getX() - s.getX()) * Math.cos(th) - (t.getY() - s.getY()) * Math.sin(th) + s.getX()),
                    ((t.getX() - s.getX()) * Math.sin(th) + (t.getY() - s.getY()) * Math.cos(th) + s.getY()));
            curve(n - 1, a, s);
            System.out.printf("%.8f %.8f\n",s.getX(),s.getY());
            curve(n - 1, s, u);
            System.out.printf("%.8f %.8f\n",u.getX(),u.getY());
            curve(n - 1, u, t);
            System.out.printf("%.8f %.8f\n",t.getX(),t.getY());
            curve(n - 1, t, b);
        }
    }
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, b, c;
    string s,t;
    // cin >> a >> b >> c;
    cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << "\n";
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    clock_t start = clock();
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);

    rep(i, D) {
        ll r = rand() % 26;
        T[i] = r + 1;
    }
    vector<ll> last(26, 0);

    ll sum = 0;
    auto f = [&] {
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(i, 26) {
                sum -= C[i] * ((d + 1) - last[i]);
            }
        }
        return sum;
    };
    ll ans = -INF;
    clock_t end = clock();
    double time = (end - start) / 1000;
    while (time <= 1950) {
        vector<pair<ll, P>> change(10);
        rep(j, 10) {
            ll r = rand() % 26;
            r++;
            ll d = rand() % 365;
            ll old = T[d];
            T[d] = r;
            change[j] = {d, {old, r}};
        }
        ll res = f();
        if (res > ans) {
            ans = res;
        } else {
            rep(j, 10) {
                ll d = change[j].first;
                T[d] = change[j].second.first;
            }
        }
        // cout << ans << '\n';
        end = clock();
        time = (end - start) / 1000;
    }
    // cout << time << '\n';
    rep(d, D) {
        cout << T[d] << '\n';
    }
}

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


Measured memory_bytes: 3788
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, i, t = 0, h = 0;
	cin >> n;

	string tw, hw;
	for( i = 0; i < n; ++i){
		cin >> tw >> hw;
		if( tw > hw ) t += 3;
		else if( tw < hw ) h += 3;
		else{
			t += 1;
			h += 1;
		}
	}

	cout << t << " " << h << "\n";

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<string>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int kosuu = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1])kosuu++;
	}
	cout << kosuu+1 << endl;
}


Measured memory_bytes: 9424
#include <stdio.h>
#include <stdlib.h>
main(){
  int i,j,k=0,l=0,a=0,b=0;
  char ch;
  char str1[200]="",str2[200],str3[200],str4[200];
  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%s %s",str1,str2);
    for(k=0;;k++){
      if(str1[k]=='\0'&&str2[k]=='\0'){
        a+=1;
        b+=1;
        break;
      }
      if(str1[k]==str2[k])
        continue;
      if(str1[k]>str2[k]){
        a+=3;
        break;
      }
      if(str1[k]<str2[k]){
        b+=3;
        break;
      }
      if(str1[k]=='\0'&&str2[k]!='\0'){
        b+=3;
        break;
      }
      if(str1[k]=='\0'&&str2[k]!='\0'){
        b+=3;
        break;
      }
      if(str1[k]!='\0'&&str2[k]=='\0'){
        a+=3;
        break;
      }
    }
    //    printf("%d %d\n",a,b);
  }
  printf("%d %d\n",a,b);
  return 0;
}

Measured memory_bytes: 596
s=input()
n=int(input())

if s[0]!="1":
  print(s[0])
else:
  cnt=1
  for j in range(len(s)):
    if s[j]!="1":
      break
    else:
      cnt+=1
  if cnt==1 or n < cnt:
    print(1)
  else:
    print(s[cnt-1])

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;

main(){
cin >> n;
	while(n --){
		int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a+3);
puts((a[2]*a[2] == a[0]*a[0]+a[1]*a[1]) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1132
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    string S;
    cin >> S;
    bool exist_A=false;
    bool exist_B=false;
    for(int i=0;i<S.length();++i){
        if('A'==S[i]){
            exist_A=true;
        }
        else{
            exist_B=true;
        }
    }
    if(exist_A){
        if(exist_B){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }
    else{
        cout << "No";
    }
}


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

int main()
{
  int N, K, cnt=0;
  cin >> N >> K;
  while(N>=K){
    N=N/K;
    cnt++;
  }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int N = 100 + 5; 

int main()
{
	char s[N];
	cin >> s;
	int ans = 0,n = strlen(s);
	for(int i = 0;i < n / 2;i++){
		if(s[i] != s[n - 1 - i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

Measured memory_bytes: 596
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int a = sc.nextInt();
	// スペース区切りの整数の入力
	int b = sc.nextInt();
	int c = sc.nextInt();
	
	int tmp = a;
	a = b;
	b = tmp;
	
	tmp = a;
	a = c;
	c = tmp;
	
	// 出力
	System.out.print(a);
	System.out.print(" ");
	System.out.print(b);
	System.out.print(" ");
	System.out.print(c);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
#include<math.h>
void solution(int a,int b,int c,int d,int e,int f);
double x,y;
int main()
{
    int a,b,c,d,e,f;
    while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)==6)
    {
        solution(a,b,c,d,e,f);
        printf("%0.3lf %0.3lf\n",x,y);
    }
    return(0);
}
void solution(int a,int b,int c,int d,int e,int f)
{
    double number_1,number_2,number_3,correction;
    number_1=c*e-b*f;
    number_2=a*f-c*d;
    number_3=a*e-b*d;
    if((number_1==0)&&(number_3<0)&&(number_2!=0))
    {
        correction=-1*number_3;
        x=number_1/correction;
        y=number_2/number_3;
    }
    else if((number_2==0)&&(number_3<0)&&(number_1!=0))
    {
        correction=-1*number_3;
        x=number_1/number_3;
        y=number_2/correction;
    }
    else if((number_1==0)&&(number_3<0)&&(number_2==0))
    {
        correction=-1*number_3;
        x=number_1/correction;
        y=number_2/correction;
    }
    else
    {
        x=number_1/number_3;
        y=number_2/number_3;
    }
    return;
}

Measured memory_bytes: 1068
def c2(n):
    return (n*(n-1)) // 2

n = int(input())

d = {}
for _ in range(n):
    si = input()
    l = [0 for i in range(26)]
    for c in si:
        l[ord(c) - ord('a')] += 1

    if str(l) in d:
        d[str(l)] += 1
    else:
        d[str(l)] = 1

num = 0
for v in d.values():
    num += c2(v)

print(num)

Measured memory_bytes: 23600
#include<bits/stdc++.h>
#define N 100005
#define M 65540
using namespace std;
int n,s[N],S,ans,f[M],inf,sum[20];

int dfs(int S)
{
  if(!S)return 0; 
  if(f[S]<inf)return f[S];
  for(int i=0;i<16;i++)if((S>>i)&1)
    for(int j=0;j<16;j++)if(i!=j&&(S>>j)&1)
    {
      int p=i^j,x=S^(1<<i)^(1<<j)^(1<<p);
      if(S>>p&1)f[S]=min(f[S],dfs(x)+2);
      else f[S]=min(f[S],dfs(x)+1);
      //枚举每次异或的两个节点i,j,i异或掉j,j异或掉j,还剩下p=i^j
      //如果p本身存在那两个p直接消掉 
    }
  return f[S];
}

int main()
{
  int a,b,c;
  scanf("%d",&n);
  for(int i=1;i<n;i++)
    scanf("%d%d%d",&a,&b,&c),s[a]^=c,s[b]^=c;
  for(int i=0;i<n;i++)sum[s[i]]++;
  for(int i=1;i<16;i++)
    ans+=(sum[i]>>1),S+=(1<<i)*(sum[i]&1);
  memset(f,127,sizeof(f));inf=f[0];
  printf("%d\n",ans+dfs(S));
  return 0;
} 

Measured memory_bytes: 896
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
count = {"r": 0, "s": 0, "p": 0}
win = [-1 for i in range(N)]

for i in range(N):
    if i < K:
        count[T[i]] += 1
        win[i] = 1
    else:
        if T[i] == T[i-K] and win[i-K] == 1:
            win[i] = 0
        else:
            count[T[i]] += 1
            win[i] = 1

score = R*count["s"] + S*count["p"] + P*count["r"]
print(score)

Measured memory_bytes: 4212
import java.util.*;
public class Main{
	
	public static void main (String[] args) {
		
		Scanner scanner = new Scanner (System.in);
		
		int totalCard = scanner.nextInt();
		int [] cardList = new int[totalCard];
		
		for (int index=0; index<totalCard; index++) {
			int temp = scanner.nextInt();
			cardList[index]=temp;
		}
		
		int alicePoint = 0;
		int bobPoint = 0;
		
		boolean aliceTurn = true;
		for (int index=0; index<totalCard; index++) {
			
			int card = getMaximum(cardList);
			if (aliceTurn==true) {
				alicePoint+=card;
				aliceTurn = false;
			} else {
				bobPoint+=card;
				aliceTurn = true;
			}
		}
		
		System.out.println(Math.abs(alicePoint-bobPoint));
		
	}
	
	static int getMaximum (int[] cardList) {
		
		int maximum = 0;
		int maximumIndex = 0;
		
		for (int index=0; index<cardList.length; index++) {
			int temp = cardList[index];
			if (temp>maximum) {
				maximum=temp;
				maximumIndex=index;
			}
		}
		cardList[maximumIndex]=0;
		return maximum;
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

char s[8888];
vector<int> a[2];
int x, y;

bool solve(int p, int s, map<int, int> dp[8888], vector<int>& q, int l) {
  if (p == int(q.size())) return s == l;
  if (dp[p].count(s)) return false;
  dp[p][s] = true;
  return solve(p+1, s+q[p], dp, q, l) || solve(p+1, s-q[p], dp, q, l);
}

int main(void) {
  scanf("%s", s);
  scanf("%d%d", &x, &y);
  int p = 0;
  for (int i = 0; s[p]; i = 1 - i) {
    int k = 0;
    while (s[p] == 'F') ++p, ++k;
    a[i].push_back(k);
    ++p;
  }

  /*
  for (int i = 0; i < 2; i++) {
    for (auto&& x : a[i]) {
      printf("%d ", x);
    }
    puts("");
  }
  */

  bool ok = true;
  map<int, int> dp[8888];
  ok &= solve(1, a[0][0], dp, a[0], x);
  if (ok) {
    for (int i = 0; i < 8888; i++) {
      dp[i].clear();
    }
    ok &= solve(0, 0, dp, a[1], y);
  }
  puts(ok ? "Yes" : "No");
  return 0;
}


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

int my_lower(vector<int> &vec, int key, int nimin, int nimax) {
  int nimid = nimin + (nimax - nimin) / 2;
  if (vec.at(nimid) > key) {
    if (vec.at(nimid - 1) < key) {
      return nimid;
    }
    return my_lower(vec, key, nimin, nimid - 1);
  }
  if (vec.at(nimid) < key) {
    if (vec.at(nimid + 1) > key) {
      return nimid + 1;
    }
    return my_lower(vec, key, nimid + 1, nimax);
  }
  if (vec.at(nimid) == key) {
    for (int i = nimid; i >= nimin; i--) {
      if (vec.at(nimid) == vec.at(i)) {
        continue;
      }
      return i + 1;
    }
  }
}

int main() {
  int N;
  int ans = 0; 
  cin >> N;
  vector<int> bou(N);
  for (int i=0; i < N; i++) {
    cin >> bou.at(i);
  }
  sort(bou.begin(), bou.end());
  // a<=b<=cとすると、三角不等式はc<a+bと同値。
  // そこで、bouの中で添字が小さい順に見ていき、最初にa+b以上となる場所を二分探索で探す。
  for (int i=0; i < N - 2; i++) {
    int bi = bou.at(i);
    for (int j=i+1; j < N - 1; j++) {
      int di;
      if (bi + bou.at(j) > bou.at(N - 1)) {
        di = N - 1 - j;
      }
      else {
        di = my_lower(bou, bi + bou.at(j), 0, N - 1) - 1 - j;
      }
      ans += max(di, 0);
    }
  }
  cout << ans << endl;
}


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

int main(void) {
    string a, s, c;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> s >> c;
    cout << a[0] << s[0] << c[0] << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      String S = sc.next();
      
      if (N % 2 == 1) {
        System.out.println("No");
        return;
      }
      
      // 分解したものが一致するか比較
      if (S.substring(0, N/2).equals(S.substring(N/2, N))) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n, m, a, b, c[10], res;
vector<ll> vec[10];

void dfs(ll x, ll y){
    if (x == n) {
        res++;
    } else {
        c[y] = 1;
        for (ll i = 0; i < vec[y].size(); i++) {
            if (c[vec[y][i]]) continue;
            dfs(x + 1, vec[y][i]);
        }
        c[y] = 0;
    }
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    dfs(1, 1);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
 
#define INF 2e9
#define ll long long
 
int main(){
    int n, tim;
    cin>>n>>tim;
    int c[n], t[n];
    int ans = 100000;
    REP(i, n){
        cin>>c[i]>>t[i];
    }
    REP(i, n){
        if(t[i]<=tim){
            if(ans>c[i]){
                ans = c[i];
            }
        }
    }
    if(ans==100000){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll n, x,s=LLONG_MAX;
	cin >> n >> x;
	vector<ll>m(n);
	for (ll i = 0; i < n; i++) {
		cin >> m[i];
		s = min(m[i], s);
		x -= m[i];
	}
	cout << x / s +n<< endl;

	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int a,b;
    cin >> a >> b;
    int ab = min(a,b);
    for(int i=0;i<max(a,b);i++){
        cout << ab;
    }
    cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char buf[24];
char s[125];

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",buf);s[i]=buf[0];
    if(s[i]=='Y'){
      puts("Four");return 0;
    }
  }
  puts("Three");
  return 0;
}


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

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

  int v[n];
  int w[n];
  for(int i=0; i<n; i++){
    cin >> v[i] >> w[i];
  }

  int DP[n+1][W+1];
  for(int i=0; i<=W; i++){
    DP[0][i]=0;
  }

  for(int i=1; i<=n; i++){
    for(int j=0; j<=W; j++){
      if(j < w[i-1]){
        DP[i][j] = DP[i-1][j];
      }else{
        if(DP[i-1][j] > DP[i-1][j-w[i-1]]+v[i-1]){
          DP[i][j] = DP[i-1][j];
        }else{
          DP[i][j] = DP[i-1][j-w[i-1]]+v[i-1];
        }
      }
    }
  }

  cout << DP[n][W] << endl;

  return 0;
}



Measured memory_bytes: 7040
n = gets.to_i
r = n.times.map { gets.to_i }

max_profit = r[1] - r[0]
min = r[0]
(1...r.size).each do |i|
  profit = r[i] - min
  max_profit = profit if profit > max_profit
  min = r[i] if r[i] < min
end
puts max_profit

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*1ll*b;x%=m;if(x<0)x+=m;return x;}

int N,K,L;
vector<int> G[200010];
bool vis[200010];
int compid[200010];
int compcnt;
int compsz[200010];
int cnt[200010];
int ans[200010];

void dfs1(int u){
    vis[u] = true;
    compid[u] = compcnt;
    for(int v:G[u])
        if(!vis[v])
            dfs1(v);
}

void dfs2(int u,vector<int> &verts,vector<int> &ids){
    vis[u] = true;
    verts.pb(u);
    ids.pb(compid[u]);
    for(int v:G[u])
        if(!vis[v])
            dfs2(v,verts,ids);
}

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    si(N);si(K);si(L);

    for(int i=1;i<=K;i++){
        int u,v;
        si(u);si(v);
        G[u].pb(v);
        G[v].pb(u);
    }
    for(int i=1;i<=N;i++){
        if(!vis[i]){
            compcnt++;
            dfs1(i);
        }
    }

    for(int i=1;i<=N;i++)
        G[i].clear(),
        vis[i] = false;

    for(int i=1;i<=L;i++){
        int u,v;
        si(u);si(v);
        G[u].pb(v);
        G[v].pb(u);
    }

    compcnt = 0;
    for(int i=1;i<=N;i++){
        if(!vis[i]){
            compcnt++;
            vector<int> verts,ids;
            dfs2(i,verts,ids);
            for(int it:ids)
                cnt[it] ++;

            for(int it:verts)
                ans[it] += cnt[compid[it]];

            for(int it:ids)
                cnt[it] --;
        }
    }

    for(int i=1;i<=N;i++)
        cout<<ans[i]<<" ";

    return 0;
}


Measured memory_bytes: 12788
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

int main(){
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;
    
    for(int i=0;i<n-1;i++){
        if(s[i]=='#'&&s[i+1]=='#'&&a<i&&max(c,d)>i){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    if(c>d){
        bool can=false;
        for(int i=0;i<n-2;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'&&i+1>=b&&i+1<=d){
                can=true;
                break;
            }
        }
        if(!can){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>

int main()
{
   const int kMaxN = 100000;
   int nDam;
   std::cin >> nDam;
   int nMountain = nDam;
   int dam[kMaxN], mountain[kMaxN];
   mountain[0] = 0;
   for (int iDam = 0; iDam < nDam; iDam++) {
      std::cin >> dam[iDam];
      if (iDam%2) {
         mountain[0] -= dam[iDam];
      } else {
         mountain[0] += dam[iDam];
      }
   }

   std::cout << mountain[0] << " ";
   for (int iMountain = 1; iMountain < nMountain; iMountain++) {
      mountain[iMountain] = 2 * dam[iMountain - 1] - mountain[iMountain - 1];
      std::cout << mountain[iMountain] << " ";
   }

   std::cout << std::endl;

   return 0;
}

   


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

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

  int n;
  cin >> n;

  int N = n;
  int ans = 0;
  for (int i = 2; i * i <= N; i++) {
    int cnt = 0;
    while(n % i == 0) {
      n /= i;
      cnt++;
    }
    for (int j = 1; j <= 50; j++) {
      if(cnt < j) break;
      ans++;
      cnt -= j;
    }
  }
  if(n > 1) ans++;
  cout << ans << '\n';
}

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

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }
    return ans;

}

int main()
{
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;

    if(S==U){
        cout << A-1 << " "<< B << endl;
    }else{
        cout << A <<" "<< B-1 << endl;
    }


    return 0;

}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    x = int(readline())

    print(1 - x)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61660
n= int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

init = sum(a)
for i in range(n):
  if b[i] >= a[i]:
    b[i] = b[i] - a[i]
    a[i] = 0
  else:
    a[i] = a[i] - b[i]
    b[i] = 0
  
  if b[i] >= a[i+1]:
    b[i] = b[i] - a[i+1]
    a[i+1] = 0
  else:
    a[i+1] = a[i+1] - b[i]
    b[i] = 0

fin = sum(a)  
print(init-fin)

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



int main()
{

	queue < pair<int, int> > q;
	pair<int, int> p;



	char **m;
	char c[10] = { "123456789" };
	int **f;
	int n, k, i, i1, c1, i2, sum = 0;
	cin >> n;
	cin >> k;
	cin >> c1;

	m = new char *[n + 2];
	f = new int *[n + 2];

	for (i = 0; i < n + 2; i++){
		m[i] = new char[k + 2];
		f[i] = new int[k + 2];
	}

	for (i = 1; i <= n; i++){
		for (i1 = 1; i1 <= k; i1++){
			cin >> m[i][i1];
		}
	}

	for (i = 0; i < n + 2; i++){
		for (i1 = 0; i1 < k + 2; i1++){
			if (i == 0 || i == n + 1){
				m[i][i1] = 'X';
			}
			else if (i1 == 0 || i1 == k + 1){
				m[i][i1] = 'X';
			}
		}
	}

	for (i = 1; i <= n; i++){
		for (i1 = 1; m[i][i1] != '\0'; i1++){
			if (m[i][i1] == 'S'){
				q.push(make_pair(i, i1));
			}
		}
	}



	pair<int, int> temp;

	temp = q.front();

	for (i = 0; i < c1; i++){

		for (i1 = 0; i1 < n + 2; i1++){
			for (i2 = 0; i2 < k + 2; i2++){
				if (i1 == 0 || i1 == n + 1){
					f[i1][i2] = 1;
				}
				else if (i2 == 0 || i2 == k + 1){
					f[i1][i2] = 1;
				}
				else
					f[i1][i2] = -1;
			}
		}

		f[temp.first][temp.second] = 0;

		while (!q.empty()){
			p = q.front();
			q.pop();

			int x[4] = { -1, 1, 0, 0 }, y[4] = { 0, 0, -1, 1 };

			for (int j = 0; j < 4; j++){

				//いける場所の捜索
				if (m[p.first + x[j]][p.second + y[j]] != 'X' && f[p.first + x[j]][p.second + y[j]] < 0){
					q.push(make_pair(p.first + x[j], p.second + y[j]));
					f[p.first + x[j]][p.second + y[j]] = f[p.first][p.second] + 1;
				}
			}
			//ゴールかどうか？
			if (m[p.first][p.second] == c[i]){
				sum += f[p.first][p.second];
				temp = p;
				while (!q.empty()){
					q.pop();
				}
				q.push(p);
				break;
			}
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 6160
#include<stdio.h>

int main()
{
    int N,K;
    int A[1000]={};
    int d;
    int address;

    scanf("%d %d", &N,&K);

    int i, j;
    for(i=0;i<K;i++)
    {
        scanf("%d", &d);
        for(j=0;j<d;j++)
        {
            scanf("%d", &address);
            A[address - 1] = 1;
        }
    }

    int count=0;
    for(i=0;i<N;i++)
    {
        if(A[i]==0)
            count++;
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 1708