akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

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

        String S = sc.next();
        int Q = sc.nextInt();
        char[] ans = new char[(S.length()) + 2*(Q)];

        for(int i = Q;i<Q+S.length();i++){
            ans[i] = S.charAt(i-Q);
        }
        int headCounter = Q-1;
        int tailCounter = Q+S.length();

        boolean isReversed = false;
        for(int i=0;i<Q;i++){
            int t = sc.nextInt();
            if(t == 1){
                isReversed = !isReversed;

            } else {
                int f = sc.nextInt();
                String C = sc.next();

                if(f == 1){
                    if(isReversed){
                        ans[tailCounter++] = C.charAt(0);
                    } else {
                        ans[headCounter--] = C.charAt(0);

                    }
                } else {
                    if(isReversed){
                        ans[headCounter--] = C.charAt(0);
                    } else {
                        ans[tailCounter++] = C.charAt(0);
                    }
                }
            }

        }
        StringBuffer sb = new StringBuffer();
        for(int i = headCounter+1; i < tailCounter;i++){
            sb.append(ans[i]);

        }
        String ansString = "";

        if(isReversed ){
            ansString = sb.reverse().toString();
        } else {
            ansString = sb.toString();

        }

        System.out.println(ansString);

    }

}









Measured memory_bytes: 133308
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2148
@a=map~~<>,1..<>;
@c=<>;
for(@a){
	($a,$b)=glob;
	$m=1e9;
	print+(grep{
		$c[$_-1]=~/ /;
		$m-=$-=$m-abs($`-$a)-abs$'-$b;
		$-
	}1..@c)[-1],$/
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,h;
    cin>>n>>h;
    int chop[100000],cast[100000];
    int strongest=0;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>chop[i]>>cast[i];
        if(chop[strongest] == chop[i] && cast[strongest] < cast[i]){
            strongest = i;
        }else if(chop[strongest] < chop[i]){
            strongest = i;
        }
    }
    int superchop = chop[strongest];
    int supercast = cast[strongest];
    //cast[strongest] = 0;
    sort(cast,cast+n);
    for(int i=n; i>=0 && h>0 ;i--){
        if(cast[i]>superchop){
            h -= cast[i];
            ans++;
        }
    }
    /*if(h>0){
        ans += h/superchop;
        h -= superchop * (h/superchop);
    }
    if(h>0){
        ans++;
    }*/
    if(h>0){
        ans+=(h+superchop-1)/superchop;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    vector<ll> ruiA(N+1), ruiB(M+1);
    rep(i, N) ruiA[i+1] = ruiA[i] + A[i];
    rep(i, M) ruiB[i+1] = ruiB[i] + B[i];
    ll ans = 0;
    ll i = 0;
    while (i <= N && ruiA[i] <= K) {
        chmax(ans, (ll)(i + upper_bound(ALL(ruiB), K-ruiA[i]) - ruiB.begin()-1));
        i++;
    }
    cout << ans << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  priority_queue<ll, vector<ll>, greater<ll>> ans;
  for (int i = 0; i <= N-K; i++) {
    ll dif = H[i+K-1] - H[i];
    ans.push(dif);
  }
  cout << ans.top() << endl;
}

Measured memory_bytes: 2168
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c, d, k;
    scan(a, b, c, d, k);
    long h;
    if (b < d)
        h += (c - a) * 60 + (d - b);
    else
        h += (c - a - 1) * 60 + (d - b) + 60;
    writeln(h - k);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
#define int ll
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
void solve(){
	ll a=read(),b=read(),c,ans;
	if (a>b) swap(a,b);
	if (a==1 && b==1){ cout<<0<<endl; return; }
	//if (a==2 && b==2){ cout<<1<<endl; return; }
	c=a*b-1; c=floor((ll)sqrt((ld)a*b-1));// if (c*c>=a*b) c--;
	ans=c*2; if (c*(c+1)>=a*b) ans--;
	if (c>=a) ans--;
	cout<<ans<<endl;
}
//#define local
signed main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	int T=read(); while (T--) solve();
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	ll n,m;
	cin>>n>>m;
	if(abs(n-m)%2!=0){
		cout<<"IMPOSSIBLE";
		return 0;
	} 
	cout<<(n+m)/2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,F,B,Z,X;
	cin>>N;
	if(100<=N&&N<=999){
	B=N/100;
	Z=(N/10)%10;
	X=N%10;
	F=(X*100)+(Z*10)+B;
	if(F==N)
	cout<<"Yes";
	else
	cout<<"No";
}
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

ll mypow(ll x, ll n) { //x^nの計算
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
    }
    x *= x;
    n >>= 1;  // n を1bit 左にずらす
  }
  return res;
}

ll hantei(int N,ll X){
  if(N==0){
    if(X==1){
      return 1;
    }
    else{
      return -1;
    }
  }
  else{
    ll num=mypow(2,N+2)-3;
    if(X==1){
      return 0;
    }
    else if(X==num){
      return 2*(mypow(2,N)-1)+1;
    }
    else if(X==(num+1)/2){
      return mypow(2,N);
    }
    else if(X<(num+1)/2){
      return hantei(N-1,X-1);
    }
    else{
      return mypow(2,N)+hantei(N-1,X-(num+1)/2);
    }
  }
}

int main(){
  int N;
  cin >> N;
  ll X;
  cin >> X;
  cout << hantei(N,X) << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  while(1){
    int N,A,B,C,X;
    cin >> N >> A >> B >> C >> X;
    if(N==0&&A==0&&B==0&&C==0&&X==0)break;
    int count=0;
    for(int i=0;i<N;i++){
      int y;
      cin >> y;
      for(int j=0;count<=10001;j++){
        bool ok=false;
        if(X==y){
          ok=true;
        }
        count++;
        X=(A*X+B)%C;
        if(ok)break;
      }
    }
    count--;
    if(count>10000)count = -1;
    cout << count << endl;
  }
}



Measured memory_bytes: 3044
import sys
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	dp=list(range(10**5+1))
	x=[]
	a=6
	while a<10**5:
		x.append(a)
		a*=6
	a=9
	while a<10**5:
		x.append(a)
		a*=9
	x.sort()
	#print(x)

	#print(dp)

	for i in x:
		for j in range(i,10**5+1):
			dp[j]=min(dp[j],dp[j-i]+1)
	print(dp[n])



if __name__ == "__main__":
	main()


Measured memory_bytes: 66112
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int W, H, N; std::cin >> W >> H >> N;
  int wmin = 0, wmax = W;
  int hmin = 0, hmax = H;
  rep(i, N) {
    int x, y, a; std::cin >> x >> y >> a;
    if ( a == 1 ) wmin = std::max(x,wmin);
    if ( a == 2 ) wmax = std::min(x,wmax);
    if ( a == 3 ) hmin = std::max(y,hmin);
    if ( a == 4 ) hmax = std::min(y,hmax);
  }
  
  if ( wmin > wmax || hmin > hmax ) std::cout << 0 << std::endl;
  else std::cout << (wmax-wmin)*(hmax-hmin) << std::endl;
  return 0;
}


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

int main()
{
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[(p*(p+1)/2)/p for i,p in enumerate(P) ]
ans=sum(E[:K])
_=sum(E[:K])
for i in range(1,N-K+1):
  _-=E[i-1]
  _+=E[i+K-1]
  if _>ans:
    ans=_
print(ans)

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

void set_color(const vector<vector<int> >& u, int p, vector<int>& color, int c) {
    if (color[p] != -1) return;
    color[p] = c;
    for (int i = 0; i < u[p].size(); i++) {
        set_color(u, u[p][i], color, c);
    }
}

bool is_friend(const vector<vector<int> >& u, int s, int t){
    static vector<int> color(u.size(), -1);
    static int c = 0;
    set_color(u, s, color, c++);
    return color[s] == color[t];
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > u(n);
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        u[s].push_back(t);
        u[t].push_back(s);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        if (is_friend(u, s, t)) {
            cout << "yes" << endl;
        } else {
            cout << "no"  << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 11740
#include <bits/stdc++.h>
#define MAXN 1001
#define MAXA 10001

using namespace std;
typedef long long ll;
ll A[MAXN];
ll B[MAXN];
ll dp[MAXA];

int main()
{
    ll H,N;
    cin>>H>>N;
    fill(dp,dp+H+1,LONG_LONG_MAX);
    dp[0] = 0;
    for(ll i = 0;i < N;i ++)
    {
        cin>>A[i]>>B[i];
    }
    for(ll i =0 ;i < N;i ++)
    {
        for(ll j = 1;j <= H;j ++)
        {
            if(j >= A[i])
                dp[j] = min(dp[j],dp[j-A[i]] + B[i]);
            else dp[j] = min(dp[j],B[i]);
        }
    }
    cout<<dp[H]<<endl;
    return 0;
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n, m;  cin >> n >> m;
  vector<int> h(n); cin >> h;
  vector<int> good(n, 1);
  while (m--){
    int u, v; cin >> u >> v;  u--, v--;
    if(h[u]>=h[v]) good[v] = 0;
    if(h[v]>=h[u]) good[u] = 0;
  }
  cout << count(good.begin(), good.end(), 1) << "\n";
  return 0;
}

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

int main() {
	vector<int> vec(3);
	for (int i = 0; i < 3; i++)
		cin >> vec.at(i);
	sort(vec.begin(), vec.end());
		cout << vec.at(2)*10+vec.at(1)+vec.at(0) << endl;
	return 0;
}


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

int main(){
    int N; cin >> N;
    for(int i = 0; i < N; i++){
        int n, k; cin >> n >> k; 
        vector<int> x(n);    
        vector<int> dist(n-1); //家から家までの距離
        for(int j = 0; j < n; j++){
            cin >> x.at(j);
        }
        for(int j = 0; j < n-1; j++){
            dist.at(j) = x.at(j + 1) - x.at(j);
        }
        sort(dist.rbegin(), dist.rend()); //大きい順にソート
        int ans = x.at(n-1) - x.at(0); //端から端までの距離
        if(k >= n) cout << 0 << endl; //発電所が家の数以上なら0
        else{
            for(int j = 0; j < k - 1; j++){ //家の間隔が大きい所は電線を通さない(k-1個分省略)
                ans -= dist.at(j);
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3612
import sys

TABLE_SIZE = 1000000
table = [None] * TABLE_SIZE


def insert(value):
    index = hash(value) % TABLE_SIZE
    values = table[index]
    if not values:
        values = table[index] = []
    values.append(value)


def find(value):
    index = hash(value) % TABLE_SIZE
    values = table[index]
    if not values:
        return False
    return value in values


n = int(sys.stdin.readline())
for _ in range(n):
    command, value = sys.stdin.readline().split()
    if command == 'insert':
        insert(value)
    else:
        print('yes' if find(value) else 'no')



Measured memory_bytes: 73280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l;
  cin >> l;
  for(int j=0; j<l; j++){
    int t,n,max=0,min=0,s;
    int a[100];
    cin >> t;
    for(int i=0; i<t; i++){
	  cin >> n;
	  a[i] = n;
    }
    for(int i=t-1; i>0; i--){
  	s = a[i] - a[i-1];
  	if(s>max) max = s;
  	if(s<min) min = s;
    }
  min = min*(-1);
  cout << max << " " << min << endl;
  }
  return 0;
}
  


Measured memory_bytes: 2996
def func(p,q):
    x=p[0]-q[0]
    y=p[1]-q[1]
    return [x,y]
def fun(p,q):
    x=p[0]+q[0]
    y=p[1]+q[1]
    return [x,y]

x1,y1,x2,y2=map(int,input().split())
p1=[x1,y1]
p2=[x2,y2]
d=func(p2,p1)
d=[-d[1],d[0]]
p3=fun(p2,d)
d=[-d[1],d[0]]

p4=fun(p3,d)
x3=p3[0]
y3=p3[1]
x4=p4[0]
y4=p4[1]
print(x3,y3,x4,y4)


Measured memory_bytes: 38384
n = int(input())
c = [0 , 0 , 0 , 0]
for i in range(n):
    s = input()
    if s == "AC":
        c[0] += 1
    elif s == "WA":
        c[1] += 1
    elif s == "TLE":
        c[2] += 1
    elif s == "RE":
        c[3] += 1
print("AC x " + str(c[0]))
print("WA x " + str(c[1]))
print("TLE x " + str(c[2]))
print("RE x " + str(c[3]))

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 3.141592653589793238;
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return true; } return false; }


int main(){
  ll n;
  cin >> n;
  vector<pair<double, pair<ll, ll>>> a(n);
  for(auto& i : a){
    cin >> i.second.first >> i.second.second;
    i.first = atan2(i.second.first, i.second.second);
  }
  
  sort(a.begin(), a.end());
  for(ll i = 0; i < n * 2; i++) a.emplace_back(a[i].first + 2 * PI, a[i].second);
  
  double ans = 0;
  ll x = 0, y = 0, l = 0, r = 0;
  while(l < n){
    if(a[r].first - a[l].first < PI){
      x += a[r].second.first;
      y += a[r].second.second;
      r++;
    }
    else{
      x -= a[l].second.first;
      y -= a[l].second.second;
      l++;
    }
    chmax(ans, sqrt(x*x+y*y));
  }
  
  printf("%.20f", ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
using namespace std;
string s = "";
int n, p;

main()
{
    cin >> n;
    int c = 1;
    stack<int> st;
    for (int i = 0; i < n; i++)
    {
        cin >> p;
        while (c <= p)
        {
            st.push(c);
            s += '(';
            c++;
        }
        if (!st.empty() && st.top() == p)
        {
            s += ')';
            st.pop();
        }
        else
        {
            cout << ":(" << endl;
            return 0;
        }
    }
    cout << s << endl;
}



Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double,int> P;
typedef pair<P,ll> T;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-15
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
int d;
int l[305];
int s;
ModInt dp[2][2][100000];
int main(){
	scanf("%d",&d);
	for(int i=0;i<d;i++)scanf("%d",&l[i]);
	scanf("%d",&s);
	dp[0][0][0]=ModInt(1);
	for(int i=0;i<d;i++){
		for(int j=0;j<=300*(i+1);j++){
			dp[(i+1)%2][0][j]=dp[i%2][0][j];
			dp[(i+1)%2][1][j]=dp[i%2][1][j];
			if(j>=l[i])dp[(i+1)%2][1][j]+=dp[i%2][0][j-l[i]];
			if(j>=l[i])dp[(i+1)%2][0][j]+=dp[i%2][1][j-l[i]];
		}
	}
	ModInt ans;
	for(int i=0;i<=s;i++){
		ModInt a = ModInt(s-i);
		ans += a.exp((ll)d)*dp[d%2][0][i];
		ans -= a.exp((ll)d)*dp[d%2][1][i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6340
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
  if(H==0&&W==0){
    break;
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      printf("#");
    }
    printf("\n");
  }
  printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2104
N, K = map(int, input().split())

first = 0
second = 0
result = 0
mod = 10 ** 9 + 7

for i in range(K):
    first += i
    second += N - i

result = (result + second - first + 1) % mod

for i in range(K, N + 1):
    first += i
    second += N - i
    result = (result + second - first + 1) % mod

print(result)

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

string yorn(bool a){ if(a) return "Yes" ; return "No" ; }

int main(){
    string s,t ;
    cin >> s >> t ;
    sort(s.begin(),s.end()) ;
    sort(t.begin(),t.end()) ;
    reverse(t.begin(),t.end()) ;
    cout << yorn(s<t) << endl ;
}


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

signed main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    //長さaの辺が何本あるか調べる
    vector<int> l(1001);
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        l.at(a) ++;
    }

    //無駄な部分は消す
    while(l.at(l.size()-1) == 0){
        l.pop_back();
    }
    int m = l.size();

    //累積和。長さi以下の辺の本数を調べる。
    vector<int> r(m);
    for(int i = 1;i < m;i ++){
        r.at(i) = r.at(i-1) + l.at(i);
    }

    ll ans = 0;

    //すべての辺の長さが異なるとき。
    //iは一番短い辺。jは二番目に短い辺。
    //(iの本数)×(jの本数)×(j+1 ~ i+j-1の本数の合計)
    for(int i = 2;i < m-2;i ++){
        for(int j = i+1;j < m-1;j ++){ 
            ans += l.at(i) * l.at(j) * (r.at(min(m-1,j+i-1)) - r.at(j));
        }
    }

    //長さの同じ辺が２本あるとき。
    //同じ２辺の選び方× 1~2*i-1までの本数。(iは除く)
    for(int i = 2;i < m;i ++){
        if(l.at(i) > 1){
            ans += (l.at(i) * (l.at(i)-1) / 2) * (r.at(min(m-1,2*i-1)) - l.at(i));
        }
    }

    //すべて同じ長さの時。
    for(int i = 1;i < m;i ++){
        if(l.at(i) > 2){
            ans += (l.at(i) * (l.at(i)-1) * (l.at(i)-2)) / 6;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[2][n];
  for (int i = 0; i < n; i++) cin >> a[0][i];
  for (int i = 0; i < n; i++) cin >> a[1][i];
  int sum = 0;
  int max = 0;
  for (int i = 0; i < n; i++) {
    sum = 0;
    for (int j = 0; j <= i; j++) {
      sum += a[0][j];
    }

    for (int j = i; j < n; j++) {
      sum += a[1][j];
    }
    
    if (max < sum) {
      max = sum;
    }
  }

  printf("%d\n", max);
}


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

const int M = 110;

int n;
int t[M];
char s[M][M];

int main () {
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; i++) scanf("%s %d", s[i], &t[i]);
        char x[M];
        scanf("%s", x);
        int res = 0;
        int f = 0;
        for (int i = 0; i < n; i++) {
            if (f) res += t[i];
            if (strcmp(s[i], x) == 0) f = 1;
        }
        printf("%d\n", res);
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=0, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a>>m>>b;
  /*ll ar[n];
  rep(i,0,n){ cin>>ar[i];k+=ar[i];}
  m=abs(k-ar[0]);
  rep(i,0,n)
  {
    b+=ar[i];
    ll z=k-b;
    m=min(m,abs(z-b));*/
 double z=((double)(n)*(double)(a))/(double)(2);
 cout<<z<<" ";
 if(2*m==n && 2*b==a) cout<<1;
 else cout<<0;
  //k=min(n+a,min(n+b,a+b));
 // cout<<m;
  /*if(n<a) cout<<0;
  else cout<<10;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int m, n;
int p[20001] = {};
int c[505], e[505];

int dp[505][20001];
int INF = 1e9+7;
int ans = 0;

int main(){
	scanf("%d %d", &m, &n);
	for(int i=0; i<m; i++) scanf("%d", &p[i]);
	for(int i=1; i<n+1; i++) scanf("%d %d", &c[i], &e[i]);
	sort(p, p+m, greater<int>() );
	for(int i=1; i<20001; i++) p[i] += p[i-1];
	for(int i=0; i<501; i++)
		for(int j=1; j<20001; j++) dp[i][j] = INF;

//	for(int i=0; i<20001; i++) printf("%d\n", p[i]);

	for(int i=1; i<n+1; i++){
		for(int j=1; j<20001; j++){
			if(j-c[i]>=0){
				dp[i][j] = min(dp[i][j], dp[i-1][j-c[i]] + e[i]);
			}
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			ans = max(ans, p[j-1] - dp[i][j]);
//			if(j < 10) printf("%d %d %d %d %d\n",ans, i, j, p[j-1], dp[i][j]);
		}
	}
//	printf("%d\n", dp[1][10000]);
/*
	for(int i=0; i<n+5; i++){
		for(int j=0; j<m+5; j++){
			printf("%d\t", dp[i][j]);
		}
		printf("\n");
	}
*/
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 42048
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

/*******************************************************************/

var n, m int

type bridge struct {
	start, end int
}
type Interface []*bridge

func (b Interface) Len() int {
	return len(b)
}
func (b Interface) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}
func (b Interface) Less(i, j int) bool {
	return b[i].end < b[j].end
}

func main() {
	tmp := NextIntsLine()
	n, m = tmp[0], tmp[1]
	bridgeSlice := []*bridge{}
	for i := 0; i < m; i++ {
		tmp = NextIntsLine()
		bridgeSlice = append(bridgeSlice, &bridge{start: tmp[0], end: tmp[1]})
	}
	sort.Sort(Interface(bridgeSlice))

	answer := 0
	prev := -1
	for _, b := range bridgeSlice {
		// すでに侵略不可となっている場合はスキップ
		if b.start <= prev {
			continue
		}
		// 橋を壊す
		prev = b.end - 1
		answer++
	}
	fmt.Println(answer)
}


Measured memory_bytes: 7424
N,H = map(int,input().split())
K = [list(map(int,input().split())) for n in range(N)]
A = max(k[0] for k in K)
B = sorted(b for a,b in K if A<b)
C = 0

while 0<H and B:
  H-=B.pop()
  C+=1

print(C-(-max(0,H)//A))

Measured memory_bytes: 28208
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	public void run()
	{
		Scanner file = new Scanner(System.in);
		int N = file.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int ans = 0;
		for(int i = 0;i<N;i++)
			a[i] = file.nextInt();
		for(int i = 0;i<N;i++)
			b[i] = file.nextInt();
		for(int i = 0;i<N;i++)
			ans += Math.max(0,a[i]-b[i]);
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	unsigned long long N, ans = 0, i = 1;
	cin >> N;

	while (i <= N)
	{
		if (i % 3 == 0 || i % 5 == 0)
		{
			//
		}
		else
		{
			ans += i;
		}

		i++;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int i,t;
    cin >> i >> t;
    cout << ((i%t)?1:0) << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())

A = [int(i) for i in input().split()]

plus = [0] * (N-1)
for i in range(N-1):
  plus[i] = i + A[i]

minus = [0] * (N-1)
for j in range(1, N):
  minus[j-1] = j - A[j]

sum = 0
c = dict(collections.Counter(minus))
for i in range(N-1):
  sum += c.get(plus[i], 0)
  c[minus[i]] -= 1

print(sum)

Measured memory_bytes: 55444
from collections import defaultdict, deque
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = defaultdict(list)
  par =  [0]*N
  cnt = [0]*(N+1)
  for a,b in zip(*[iter(L)]*2):
    dic[a] += [b]
    cnt[b] += 1

  for i in range(1,N+1):
    if cnt[i]==0:
      q = deque([i])
      par[i-1] = '0'
      break
  
  while q:
    m = q.popleft()
    for c in dic[m]:
      cnt[c] -= 1
      if cnt[c]==0:
        par[c-1] = str(m)
        q += [c]

  ans = '\n'.join(par)
  print(ans)
  
if __name__== '__main__':
  main()

Measured memory_bytes: 37140
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    else {
        if(s.length() != 26) {
            vector<int> v(26, -1);
            rep(i,0,s.length()) {
                v[ s[i] - 'a' ] = i;
            }

            string ans = s;
            rep(i,0,26) {
                if(v[i] < 0) {
                    ans += ('a' + i);
                    break;
                }
            }
            cout << ans << endl;
        }
        else {
            const int N = 26;
            repr(i,N-2,0) {
                bool found = false;
                int mi = N;
                rep(j,i+1,N) {
                    if(s[i] - 'a' < s[j] - 'a') {
                        found = true;
                        chmin(mi, (ll)(s[j] - 'a'));
                    }
                }
                if(found) {
                    s = s.substr(0, i) + (char)('a' + mi);
                    break;
                }
            }

            cout << s << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
s = [i for i in d if d[i] >= 2] + [0, 0]
s.sort(reverse=True)
if d.get(s[0], 0) >= 4:
    print(s[0]**2)
else:
    print(s[0]*s[1])

Measured memory_bytes: 18060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

struct TWO {
	long long int a, b;
};

bool cmp(TWO x, TWO y) {
	return x.a < y.a;
}

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	string str,str2;
	cout << fixed << setprecision(10);
	long long int n, c,m,nokori, L[200000],res=0,restmp=0,d=0,left=0,right,num;
	TWO two[200001];
	cin >> n >> m >> d;
	num = max(2 * (n - d),0LL);
	if (d == 0) { num = n; }
	
	cout << (long double)(m - 1) * (long double)num / (long double)(n*n) << endl;
} 


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'

int main () {
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	string n;
	// stops reading at the first non-numeric character, which is the newline
	cin >> n;

	for (int i = 0; i < n.length(); i++) {
		if (n[i] == '7') {
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";

	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (4 * i + 7 * j == N)
			{
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 0 && b == 0) break;
            if (a > b) {
                int t = a;
                a = b;
                b = t;
            }
            System.out.println(a + " " + b);
        }
    }
}

Measured memory_bytes: 35604
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	a, b, c := nextInt(), nextInt(), nextInt()
	m1 := a % b
	s := 0
	for i := 1; ; i++ {
		s += a
		if m := s % b; m == c {
			out("YES")
			return
		} else if i > 1 && m == m1 {
			break
		}
	}
	out("NO")
}


Measured memory_bytes: 640
//
//  main.cpp
//  Wall
//
//  Created by wenhan on 2017/11/18.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
bool f[10];
int x[10][10];
int v[10],mmin;
void jisuan(int n,int s){
    if(n==1)
    {
        mmin=min(s, mmin);
        return ;
    }
    for(int i=0;i<=9;i++)
        if(f[i]==false&&i!=n)
    {
        s+=x[n][i];
        f[i]=true;
        jisuan(i,s);
        s-=x[n][i];
        f[i]=false;
    }
}
int main() {
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++)
            scanf("%d",&x[i][j]);
    for(int i=0;i<=9;i++)
    {
        mmin=0xffffff;
        memset(f, false, sizeof(f));
        jisuan(i,0);
        v[i]=mmin;
    }
    int y;
    int s=0;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        {
            scanf("%d",&y);
            if(y!=-1)
                s+=v[y];
        }
    printf("%d\n",s);
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A_arr = [int(x) for x in input().split()]

A_max = max(A_arr)
A_min = min(A_arr)

ans_arr = []
if A_max > -A_min:
    Am = A_arr.index(A_max)
    for i in range(len(A_arr)):
        if i == Am:
            continue
        ans_arr.append((Am+1, i+1))
    for i in range(len(A_arr)-1):
        ans_arr.append((i+1, i+2))
else:
    Am = A_arr.index(A_min)
    for i in range(len(A_arr)):
        if i == Am:
            continue
        ans_arr.append((Am+1, i+1))
    for i in range(len(A_arr)-1, 0, -1):
        ans_arr.append((i+1, i))

print(len(ans_arr))
for i,j in ans_arr:
    print(i,j)



Measured memory_bytes: 3064
N,H,W= map(int,input().split())
a = [[]*N]*N
for i in range(N):
    a[i]=input().rstrip().split()


count=0
for i in range(0,N):
    if ((int(a[i][0])>=H)and(int(a[i][1])>=W)):
        count+=1


print(count)

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

int main(){
  int n, l, r;
  int ans = 0;
  cin >> n;
  rep(i, n) {
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func f(N int, a []int) ([]int, bool) {
	b := make([]int, N+1)
	x := N
	flg := false
	for i := 0; i < N; i++ {
		if a[i] != x {
			flg = true
		}
		f := max(0, i-a[i])
		t := min(N, i+a[i]+1)
		b[f]++
		b[t]--
	}
	for i := 1; i <= N; i++ {
		b[i] += b[i-1]
	}
	return b, flg
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N+1)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	flg := true
	for i := 0; i < K; i++ {
		a, flg = f(N, a)
		if flg == false {
			// out(i)
			break
		}
	}
	ans := a
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < N; i++ {
		fmt.Fprint(w, ans[i], " ")
	}
	fmt.Fprintln(w)
}


Measured memory_bytes: 10332
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  int r,b;
  r = 0;
  b = 0;
  cin >> n >> s;
  for(int i = 0;i < n;i++){
    if(s[i] == 'R')r++;
    else b++;
  }
  if(r > b)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int N = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

inline ll read()
{
	ll x = 0; int f = 1, c = getchar(); 
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; 
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); 
	return x * f; 
}

string s; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	cin >> s; 
	sort(all(s)); 
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) puts("Yes"); 
	else puts("No"); 
	
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<tuple<string,ll,ll>> a(n);
  rep(i,n) {
    string s;
    ll p;
    cin >> s >> p;
    a[i] = tuple(s,-1*p,i+1);
  }
  Sort(a);
  rep(i,n) {
    cout << get<2>(a[i]) << '\n'; 
  }
}

Measured memory_bytes: 3592
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

if N == 0:
    x = A[0]
    if x == 1:
        print(1)
    else:
        print(-1)
    exit()

INF = 1 << 60

bound = [0] * (N + 1)
bound[0] = 1
ok = True
for n in range(1, N + 1):
    bound[n] = min(INF, (bound[n - 1] - A[n - 1]) * 2)
    if bound[n] < A[n]:
        ok = False

if not ok:
    print(-1)
    exit()

B = [0] * (N + 2)
for n in range(N, -1, -1):
    x = min(bound[n], B[n + 1] + A[n])
    B[n] = x

print(sum(B))



Measured memory_bytes: 645536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int days = sc.nextInt();
        int n = sc.nextInt();
        int[] hw = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++){
            hw[i] = sc.nextInt();
            sum += hw[i];
        }
        int result = days - sum;
        if (result >= 0){
            System.out.println(result);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 46268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const p=31,mod=1e9+9;
ll pw[300];
ll sq(ll a){
	return (a*a)%mod;
}
ll exp(ll a,ll b){
	if(b==0)return 1;
	if(b==1)return a;
	if(b&1){
		return (a*sq(exp(a,b>>1)))%mod;
	}
	return sq(exp(a,b>>1))%mod;
}
ll inv(ll a){
	return exp(a,mod-2);
}
int main(){
	string s;cin>>s;
	pw[0]=1;
	ll hash[300];
	hash[0]=0;
	for(int i=1;i<=200;i++){
		pw[i]=pw[i-1]*p;
		pw[i]%=mod;
	}
	for(int i=1;i<=s.size();i++){
		hash[i]=(hash[i-1]+s[i-1]*pw[i])%mod;
	}
	for(int i=s.size()-3;i>0;i-=2){
		// cout<<(i+1)<<' '<<(((hash[i+1]-hash[(i+1)/2]+mod)%mod)*inv(pw[(i+1)/2]))%mod<<endl;
		// cout<<(i+1)/2<<' '<<hash[(i+1)/2]<<endl;
		if(hash[(i+1)/2]==(((hash[i+1]-hash[(i+1)/2]+mod)%mod)*inv(pw[(i+1)/2]))%mod){
			cout<<i+1;return 0;
		}
	}
}

Measured memory_bytes: 3624