akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define MOD 1000000007

const ll inf = 1e18L + 5;

void max_self(int& a, int b ){
    a = max(a, b);
}

void dfs(vector<vector<int> > &graph, int v, vector<int> &dist, vector<int> &in_degree ) {

    for( int u : graph[v] ) {
        max_self(dist[u], 1+dist[v]);
        in_degree[u]--;
        if( in_degree[u] == 0 )
            dfs(graph, u, dist, in_degree);
    }
}


int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

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

    vector<vector<int> > graph;
    graph.resize(N+1);
    vector<int> dist(N+1, 0);
    vector<int> in_degree(N+1, 0);

    for( int i = 1; i <= N; i++ ) {
        graph[0].push_back(i);
        in_degree[i]++;
    }

    int x,y;
    for( int edge = 0; edge < M; edge++ ) {
        cin>>x>>y;
        graph[x].push_back(y);
        in_degree[y]++;
    }

    vector<int> visited(N+1);
    dfs(graph, 0, dist, in_degree);

    int res = 0;
    for( int i = 1; i <= N; i++ ) {
        max_self( res, dist[i]);
    }
    cout<<res-1<<endl;

    return 0;
}

Measured memory_bytes: 9720
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<vector<int> > v(100010);
map<pair<int,int>,int > mp;
int ans[100010];
int memo[100010];

int main()
{
	int n,m;cin >> n >> m;
	int cou = n;
	REP(i,m)
	{
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);v[b].PB(a);
		mp[MP(a,b)] = 0;
		mp[MP(b,a)] = 0;
	}
	
	vector<pair<int,pair<int,int> > > list;
	
	int Q;cin >> Q;
	
	REP(i,Q)
	{
		int a,b,c;cin >> a >> b >> c;
		a--;
		list.PB(MP(a,MP(b,c)));
	}
	
	for(int i = Q-1;i >= 0;i--)
	{
		if(cou == 0)break;
		
		int color = list[i].SE.SE;
		if(ans[list[i].FI] == 0)
		{
			ans[list[i].FI] = color;
			cou--;
		}
		if(list[i].SE.FI == 0)
		{
			continue;
		}
				
		int m_Dist = list[i].SE.FI;
				
		queue<pair<pair<int,int>,int> > q;
		q.push(MP(MP(list[i].FI,list[i].SE.FI),-1));
		
		while(!q.empty())
		{
			pair<pair<int,int>,int> now = q.front();q.pop();
			int node = now.FI.FI;
			int dist = now.FI.SE;
			int prev = now.SE;
						
			//cout << node << ' ' << color << endl;
			REP(j,v[node].size())
			{
				if(v[node][j] == prev)
				{
					continue;
				}
				if(mp[MP(node,v[node][j])] >= dist)
				{
					continue;
				}
				mp[MP(node,v[node][j])] = dist;
				//mp[MP(v[node][j],node)] = max(m_Dist - dist + 1,mp[MP(v[node][j],node)]);
				if(ans[v[node][j]] == 0)
				{
					ans[v[node][j]] = color;
					cou--;
				}
				
				if(dist>1)
				{
					q.push(MP(MP(v[node][j],dist-1),node));
				}
			}
		}
	}
	
	REP(i,n)
	{
		cout << ans[i] << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 21744
#include <bits/stdc++.h>
#define MAXN 200000

using namespace std;

int v[MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    //ios::sync_with_stdio(false);
    cin >> n;
    long long s = 0;
    for(i = 1; i <= n; i++) {
        cin >> v[i];
        s += v[i];
    }
    long long sum = 0;
    long long ans = (1LL << 62);
    for(i = 1; i < n; i++) {
        sum += v[i];
        if(abs(s - 2 * sum) < ans)
            ans = abs(s - 2 * sum);
    }
    cout << ans;
    //cin.close();
     //cout.close();
    return 0;
}


Measured memory_bytes: 1024
N, A, B, C, D = map(int, input().split())
S = list(input())
S[A - 1] = 'A'
S[B - 1] = 'B'
a1 = 0
a2 = 0
ans = ''
if C > D:
    a1 = 'A'
    a2 = 'B'
    tmp1 = C - 1
    tmp2 = D - 1
    now1 = A - 1
    now2 = B - 1
else:
    a1 = 'B'
    a2 = 'A'
    tmp1 = D - 1
    tmp2 = C - 1
    now1 = B - 1
    now2 = A - 1

while True:
    if now1 != tmp1:
        if now1 + 1 <= len(S) - 1 and S[now1 + 1] == '.' and now1 + 1 <= tmp1:
            S[now1] = '.'
            S[now1 + 1] = a1
            now1 += 1
        elif now1 + 2 <= len(S) - 1 and S[now1 + 2] == '.' and now1 + 2 <= tmp1:
            S[now1] = '.'
            S[now1 + 2] = a1
            now1 += 2
        elif now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        elif now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        else:
            ans = 'No'
            break
    elif now2 != tmp2:
        if now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        elif now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'
        break

print(ans)


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

int main(){

  string s;
  cin>>s;
  

  for (int i=0;i<3;i++){
    if (s.at(i)=='1'){
      s.at(i)='9';
    }
    
    else {
      s.at(i)='1';
    }
  }
    
    cout<<s<<endl;
  
 
}
  













Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    a = II()
    s = SI()
    if a >= 3200: 
        print(s)
    else: print('red')

main()

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

using ll = long long int;

int main(void){
    
    int n;
    cin >> n;
    
    ll answer = pow(3,n);
    ll sub = 1;
    
    
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a % 2 == 1){
            
        }else{
            sub *= 2;
        }
    }
    
    cout << answer - sub << endl;
    
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

string s;
int A[2][300004], B[2][300004];

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

	int n, i, j, k, x, y, z;
	cin >> n >> s;
	s = '1' + s;
	for (i = 1; i <= n; ++i) {
		if (s[i] == 'E') A[0][i]++;
		else A[1][i]++;
		A[0][i] += A[0][i-1];
		A[1][i] += A[1][i-1];
	}
	for (i = n; i >= 1; --i) {
		if (s[i] == 'E') B[0][i]++;
		else B[1][i]++;
		B[0][i] += B[0][i+1];
		B[1][i] += B[1][i+1];
	}
	int ans = MOD;
	for (i = 1; i <= n; ++i) {
		ans = min(ans, A[1][i-1] + B[0][i+1]);
	}
	cout << ans << endl;

	return 0;
}

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

int gcd(int a, int b) { return b?gcd(b,a%b):a;}
int ngcd(vector<int> a){
    int result = a[0];
    for(int i = 1; i < a.size() && result != 1; ++i) {
        result = gcd(result, a[i]);
    }
    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, start;
    cin >> n >> start;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    rep(i, n) x[i] = abs(x[i] - start);
    int ans = ngcd(x);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, x, y = 0, z = 0, h, w, ans = 0, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;

  cin >> n >> m >> x;
  VI c(n);
  VII a(n, VI(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  rep(s, 1 << n) {
    VI d(m);
    sum = 0;
    rep(i, n) {
      if (s >> i & 1) {
        sum += c[i];
        rep(j, m) { d[j] += a[i][j]; }
      }
    }
    bool ok = true;
    rep(j, m) if (d[j] < x) ok = false;
    if (ok) chmin(Min, sum);
  }
  if (Min == 1e9 + 1) {
    pri(-1);
  } else
    pri(Min);
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;

const int MAX_N = 100010;
ll A[MAX_N];

int main() {
    int N; cin >> N;
    rep(i,N) cin >> A[i];
    vector<pair<ll,ll>> ans;
    sort(A, A+N);
    int Q = 0;
    rep(i,N) {
        if(A[i] < 0) ++Q;
    }
    if(Q == 0) Q = 1;
    if(Q == N) Q = N - 1;
    for(int i = Q; i < N-1; ++i) {
        ans.push_back(make_pair(A[0], A[i]));
        A[0] = A[0] - A[i];
    }
    for(int i = 0; i < Q; ++i) {
        ans.push_back(make_pair(A[N-1], A[i]));
        A[N-1] = A[N-1] - A[i];
    }
    cout << A[N-1] << endl;
    for(const auto e : ans) cout << e.first << " " << e.second << endl;
    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
int main() {
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    double ans = (double) W*H/2;
    int line = (W == x*2 && H == y*2) ? 1 : 0;
    cout << setprecision(10) << ans << " " << line;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


h, w = MI()
c = [IS() for _ in range(h)]
for i in c:
    print(i)
    print(i)


Measured memory_bytes: 68076
n1, n2, n3, n4=map(int,input().split())
n=[]
n.append(n1)
n.append(n2)
n.append(n3)
n.append(n4)
if 1 in n and 7 in n and 9 in n and 4 in n:
  print('YES')
else:
  print('NO')



Measured memory_bytes: 2940
// https://atcoder.jp/contests/abc098/tasks/abc098_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    size_t maxv = 0;
    FOR(i, 1, n - 1) {
        set<char> a, b, result;
        REP(j, i) a.insert(s[j]);
        FOR(j, i, n) b.insert(s[j]);
        // aとbの積集合を作る
        set_intersection(ALL(a), ALL(b), inserter(result, result.end()));
        maxv = max(maxv, result.size());
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (void){

    int n,a,b;
    int sum = 0;

    scanf("%d %d %d", &n, &a, &b);

    for(int i = 1; i <= n; i++){

        int h1 = i%10;
        int h2 = i%100 - h1;
        int h3 = i%1000 - i%100;
        int h4 = i%10000 -i%1000;
        int h5 = i - i%10000;
        int hsum = h1+h2/10+h3/100+h4/1000+h5/10000;
        if( a <= hsum && hsum <= b  )
          sum += i;

    }

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


Measured memory_bytes: 128
n = int(input())
c = [0 for i in range(n-1)]
s = [0 for i in range(n-1)]
f = [0 for i in range(n-1)]
for i in range(n-1) :
  c[i],s[i],f[i] = map(int,input().split())
  
for i in range(0,n-1) :
  ans = 0
  for j in range(i,n-1) :
    if s[j] <= ans and ans%f[j] == 0 :
      ans += c[j]
    elif s[j] > ans :
      ans += c[j] + (s[j]-ans)
    elif ans%f[j] != 0 :
      ans += c[j] + (ans//f[j]+1)*f[j] - ans
  print(ans)
print(0)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	ll pre[n]={0};
	for(ll p=0;p<n;p++)
	{
		cin>>a[p];
		sum=(sum%mod+a[p]%mod)%mod;
		if(p==0)
			pre[p]=a[p]%mod;
		else
			pre[p]=(pre[p-1]%mod+a[p]%mod)%mod;
	}
	ll ans=0;
	for(ll p=0;p<n-1;p++)
	{
		ll ter=((sum-pre[p]+mod)%mod*a[p]%mod)%mod;
		ans=(ans%mod+ter%mod)%mod;
		//cout<<"ans= "<<ans<<endl;

	}
	cout<<ans;

}

Measured memory_bytes: 6708
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int a,b;
    cin >> a >> b;

    cout << (a+b)%24 << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x));
        var ret = 1;
        foreach(var i in input) ret *= i;
        System.Console.WriteLine(ret);
    }
}


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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n,t;
    cin>>n>>t;
    vector<pair<int,int>> a(n);
    for(pair<int,int>& x: a) cin>>x.first>>x.second;
    sort(a.begin(), a.end());
    for(auto x: a) {
        if(x.second <= t) {
            cout<<x.first;
            return 0;
        }
    }
    cout<<"TLE";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
using ll=long long;
const ll MOD=1000000007;



int main() {
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)cout<<i<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 600060
const int mod=1e9+7; 
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,L,R,A,B; 
int fac[N],inv[N];
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int calc(int x,int p,int q){
	if(1LL*(p+1)*m>x)return 0;
	x-=(p+1)*m;
	int ans=0;
	for(int i=0;i<=n-m&&x>=0;++i){
		ans=(ans+1LL*(i&1?-1:1)*C(n-m,i)*C(x+n,n))%mod;
		x-=q+1;
	}
	return (ans+mod)%mod;
}
int Solve(int x){
	int tot=0;
	for(int i=0;i<=x;++i){
		tot=(tot+1LL*(calc(x,i,i)-calc(x,i,i-1)+mod)*C(n,m)%mod)%mod;
	}
	return (C(n+x,n)-tot+mod)%mod;
}
int main(){
	n=read(),m=read(),L=read(),R=read();
	init(n+R);
	printf("%d\n",(Solve(R)-Solve(L-1)+mod)%mod);
	return 0;
}



Measured memory_bytes: 8384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll N,A,B;
vector<ll>h(100005);
bool isOK(ll mid){
	ll ret=0;
	for(int i=0;i<N;i++){
		if(h[i]-mid*B>0){
			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);
		}
	}
	return ret<=mid;
}


int main(){
	init();
	cin>>N;
	cin>>A>>B;
	for(int i=0;i<N;i++)cin>>h[i];
	
	ll right=pow(10,10);
	ll left=0;
	ll mid;
	//cout<<isOK(3)<<endl;
	while(right-left>1){
		mid=(right+left)/2;
		if(isOK(mid))right=mid;
		else left=mid;
	}
	cout<<right<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
int n,m,ans,fa[N],sz[N],val[N],sum[N];
struct node{int x,y,d;}a[N];
inline bool cmp(node aa,node bb){return aa.d<bb.d;}
int find(int x){
	if (x==fa[x]) return x;
	fa[x]=find(fa[x]);
	sum[fa[x]]+=sum[x];
	sz[fa[x]]+=sz[x];
	sum[x]=sz[x]=0;
	return fa[x];
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++) scanf("%lld",&val[i]);
	for (int i=1;i<=m;i++) scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].d);
	for (int i=1;i<=n;i++) fa[i]=i,sum[i]=val[i];
	sort(a+1,a+m+1,cmp);
	for (int i=1;i<=m;i++){
		int fx=find(a[i].x);
		int fy=find(a[i].y);
		if (fx==fy){
			sz[fx]++;
			if (a[i].d<=sum[fx]) ans+=sz[fx],sz[fx]=0;
		}
		else {
			fa[fx]=fy;
			sum[fy]+=sum[fx];
			sz[fy]+=sz[fx]+1;
			sz[fx]=sum[fx]=0;
			if (a[i].d<=sum[fy]){
				ans+=sz[fy];
				sz[fy]=0;
			}
		}
	}
	printf("%lld\n",m-ans);
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int a=0,b=0,c=0,t=0;
    vector <int> N;
    //int min = INF;
    int max = 0;
    int K;
    cin >> K;
    cin >> a >> b;
    for(int i=a; i<=b;i++){
        if(i%K==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
 
int dp[5000001] = {0};
int main() {
        int k,m,n;
        dp[1] = 1;
        for(int i = 1 ; i <= 1000000 ; i++){
                dp[i*2] |= dp[i];
                dp[i*3] |= dp[i];
                dp[i*5] |= dp[i];
        }
        for(int i = 1 ; i <= 1000000 ; i++){
                dp[i] += dp[i-1];
        }
        while(cin >> m && m){
                cin >> n;
                cout << dp[n] - dp[m-1] << endl;
        }
        return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

	int month[] = {0, 31, 29, 31,
		30, 31, 30,
		31, 31, 30,
		31, 30, 31};

	int m, d;
	while(cin >> m >> d){
		if(m == 0 && d == 0){
			break;
		}
		for(int i = 1; i < m; i++){
			d += month[i];
		}

		cout << day[d%7] << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n;

void dfs(string s, char ma) {
    if(s.size() == n) {
        out(s);
        return;
    }
    for(char c = 'a'; c <= ma; c++) {
        if(c == ma) {
            dfs(s + c, (char)(ma + 1));
        }
        else {
            dfs(s + c, ma);
        }
    }
}

int main() {
    cin >> n;
    dfs("", 'a');
    re0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, m, p, y, id;
	string s, ss;

	cin >> n >> m;

	vector<ll> v(n, 1);
	vector<tuple<ll, ll, ll>> vv;
	vector<string> ans(m, "");

	REP(i, m) {
		cin >> p >> y;
		vv.push_back(make_tuple(y, p, i));
	}

	sort(vv.begin(), vv.end());

	REP(i, m) {
		tie(y, p, id) = vv[i];
		s = to_string(p);
		while (s.size() < 6) {
			s = "0" + s;
		}
		ss = to_string(v[p - 1]);
		while (ss.size() < 6) {
			ss = "0" + ss;
		}
		v[p - 1]++;
		ans[id] = s + ss;
	}

	REP(i, m) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 10608
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }
  for (int i = 0; i < N - 1; ++i) {
    cin >> C[i];
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += B[A[i] - 1];
    if (i < N - 1 and (A[i] + 1 == A[i + 1])) {
      ans += C[A[i] - 1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int id[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
  int x,y;
  cin >> x >> y;
  if( id[x-1] == id[y-1] ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n;
  cin >> n;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  ll ok=INF,ng=-1;
  
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    ll cnt=0;
    rep(i,n) cnt+=(vec[i]+mid+1)/(n+1);
    if(cnt<=mid)ok=mid;
    else ng=mid;
  }
  for(ll i=max(0ll,ok-100000);i<=ok;i++){
    ll sum=0;
    rep(j,n){
      sum+=(vec[j]+i+1)/(n+1);
    }
    if(sum<=i){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int i, j;
    int h, w;
	cin >> h >> w;
	vector<string> grid(h);
	vector< vector<int> > l(h, vector<int>(w)), r(h, vector<int>(w)),
		u(h, vector<int>(w)), d(h, vector<int>(w));
	int answer = 0;
	int tmp = 0;
	for (i = 0; i < h; i++)
		cin >> grid[i];

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (grid[i][j] == '#') {
				l[i][j] = 0;			
				u[i][j] = 0;
				continue;
			}
			if (j == 0) 
				l[i][j] = 1;
			else 
				l[i][j] = l[i][j - 1] + 1;

			if (i == 0) 
				u[i][j] = 1;
			else 
				u[i][j] = u[i - 1][j] + 1;			
		}
	}

	for (i = h - 1; i >= 0; i--) {
		for (j = w - 1; j >= 0; j--) {
			if (grid[i][j] == '#') {
				r[i][j] = 0;
				d[i][j] = 0;
				continue;
			}
			if (j == w - 1)
				r[i][j] = 1;
			else
				r[i][j] = r[i][j + 1] + 1;

			if (i == h - 1)
				d[i][j] = 1;
			else
				d[i][j] = d[i + 1][j] + 1;
		}
	}			

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			tmp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
			if (tmp > answer)
				answer = tmp;
		}
	}
	
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl



template<class T>
void show_2d_vector(const vector<vector<T>> &v){
    for (auto v1: v) {
        for(auto v2: v1) {
            cout << v2 << " ";
        }
        cout << endl;
    }
}


int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> s(n);
    vector<ll> t(m);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }
    vector<bool> used(100005, false);
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    for(int i = 0; i <= n; i++){
        dp[i][0] = 1;
    }
    for(int j = 0; j <= m; j++){
        dp[0][j] = 1;
    }
    for(int i = 1; i <= s.size(); i++){
        used[s[i-1]] = true;
        for(int j = 1; j <= t.size(); j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= MOD;
            }else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1]-dp[i-1][j-1] +MOD;
                dp[i][j] %= MOD;

            }
        }
    }

    cout << dp[n][m]%MOD << endl;


    //show_2d_vector(dp);
    return 0;

}


Measured memory_bytes: 31616
// Problem: E - Tr/ee
// Contest: AtCoder - AtCoder Regular Contest 103
// URL: https://atcoder.jp/contests/arc103/tasks/arc103_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

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

char s[N];
void Solve(){
  cin>>s+1;
  int n=strlen(s+1);
  if(s[1]=='0'||s[n]=='1'){
    cout<<"-1"<<endl;
    return;
  }
  rep(i,1,n-2){
    if(s[i]!=s[n-i]){
      cout<<-1<<endl;
      return;
    }
  }
  int last=1;
  cout<<1<<" "<<2<<endl;
  rep(i,3,n){
    cout<<last<<" "<<i<<endl;
    if(s[i-1]=='1'){
      last=i;
    }
  }
} 


Measured memory_bytes: 3764
def test():

	while True:
		i = list(map(int,input().split()))
	
		H = i[0]
		W = i[1]

		if H == 0 and W == 0:
			break

		for i in range(H):
			for j in range(W):
				print("#",end="")
			print()

		print()

if __name__ == "__main__":
	test()



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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n),b(n),c(n);
  rep(i,0,n){
    b[i]=k+n+i;
    c[i]=k+2*n+i;
  }
  rep(i,0,n-n/2)a[n/2+i]=k+i;
  rep(i,0,n/2)a[i]=k+(n-n/2)+i;
  vector<pair<ll,P>>p(n);
  rep(i,0,n)p[i]=MP(a[i]+b[i],MP(a[i],b[i]));
  sort(ALL(p));
  if(2*k-1<=n)
  rep(i,0,n)cout<<p[i].se.fi spa p[i].se.se spa c[i]<<endl;
  else cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;

int n;
#define maxn 311
int f[maxn][maxn];bool del[maxn][maxn];
#define LL long long
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			scanf("%d",&f[i][j]);
	memset(del,0,sizeof(del));
	bool flag=0;
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
				if (f[i][j]>f[i][k]+f[k][j]) flag=1;
				else if (k!=i && k!=j && f[i][j]==f[i][k]+f[k][j]) del[i][j]=1;
	if (flag) puts("-1");
	else
	{
		LL ans=0;
		for (int i=1;i<=n;i++)
			for (int j=i+1;j<=n;j++)
				ans+=(del[i][j]^1)*f[i][j];
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 768
N,K = map(int,input().split())
A = list(map(int,input().split()))

counter = 0
place_list = []
place_set = set()
next = 1
while True:
    
    if  next in place_set:
        break
        
    else:
        place_list.append(next)
        place_set.add(next)
        next = A[next-1]
        
    counter += 1

duration_cycle = len(place_list)- place_list.index(next)
if K <len(place_list):
    print(place_list[K])
else:
    print(place_list[(K-place_list.index(next))%duration_cycle+place_list.index(next)])


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

int main(void){
	int n;
	scanf("%d", &n);
	
	int i;
	double x1,x2,x3,y1,y2,y3,p,q,r;
	for(i=0; i<n; i++){
	
		scanf("%lf %lf %lf %lf %lf %lf",&x1, &y1, &x2, &y2, &x3, &y3);
		
		p = ( (y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3) );

		q = ( (x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3) );
	
		r=sqrt( pow(x1-p, 2.0) + pow(y1-q, 2.0) );
	
		printf("%.3lf %.3lf %.3lf\n", p, q, r);
		
		
	}
	
	return 0;
}

Measured memory_bytes: 664
#include <stdio.h>
#include <string.h>

char a[205], b[205];

int main(){
	int k, ans;
	char *p, *q, *wp, *wq;
	char *s[3] = { "IDENTICAL", "CLOSE", "DIFFERENT" };

	while (scanf("%s", a) && a[0] != '.') {
		scanf("%s", b);
		p = a, q = b; ans = -1, k = 0;
		while (*p && *q) {
			if (*p != *q) {
			    ans = 2; break;
			    }
			if (*p == '"') {
			    wp = ++p, wq = ++q;
				while (*p != '"'){
				    p++;
				}while (*q != '"'){
				    q++;
				}
				*p = *q = 0;
				k += 1 - (strcmp(wp, wq) == 0);
				if (k > 1) {
				    ans = 2;
				    break;
				    }
			}
			p++, q++;
		}
		if (ans < 0){
		    if (*p == *q){
		        ans = k;
		        }else{
		            ans = 2;
		        }
		}
		puts(s[ans]);
	}
	return 0;
}


Measured memory_bytes: 2104
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    ll n, k =0;
    cin >> n >> k;
    
    ll a = n % k;
    ll b = abs(a - k);
    ll res;
    if(a < b) res = a;
    else res = b;

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

ll n;
map<ll, ll> cnt;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        ll x;
        cin >> x;
        ++cnt[x];
    }
    ll sum = 0;
    for (auto &it : cnt)
        sum += it.first * it.second;

    int q;
    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        sum += c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 9404
//agc045_a.cpp
//Sun Jul  5 18:44:30 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	rep(i,t){
		int n;
		cin >> n;
		ll a[n];
		rep(j,n) cin >> a[j];
		string s;
		cin >> s;

		vector<ll> xors;
		int ans = 0;
		for (int j=n-1;j>=0;j--){
			ll x = a[j];
			rep(k,xors.size()){
				x = min(x,x^xors[k]);
			}
			if (x){
				if (s[j]=='0'){
					xors.push_back(x);
				}else {
					ans = 1;
					break;
				}
			}
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String key = s.nextLine();
        for(int i=0;i<key.length();i++){
            if(i==key.length()-1){
                break;
            }
            if(i+1<key.length()&&key.charAt(i+1)!=key.charAt(i)){
                continue;
            }else{
                System.out.println("Bad");
                System.exit(0);
            }
        }
        System.out.println("Good");
    }
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



typedef struct UnionFind{
    vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
    vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

    UnionFind(int N){/*最初はすべてが根であると初期化*/
        REP(i,0,N){
            par.push_back(i);
            size.push_back(1);
        }
    }

    lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    void unite(lli x,lli y){/*xとyの併合*/
        lli rx = root(x);
        lli ry = root(y);
        if(rx == ry)return;
        par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
        lli resize = size[rx] + size[ry];
        size[rx] = resize;
        size[ry] = resize;
    }

    bool same(lli x,lli y){
        lli rx = root(x);
        lli ry = root(y);
        return rx == ry;
    }

    lli getSize(lli x){
        lli rx = root(x);
        return size[rx];
    }
};

const int MAX_N = 100100;

void func(long long N, std::vector<long long> x, std::vector<long long> y){

    UnionFind uf(MAX_N*2);

    REP(i,0,N)uf.unite(x[i],y[i]+MAX_N);

    map<lli,lli> mx,my;
    REP(i,0,MAX_N){
        mx[uf.root(i)]++;
        my[uf.root(i+MAX_N)]++;
    }
    lli ans = 0;
    REP(i,0,MAX_N*2)ans += mx[i]*my[i];

    cout<<ans-N<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    func(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 29924
using System;
using System.Collections.Generic;

namespace agc033_a
{
  class Program
  {
    static void Main(string[] args)
    {
      var h = CIn.ReadInt();
      var w = CIn.ReadInt();
      var a = CIn.ReadCharMatrix(h, w);

      var ans = 0;
      var q = new Queue<Data>();

      for (var i = 0; i < h; i++)
      {
        for (var j = 0; j < w; j++)
        {
          if (a[i, j] == '#')
          {
            q.Enqueue(new Data(i - 1, j, 1));
            q.Enqueue(new Data(i + 1, j, 1));
            q.Enqueue(new Data(i, j - 1, 1));
            q.Enqueue(new Data(i, j + 1, 1));
          }
        }
      }

      while (q.Count > 0)
      {
        var e = q.Dequeue();

        if (e.x < 0 || e.x >= h || e.y < 0 || e.y >= w || a[e.x, e.y] == '#') continue;

        a[e.x, e.y] = '#';
        ans = Math.Max(ans, e.d);

        q.Enqueue(new Data(e.x - 1, e.y, e.d + 1));
        q.Enqueue(new Data(e.x + 1, e.y, e.d + 1));
        q.Enqueue(new Data(e.x, e.y - 1, e.d + 1));
        q.Enqueue(new Data(e.x, e.y + 1, e.d + 1));

      }

      Console.WriteLine(ans);
    }
  }

  class Data
  {
    public int x;
    public int y;
    public int d;

    public Data(int x, int y, int d)
    {
      this.x = x;
      this.y = y;
      this.d = d;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }

    public static char[,] ReadCharMatrix(long n, long m)
    {
      var array = new char[n, m];

      for (var i = 0; i < n; i++)
      {
        var line = Console.ReadLine();

        for (var j = 0; j < m; j++)
        {
          array[i, j] = line[j];
        }
      }

      return array;
    }
  }
}

Measured memory_bytes: 172700
import math

n = int(input())

for i in range(0,1000) :

  v = n + i 
  
  l = int(math.sqrt(v)) 
  
  flg = False
  for i in range(2,l):
    
    if v % i == 0 :
      
      flg = True
      break
      
  if flg == False :
    
    print(v)
    exit()
    


Measured memory_bytes: 2940
N,T=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]
#dp[i][j] 料理iまでの間で、時間jまでに達成できる最大効用
dp=[[0]*(T+1) for _ in range(N+1)]
AB.sort()
for i in range(1,N+1):
  dp[i]=dp[i-1][:]
  time=AB[i-1][0]
  happy=AB[i-1][1]
  for j in range(T):
    dp[i][min(j+time,T)]=max(dp[i][min(j+time,T)],dp[i-1][j]+happy)
print(dp[N][T])
    

Measured memory_bytes: 174212