akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
typedef long long lo;
 
template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

namespace mf {
	const int N = 1e4 + 233;
	const int M = 2e5 + 233;
	const lo inf = 1e15;
	struct E {
		int nxt, from, to, fl; lo w;
	} e[M];
	int head[N], e_cnt = 1, cur[N];
	lo d[N]; bool book[N]; int a[N]; lo pre[N];
	int all;
	inline void init(int n) {
		all = n;
		re0 (i, all + 1) head[i] = 0;
		e_cnt = 1;
	}
	inline void add(int u, int v, int fl, int w) {
		e[++ e_cnt] = (E) {head[u], u, v, fl, w}; head[u] = e_cnt;
	}
	inline void link(int u, int v, int fl, int w) {
		add(u, v, fl, w); add(v, u, 0, -w);
	}

	inline int spfa(int &fl, lo &ans, int s, int t) {
		queue <int> q;
		memset(d, 38, sizeof d);
		memset(book, 0, sizeof book);
		a[s] = d[0]; pre[s] = 0;
		d[s] = 0; book[s] = 1; q.push(s);
		while(!q.empty()) {
			int u = q.front(); q.pop(); book[u] = 0;
			for(int i = head[u]; i; i = e[i].nxt) if(e[i].fl) {
					int v = e[i].to;
					if(d[v] > d[u] + e[i].w) {
						d[v] = d[u] + e[i].w;
						pre[v] = i;
						a[v] = min(a[u], e[i].fl);
						if(!book[v])
							book[v] = 1, q.push(v);
					}
				}
		}
		if(d[t] == d[0]) return 0;
		fl += a[t]; ans += a[t] * d[t];
		for(int u = t; u != s; u = e[pre[u]].from) {
			e[pre[u]].fl -= a[t];
			e[pre[u] ^ 1].fl += a[t];
		}
		return 1;
	}

	pair <int, lo> doit(int S, int T) {
		int fl = 0; lo ans = 0;
		while(spfa(fl, ans, S, T));
		return {fl, ans};
	}
}

using mf::link;

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

int n, id[4], S, T, tot;

signed main(void) {
	read(n);
	for (int k = 0; k < 4; k++) id[k] = ++tot;
	S = ++tot; T = ++tot;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		int x, y, c;
		read(x); read(y); read(c);
		sum += c;
		int u = ++tot;
		link(S, u, c, 0);
		vector <int> cid(4, 0);
		for (int k = 0; k < 4; k++) {
			int nx = x * dx[k];
			int ny = y * dy[k];
			cid[k] = ++tot;
			link(u, cid[k], c, nx + ny);
			link(cid[k], id[3 - k], c, 0);
			// cout << k << " " << nx << " " << ny << " " << 3 - k << "\n";
		}
	}
	for (int i = 1; i <= n; i++) {
		int x, y, c;
		read(x); read(y); read(c);
		int u = ++tot;
		link(u, T, c, 0);
		vector <int> cid(4, 0);
		for (int k = 0; k < 4; k++) {
			int nx = x * dx[k];
			int ny = y * dy[k];
			cid[k] = ++tot;
			link(cid[k], u, c, nx + ny);
			link(id[k], cid[k], c, 0);
			// cout << k << " " << nx << " " << ny << " " << 3 - k << "\n";
		}
	}
	cerr << 233 << "\n";
	mf::all = tot;
	auto it = mf::doit(S, T);
	cout << -it.second << "\n";
	assert(it.first == sum);
}


Measured memory_bytes: 1536
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
const long double pie=3.14159265358979323846;
int calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    int hour_angle = 0.5 * (h * 60 + m);  
    int minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    int angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  
  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll val=c*30;
    //  d=d*6;
     double x=(abs)(val-d);
     x=abs(0.5*(60.0*c+d)-6.0*d);
    //  cout<<x<<endl;
     x=min(x,360.0-x);
    //  x=calcAngle(c*1.0,d*1.0);
     x*=pie;
     x=(x/(180*1.0));
    //  cout<<x<<endl;
    //  cout<<cos(x)<<endl;
     long double y=2.0*a*b*cos(x);
        long double ans=a*a*1.0 + b*b*1.0 -y*1.0;
     ans=sqrtl(ans);
     cout<<fixed<<setprecision(10)<<ans<<endl;
}


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

int main () {
    int a;
    int b;
    cin >> a >> b;
    if (a > 9 || b >9) {
        cout << -1;
    } else {
        int ans = a *b;
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let S = readLine()!.toArray()
var ans = "AC"
var flag = false
for (i, c) in S.enumerate() {
    if i == 0 {
        if c != "A" {
            ans = "WA"
            break
        }
    } else if i == 1 || i == S.count-1 {
        if c == c.uppercased() {
            ans = "WA"
            break
        }
    } else if c == c.uppercased() {
        if c != "C" || flag {
            ans = "WA"
            break
        } else {
            flag = true
        }
    }
}
if flag == false {
    ans = "WA"
}
print(ans)


Measured memory_bytes: 7140
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

temp = 0 # MAX_K
for i in range(K):
  temp += p_list[i]
  
ans = temp
for i in range(K,N):
  temp = temp - p_list[i-K] + p_list[i]
  if ans < temp:
    ans = temp

print( (ans + K) /2 )

Measured memory_bytes: 24548
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

int n;
int g[2][112];

int main(void) {
	ios_base::sync_with_stdio(false);

	cin >> n;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> g[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cand = 0;

		for (int j = 0; j <= i; j++) {
			cand += g[0][j];
		}
		for (int j = i; j < n; j++) {
			cand += g[1][j];
		}

		ans = max(ans, cand);
	}

	cout << ans << endl;

	return 0;
}

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

struct Edge{
    ll to, cap, rev_index;
};

class FordFulkerson{
    private:
        vector<vector<Edge>> v;
        ll n;
        bool *used;
        const ll INF = numeric_limits<ll>::max();

        int dfs(ll now, ll goal, ll f){
            if(now == goal) return f;
            used[now] = 1;
            for(Edge &e : v[now]){
                if(used[e.to]){
                    continue;
                }
                if(e.cap <= 0){
                    continue;
                }
                ll d = dfs(e.to, goal, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    v[e.to][e.rev_index].cap += d;
                    return d;
                }
            }
            return 0;
        }

    public:
        FordFulkerson(const vector<vector<pair<ll, ll>>> &v){
            this->n = v.size();
            for(int i = 0; i < n; i++){
                this->v.push_back(vector<Edge>(0));
            }
            for(int i = 0; i < n; i++){
                for(auto e : v[i]){
                    this->v[i].push_back((Edge){e.first, e.second, (ll)this->v[e.first].size()});
                    this->v[e.first].push_back((Edge){i, 0, (ll)this->v[i].size() - 1});
                }
            }
            used = new bool[n];
        }

        ll max_flow(ll start, ll goal){
            ll ret = 0;
            while(1){
                memset(used, 0, n);
                ll add = dfs(start, goal, INF);
                if(add == 0){
                    return ret;
                }
                ret += add;
            }
        }
};

using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 998244353;

int main(){
    ll H, W;
    cin >> H >> W;
    vector<string> V(H);
    for(auto &v : V) cin >> v;
    vector<vector<P>> edges(H + W + 2);
    P start, goal;
    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            if(V[i][j] == 'S'){
                start = P(i, j);
            }else if(V[i][j] == 'T'){
                goal = P(i, j);
            }else if(V[i][j] == 'o'){
                edges[i].push_back(P(H + j, 1));
                edges[H + j].push_back(P(i, 1));
            }
        }
    }
    if(start.first  == goal.first  ||
       start.second == goal.second){
        cout << -1 << endl;
        return 0;
    }
    for(const auto &p : {start, goal}){
        static int cnt = 0;
        edges[H + W + cnt].push_back(P(p.first, INF));
        edges[p.first].push_back(P(H + W + cnt, INF));
        edges[H + W + cnt].push_back(P(H + p.second, INF));
        edges[H + p.second].push_back(P(H + W + cnt, INF));
        cnt++;
    }
    for(auto &e : edges){
        sort(e.begin(), e.end());
        auto ite = unique(e.begin(), e.end());
        e.erase(ite, e.end());
    }
    /*
    for(ll i = 0; i < edges.size(); i++){
        cout << i << " : [";
        for(const auto &p : edges[i]) cout << p.first << ", ";
        cout << "]\n";
    }
    */
    FordFulkerson FF(edges);
    cout << FF.max_flow(H + W, H + W + 1) << endl;
    return 0;
}


Measured memory_bytes: 1920
def main():

    N = int(input())
    S = input()
    count = 0
    t = ""
    for c in S:
        if c == "(":
            count += 1
        else:
            count -= 1

        if count == -1:
            t = "(" + t + c
            count += 1
        else:
            t += c
    t += ")" * count
    return t


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

Measured memory_bytes: 38256
///***###                               بسم الله الرحمن الرحيم                            ###***///


/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 31 May,2020;
*/

///************************Start Of Template*************************///


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
const int N=2e5+5;
int main()
{
    Read_Fast
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


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

int main(){
  string n;
  cin >> n;
  
  for ( int i = 0 ; i < 3 ; i++ ){
  	if (n.at(i) == '1' )
      n.at(i) = '9';
    else if ( n.at(i) == '9' )
      n.at(i) = '1' ;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int A[100000];

void zalgorithm(string S){
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  int ans=0;
  cin>>n>>s;
  rep(i,s.size() ){
    zalgorithm(s.substr(i));
    rep(j,s.size()-i ){
      ans=max(ans,min(A[j],j));
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
while tmp=gets
	a,b,c,d,e,f=tmp.split.map(&:to_f)
	puts sprintf("%.3f %.3f",1e-9+1.*(c*e-b*f)/(a*e-b*d),1e-9+1.*(a*f-c*d)/(a*e-b*d))
end

Measured memory_bytes: 6136
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

ll n,m,ans,cnt,fa[100001],k1,k2;

struct node{
	ll x,y,id;
}a[100001];

bool operator < (node u,node v)
{
	return u.x<v.x;
}

bool cmp(node u,node v)
{
	return u.y<v.y;
}

struct node1{
	ll x,y,val;
}c[800001];

int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f; 
}

int find(int u)
{
	return fa[u]==u ? u:fa[u]=find(fa[u]);
}

void add(int u,int vv,int val)
{
	c[++cnt]=(node1){u,vv,val};
}

bool operator < (node1 u,node1 v)
{
	return u.val<v.val;
}

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),a[i].id=i;
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++) add(a[i].id,a[i+1].id,a[i+1].x-a[i].x);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<n;i++) add(a[i].id,a[i+1].id,a[i+1].y-a[i].y);
	sort(c+1,c+cnt+1);
	for(int i=1;i<=cnt;i++)
	  if((k1=find(c[i].x))!=(k2=find(c[i].y)))
	  {
	  	fa[k1]=k2;ans+=c[i].val;
	  }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, w;
  cin >> n >> w;
  vector<ll> W(n), V(n);
  rep(i,n) cin >> W[i] >> V[i];
  vector<vector<ll> > dp(n+5, vector<ll>(w+5,0));
  rep(i,n) {
    for (int j = 0; j <= w; ++j) {
      if (j - W[i] >= 0) chmax(dp[i+1][j], dp[i][j-W[i]] + V[i]); //i番目を使う
      chmax(dp[i+1][j], dp[i][j]); //i番目を使わない
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 83328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,db[100100][20],cnt=0,dp[100100],id[100100];
bool visited[100100];
vector<P> path[225816];

struct edge{
	int to,c;
	ll d;
};

vector<edge> g[100100];

void dfs(int v, int p=0){
	int i;
	edge e;
	visited[v] = true;
	dp[v] = dp[p]+1;
	db[v][0] = p;
	id[v] = cnt; ++cnt;
	// cout << v << " ";
	for(i=(g[v].l_ength()-1); i>=0; --i){
		e = g[v][i];
		if(visited[e.to]){
			continue;
		}
		path[0].push_back(P(cnt,e.d));
		path[e.c].push_back(P(cnt,e.d));
		path[e.c+n].push_back(P(cnt,1ll));
		// cout << "( " << v << "->" << e.to << ") ";
		dfs(e.to,v);
		path[0].push_back(P(cnt,-e.d));
		path[e.c].push_back(P(cnt,-e.d));
		path[e.c+n].push_back(P(cnt,-1ll));
		// cout << "( " << e.to << "->" << v << ") ";
	}
}

int lca(int u, int v){
	int d = 0,i;
	d = dp[u] - dp[v];
	if(d < 0){
		swap(u,v);
		d = (-d);
	}
	for(i=0; i<20; ++i){
		if(d&(1<<i)){
			u = db[u][i];
		}
	}
	if(u==v){
		return u;
	}
	for(i=19; i>=0; --i){
		if(db[u][i] == db[v][i]){
			continue;
		}
		u = db[u][i];
		v = db[v][i];
	}
	return db[u][0];
}

ll query(int c, int v){
	int l,r,m;
	v = id[v];
	l = 0; r = path[c].l_ength();
	while(r-l>1){
		m = ((l+r)>>1);
		if(path[c][m].first > v){
			r = m;
		}else{
			l = m;
		}
	}
	return path[c][l].second;
}

int main(void){
	int q,i,j,x,a,b,c;
	ll d,y,ans;
	edge e;
	cin >> n >> q;
	for(i=1; i<n; ++i){
		cin >> a >> b >> e.c >> e.d; --a; --b;
		e.to = b; g[a].push_back(e);
		e.to = a; g[b].push_back(e);
	}
	for(j=0; j<n*2; ++j){
		path[j].push_back(P(-1,0ll));
	}
	dp[0] = -1; dfs(0); // cout << endl;
	for(j=1; j<20; ++j){
		for(i=0; i<n; ++i){
			db[i][j] = db[db[i][j-1]][j-1];
		}
	}
	for(j=0; j<n*2; ++j){
		for(i=1; i<path[j].l_ength(); ++i){
			path[j][i].second += path[j][i-1].second;
		}
	}
	for(i=0; i<q; ++i){
		cin >> x >> y >> a >> b; --a; --b;
		c = lca(a,b);
		ans = query(x+n,a)+query(x+n,b)-query(x+n,c)*2;
		ans *= y;
		ans -= query(x,a)+query(x,b)-query(x,c)*2;
		ans += query(0,a)+query(0,b)-query(0,c)*2;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 49100
H, W, K = map(int, input().split())
mod = 10 ** 9 + 7

# 高さiにおいて左からj番目の棒にいる通り数
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1


def pattern(w):
    """ 幅wのあみだにおいて、validなものの通り数を返す """
    # 例外処理
    if w < 0:
        return 1

    cnt = 0
    for i in range(2 ** w):
        b = bin(2 ** w + i)[3:]
        if '11' not in b:
            cnt += 1
    return cnt


for i in range(1, H + 1):
    for j in range(W):
        tmp = 0
        # 上からおりてくる
        tmp += dp[i - 1][j] * pattern(j - 1) * pattern(W - j - 2) % mod

        # 左からおりてくる
        if j > 0:
            tmp += dp[i - 1][j - 1] * pattern(j - 2) * pattern(W - j - 2) % mod

        # 右からおりてくる
        if j < W - 1:
            tmp += dp[i - 1][j + 1] * pattern(j - 1) * pattern(W - j - 3) % mod

        dp[i][j] += tmp

print(dp[H][K - 1] % mod)


Measured memory_bytes: 3064
N,M = map(int,input().split())
D = sorted([list(map(int,input().split())) for n in range(N)])
mon = 0
num = 0

for n in range(N):
  mon+=D[n][0]*D[n][1]
  num+=D[n][1]
  
  if M<=num:
    print(mon-D[n][0]*(num-M))
    break

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

#include<vector>

int main(){
	int n;
	cin>>n;
	
	/*
	char a1[]={".",",","!","?"," "};
	char a2[]={"a","b","c"};
	char a3[]={"d","e","f"};
	char a4[]={"g","h","i"};
	char a5[]={"j","k","l"};
	char a6[]={"m","n","o"};
	char a7[]={"p","q","r","s"};
	char a8[]={"t","u","v"};
	char a9[]={"w","x","y","z"};
	*/
	
	vector<string> a(10);
	a[1]=".,!? ";
	a[2]="abc";
	a[3]="def";
	a[4]="ghi";
	a[5]="jkl";
	a[6]="mno";
	a[7]="pqrs";
	a[8]="tuv";
	a[9]="wxyz";
	
	for(int k=0;k<n;k++){
		string s;
		cin>>s;
		int cnt=0;
		int mj=0;
		for(int i=0;i<s.size();i++){
			if(s[i]-'0'==0){
				if(mj!=0){
				cout<<a[mj][cnt%a[mj].size()];
				cnt=0;
				mj=0;
				}
			}else{
				if(s[i]-'0'==mj){
					cnt++;
				}else{
					mj=s[i]-'0';
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,g;
    vector<vector<int>> brojevi(3,vector<int>(3));
    vector<vector<bool>> p(3,vector<bool>(3,false));
    for (int i=0;i<3;i++)
        for (int j=0;j<3;j++)
            cin >> brojevi[i][j];
    cin >> n;
    for (int k=0;k<n;k++)
    {
        cin >> g;
        for (int i=0;i<3;i++)
            for (int j=0;j<3;j++)
                if(brojevi[i][j]==g)
                    p[i][j]=true;
    }
    if(p[0][0] && p[1][0] && p[2][0] || p[0][1] && p[1][1] && p[2][1] || p[0][2] && p[1][2] && p[2][2] ||
       p[0][0] && p[0][1] && p[0][2] || p[1][0] && p[1][1] && p[1][2] || p[2][0] && p[2][1] && p[2][2] ||
       p[0][0] && p[1][1] && p[2][2] || p[0][2] && p[1][1] && p[2][0])
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            int temp;
            for(int i = 0; i < values.length; i++){
                values[i] = i + 1;
            }
            for(int i = 0; i < n; i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;

                temp = values[a];
                values[a] = values[b];
                values[b] = temp;
            }
            for(int i = 0; i < w; i++){
                System.out.println(values[i]);
            }
        }

        
    }
}


Measured memory_bytes: 25848
import bisect

N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
MM = []
for i in range(N):
    MM.append([XL[i][0]-XL[i][1], XL[i][0]+XL[i][1]])


XL = sorted(XL)
MM.sort(key=lambda x: x[0])
MM.sort(key=lambda x: x[1])
ans = 0
now  = -float('inf')
for i in range(N):
    if MM[i][0] >= now:
        ans += 1
        now = MM[i][1]
print(ans)

Measured memory_bytes: 79832
A, B, C = map(int, input().split())

M = set()
now = A % B

while now not in M:
    M.add(now)
    now = (now + A) % B

used = [False] * B
stack = list(M)
while stack:
    x = stack.pop()
    if used[x]:
        continue
    if x == C:
        print("YES")
        break
    used[x] = True
    for m in M:
        if not used[(x + m) % B]:
            stack.append((x + m) % B)
else:
    print("NO")


Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 1001001001;
const ll LINF = 1e18;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

int main() {
    int N; cin >> N;
    ll a, idx = 1; vl as(N + 1, 0), rs(N + 1, 0);
    while (cin >> a) {
        as[idx] = a;
        rs[idx] = a - idx;
        idx++;
    }
    
    sort(rs.begin() + 1, rs.end(), greater<ll>());
    ll ret = LINF;
    ll b1 = rs[N / 2];
    ll b2 = rs[N / 2 + 1];
    auto getKanashimi = [=](const ll b){
        ll tmp = 0;
        for (int i = 1; i <= N; i++) {
            tmp += abs(as[i] - (b + i));
        }
        return tmp;
    };
    
    ret = min(ret, getKanashimi(b1));
    ret = min(ret, getKanashimi(b2));
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int x;
    scanf("%d", &x);
    int ans = 8 - (x-400) / 200;
    printf("%d\n", ans);
}

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

/**
  vector<int>ar(3);
  for(auto&e:ar){
      scanf("%d",&e);
  }
  sort(ar.begin(),ar.end())
  int sum=accumulate(ar.begin(),ar.end(),0);
 **/

int main(){
    double pai=3.141592653589;
    vector<int> ar(3);
    for(auto&e:ar){
        scanf("%d",&e);
    }
    sort(ar.begin(),ar.end());
    printf("%d %d %d\n",ar[0],ar[1],ar[2]);
    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void) {
    int n;  //今ある枚数
    int x;  //カードの数字
    char ch;  //カードの種類

    int T[4][13] = {0}; //あるかどうかは0と1で判別

    scanf("%d", &n);

    for(int i=1; i<=n; ++i) {
        scanf("%c", &ch);
        scanf("%c %d", &ch, &x);

        switch(ch) {
          case 'S': T[0][x-1] = 1;
                  break;
          case 'H': T[1][x-1] = 1;
                  break;
          case 'C': T[2][x-1] = 1;
                  break;
          case 'D': T[3][x-1] = 1;
                  break;
        }
    }

    for(int i=0; i<4; i++) {
      for(int j=0; j<13; ++j) {
        if(T[i][j] == 0) {
          switch(i) {
            case 0: printf("S %d\n", j+1);
                    break;
            case 1: printf("H %d\n", j+1);
                    break;
            case 2: printf("C %d\n", j+1);
                    break;
            case 3: printf("D %d\n", j+1);
          }
        }
      }
    }

    return 0;
}



Measured memory_bytes: 2036
/*
AizuOnline A2097

*/
#include <stdio.h>
#include <float.h>
#include <math.h>

#define PAI 3.1415926535

main()
{
  int n;
  double S,r,r1;
  while(EOF != scanf("%d",&n) && n)
    {
      if(n % 3)
	n *= 3;
      if(n==3)
	S = sqrt(3.0)/4;
      else
	{
	  r = sqrt(3.0)/3;
	  r1= r*sin(PAI/6)/sin(PAI-PAI/6-PAI/n);
	  S = n*sin(PAI/n)*r*r1;
	}
      printf("%lf\n",S);
    }

return(0);
}

Measured memory_bytes: 680
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n;
    ll c[510],s[510],f[510];
    cin>>n;
    rep(i,n-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    rep(i,n){
        ll now=0;
        rep2(j,i,n-1){
            if(now<=s[j]){
                now=s[j]+c[j];
                continue;
            }
            else{
                ll a=now/f[j];
                if(now%f[j]!=0) a+=1;
                now=a*f[j]+c[j];
            }
        }
        cout<<now<<endl;
    }
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int now = 1;
    int cnt = 0;
    while(now < b){
        cnt+=1;
        now+=(a-1);
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

lk = k.bit_length()

nc = 0
for i in range(lk):
    c = 0
    for ai in a:
        if (ai >> i) & 1:
            c += 1
    if n - c > c:
        nc |= (1 << i)

for i in reversed(range(lk)):
    ki = (k >> i) & 1
    nci = (nc >> i) & 1
    if ki == nci:
        pass
    elif ki:
        break
    else:
        nc &= ~(1 << i)

print(sum(ai ^ nc for ai in a))


Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
 int lis( int arr[], int n )  
{  
    int lis[n]; 
   
    lis[0] = 1;    
  
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 0; j < i; j++ )   
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)  
                lis[i] = lis[j] + 1;  
    } 
  
    // Return maximum value in lis[] 
    return *max_element(lis, lis+n); 
}  
void computeLPSArray(char* pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 
    
int main()
{
  fastio();
 
ll int T;
T=1;
ll int anscount=1;
while(T--)
{
    
    ll int n,m;
    cin>>n>>m;
    ll int ans= n*(n-1)/2+m*(m-1)/2;
    cout<<ans<<endl;
}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;


int main() {

	string S, T;
	bool key = false;

	cin >> S >> T;
	
	for (int i = 0; i < S.size(); i++) {
		if (S == T) {
			key = true;
		}
		S = S.back() + S.substr(0, S.size() - 1);
	}

	if (key) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int a,b,c;cin>>a>>b>>c;
  cout << (a*b)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 998244353LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    ll n, k;
    cin>>n>>k;
    pll a[k];
    for (ll i = 0; i < k; i++) {
        cin>>a[i].f>>a[i].s;
    }
    ll dp[n + 3];
    ll L, R;
    memset(dp, 0, sizeof(dp));
    dp[n] = 1;
    for (ll i = n - 1; i >= 1; i--) {
        for (ll j = 0; j < k; j++) {
            R = min(i + a[j].s, n + 1);
            L = min(i + a[j].f, n + 1);
            //cout<<"L "<<L<<" R "<<R<<"\n";
            dp[i] = add(dp[i], sub(dp[L], dp[R + 1]));
        }
        dp[i] = add(dp[i], dp[i + 1]);
        //cout<<"DP[i] "<<dp[i]<<"\n";
    }
    cout<<sub(dp[1], dp[2])<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 5196
n = int(input())

mList = []
for i in range(n):
  mList.append(list(input().split()))

sleepM = input()

sleepIndex = 0
for i in range(n):
  if mList[i][0] == sleepM:
    sleepIndex = i
    break

result = 0
for i in range(sleepIndex+1,n):
  result += int(mList[i][1])

print(result)


Measured memory_bytes: 3060
from itertools import accumulate
from collections import Counter
import sys
input = sys.stdin.readline

N = int(input())
A = [0] + list(map(int, input().split()))
a = list(accumulate(A))
av = list(Counter(a).values())

answer = sum([i * (i - 1) // 2 for i in av])

print(answer)

Measured memory_bytes: 41448
a = input()
a = a.split(' ')
b=[]
e=[]
for i in range(len(a)):
    b.append(len(a[i]))
    f=a.count(a[i])
    e.append(f)
c=a[b.index(max(b))]
g=a[e.index(max(e))]

print(g,c)


Measured memory_bytes: 5556
#include <cstdio>
#include <unordered_map>
#include <vector>
const int HASH = 131;
const int MAXN = 5005;
const int MOD = 1e9+7;
char S[MAXN];
int H[MAXN];
int N, size;

std::unordered_map<int, std::vector<int>> D;

bool compare(int a, int b) {
  for (int k = 0; k < size; ++k) {
    if (S[a-k] != S[b-k]) return false;
  }
  return true;
}

bool matches(int sum, int cur) {
  for (int pos: D.at(sum)) {
    if (pos + size > cur) break;
    if (compare(pos, cur)) {
      return true;
    }
  }
  return false;
}

bool find() {
  D.clear();
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum = (1LL * HASH * sum + S[i]) % MOD;
    if (i >= size) {
      int old = 1LL * H[size] * S[i-size] % MOD;
      sum = (sum - old + MOD) % MOD;
    }
    if (i+1 >= size) {
      if (D.count(sum) && matches(sum, i)) {
        return true;
      }
      D[sum].push_back(i);
    }
  }
  return false;
}

void init() {
  H[0] = 1;
  for (int i = 1; i <= N; ++i) {
    H[i] = 1LL * H[i-1] * HASH % MOD;
  }
}

int solve() {
  int lo = 0;
  int hi = N/2;
  while (lo < hi) {
    size = (lo + hi + 1) / 2;
    if (find()) {
      lo = size;
    } else {
      hi = size-1;
    }
  }
  return lo;
}

int main() {
  scanf(" %d%s", &N, S);
  init();
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 768
import java.util.*
import kotlin.math.floor

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val n = sc.nextLong()
    println(problem165d(a, b, n))
}

fun problem165d(a: Long, b: Long, n: Long): Long {
    val x = Math.min(b - 1, n)
    return (floor(a * x / b.toDouble()) - a * floor(x / b.toDouble())).toLong()
}

Measured memory_bytes: 36420
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)



//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL tb[2010][2010] = {};
LL s[2010][2010] = {};

//累積和の取得[y1,y2)×[x1,x2)
LL get(LL y2, LL x2, LL y1, LL x1) {
	return s[y2][x2] - s[y2][x1] - s[y1][x2] + s[y1][x1];
}

int main() {

	LL n, k; cin >> n >> k;

	for (LL i = 0; i < n; i++) {
		LL x, y; char c; cin >> x >> y >> c;
		if (c == 'W')y += k;

		y %= (2 * k);
		x %= (2 * k);

		tb[y][x]++;
	}

	//累積和の構築
	for (LL i = 0; i < 2 * k; i++) {
		for (LL j = 0; j < 2 * k; j++) {
			s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + tb[i][j];
		}
	}

	//集計
	//a:左上
	//b:右上
	//c:中央
	//d:左下
	//e:右下

	LL ans = 0;
	for (LL i = 0; i < k + 1; i++) {
		for (LL j = 0; j < k + 1; j++) {
			LL a = get(i, j, 0, 0);
			LL b = get(i, 2 * k, 0, j + k);
			LL c = get(i + k, j + k, i, j);
			LL d = get(2 * k, j, i + k, 0);
			LL e = get(2 * k, 2 * k, i + k, j + k);
			ans = max(ans, a + b + c + d + e);
			ans = max(ans, n - (a + b + c + d + e));
		}
	}


	cout << ans << endl;

	return 0;
}



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

Measured memory_bytes: 2512
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a-b << endl;
    }else{
        cout << b-a << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> g(n + 1);
	vector<ll> t(n + 1, 0), ans(n + 1);
	for (int i = 0; i < n + m - 1; ++i) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		t[b]++;
	}
	stack<ll> st;
	for (int i = 1; i <= n; ++i) {
		if (t[i] == 0) {
			st.push(i);
			ans[i] = 0;
		}
	}
	ll par = 0;
	while (!st.empty()) {
		int i = st.top();
		st.pop();
		par = i;
		for (auto j : g[i]) {
			t[j]--;
			if (t[j] == 0) {
				ans[j] = par;
				st.push(j);
			}
		}
	}
	for (int i = 1; i <= n; ++i) { dump(ans[i]); }
}

Measured memory_bytes: 7936
#include <stdio.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;
 
int main(void) {
  int n, ans = 0, inf = 10000;
  scanf("%d", &n);
  int dis[n];
  rep(i, n) dis[i] = inf;
  dis[0] = 0;
  vector< int > vec[n];
  rep(i, n) {
    int u, k;
    scanf("%d%d", &u, &k);
    u--;
    rep(j, k) {
      int v;
      scanf("%d", &v);
      v--;
      vec[u].push_back(v);
    }
  }
  rep(i, n - 1) {
    rep(j, n) {
      vector< int >::iterator it;
      for(it = vec[j].begin(); it != vec[j].end(); ++it) {
        if(dis[*it] > dis[j] + 1) dis[*it] = dis[j] + 1;
      }
    }
    /*rep(j, n) printf("%d ", dis[j]);
    printf("\n");*/
  }
  rep(i, n) {
    if(dis[i] != inf) printf("%d %d\n", i + 1, dis[i]);
    else printf("%d -1\n", i + 1);
  }
  return 0;
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
static const double pi = 3.141592653589793;

void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    int f = 6 * m;
    double t = 30 * h + m * 0.5;
    double th = t - f;
    if (th < 0) th = -th;
    if (th >180) th = 360 - th;
    cout << fixed << setprecision(10) <<  sqrt(a * a + b * b - 2 * a * b * cos(pi * th / 180)) << endl;
}

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

Measured memory_bytes: 4140
M = 10 ** 9 + 7

x, y = map(int, input().split())

r = 0
if (x + y) % 3 == 0:
  m = (x + y ) // 3
  a, b = (2 * y - x) // 3, (2 * x - y ) // 3
  if x >= m <= y:
    f = [1]
    for i in range(1, m + 1):
      f.append(f[-1] * i % M)
    r = f[m] * pow(f[a] * f[b], M - 2, M) % M
print(r)


Measured memory_bytes: 29460
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

const int MAXN = 300300;
int A[MAXN];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 3*N; i++)
		cin >> A[i];
	sort(A, A+3*N);
	ll ans = 0;
	int r = 3*N;
	for (int i = 0; i < N; i++) {
		ans += A[r-2];
		r -= 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
class Main{
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int temp=Math.abs(a-b);
			System.out.println(temp);
		}

	}
}

Measured memory_bytes: 17320
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n==1)
    {
        cout << "Hello World\n";
    }
    else
    {
        int a,b;
        cin >> a >> b;
        cout << (a+b) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<tuple>


int main(void){
	int N,A;
	std::cin>>N>>A;
	int amari=N%500;
	if(amari<=A){
		std::cout<<"Yes"<<std::endl;
	}else{
		std::cout<<"No"<<std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 5005
#define ll long long 
using namespace std;

int n,i,j,k,a[maxn],A,B,s[maxn][maxn];
ll f[maxn];

int pd(int l,int r){
	return (s[r-1][a[r]-1]-s[l][a[r]-1])-(s[r-1][a[l]]-s[l][a[l]])==0;
}

ll cnt1(int l,int r){
	return s[r-1][a[l]-1]-s[l][a[l]-1];
}
ll cnt2(int l,int r){
	if (r==n+1) return 0;
	return (s[r-1][n]-s[r-1][a[r]])-(s[l][n]-s[l][a[r]]);
}

int main(){
	scanf("%d%d%d",&n,&A,&B),a[0]=0,a[n+1]=n+1;
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) s[i][j]=s[i-1][j]+(a[i]<=j);
	memset(f,127,sizeof(f)),f[0]=0;
	for(i=1;i<=n+1;i++) for(j=0;j<i;j++) 
		if (a[i]>a[j]&&pd(j,i))
			f[i]=min(f[i],f[j]+cnt1(j,i)*B+cnt2(j,i)*A);
	printf("%lld",f[n+1]);
}

Measured memory_bytes: 99532
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	remA := a % 2
	remB := b % 2

	if remA != remB {
		fmt.Println("IMPOSSIBLE")
	} else {
		fmt.Println((a + b) / 2)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N; cin>>N;
  vec d(N);
  
  bool ans=true;
  rep(i,N){
    ll x; cin>>x;
    if(x%2==0){
      if(x%3!=0 && x%5!=0) ans=false;
    }
  }
  if(ans) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
 
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

// 1~i番目まで見たときのj分以内での最大値
ll dp[3010][3010];


int main()
{
    cout << fixed << setprecision(15);
    ll N, T;
    cin >> N >> T;

    vector<P> A(N);

    REP(i, N){
        cin >> A[i].first >> A[i].second;
    }

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

    ll ans = 0;
    REP(i, N){
        REP(j, T){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            ll nj = j + A[i].first;
            if(nj > T) continue;
            dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]+A[i].second);
        }
        ans = max(ans, dp[i][T-1] + A[i].second);
    }

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

Measured memory_bytes: 74164