akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline

    K, q = map(int, input().split())
    D_raw = list(map(int, input().split()))
    for _ in range(q):
        N, x, M = map(int, input().split())

        x %= M
        a = (N-1) % K
        b = (N-1) // K
        D = [0] * K
        zero_num = 0
        zero_num_2 = 0
        for i in range(K):
            d = D_raw[i]%M
            D[i] = d
            if not d:
                zero_num += 1
                if i < a:
                    zero_num_2 += 1
        ans = N - 1 - zero_num * b - zero_num_2 - (sum(D) * b + sum(D[:a]) + x) // M
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48348
O=list(input())
E=list(input())
a=[]

if len(O)-len(E)==0:
    for i in range(len(O)):
        a.append(O[i])
        a.append(E[i])
else:
    for i in range(len(O)-1):
        a.append(O[i])
        a.append(E[i])
    a.append(O[len(O)-1])
b=''
for x in a:
    b += x

print(b)

Measured memory_bytes: 3064
H, W = 3, 2
ARR = [
    [1, 0],
    [2, 1],
    [1, 0]
]

H,W = map(int, input().split())
ARR = [list(map(int,input().split())) for i in range(H)]

def calculate(h, w, arr):
    ptt = []
    total = 0
    for i in range(h - 1):
        for j in range(w):
            if arr[i][j] % 2 == 1:
                arr[i][j] = arr[i][j] - 1
                arr[i + 1][j] = arr[i + 1][j] + 1
                total += 1
                ptt.append([str(i+1), str(j+1), str(i + 1 + 1), str(j + 1)])

    for j in range(w-1):
        if arr[-1][j] % 2 == 1:
            arr[-1][j] = arr[-1][j] - 1
            arr[-1][j+1] = arr[-1][j+1] + 1
            total += 1
            ptt.append([str(h-1 + 1), str(j + 1), str(h-1 + 1), str(j+1 + 1)])

    print(total)
    for pt in ptt:
        print(" ".join(pt))


calculate(H, W, ARR)


Measured memory_bytes: 56316
from itertools import combinations
MOD = 10**9 + 7

N, K = map(int, input().split())
*A, = map(int, input().split())

pos, neg = (0, 0)
for a1, a2 in combinations(A, 2):
    if a1 < a2:
        pos += 1
    elif a1 > a2:
        neg += 1
ans = (K * max(0, K-1) // 2 * pos) % MOD + (K * neg) % MOD + (K * (K-1) // 2 * neg) % MOD
print(ans % MOD)

Measured memory_bytes: 3188
def readinput():
    a,b,n=list(map(int,input().split()))
    return a,b,n

def main(a,b,n):
    m=int(min(b,n)*a/b)+1
    maxdif=0
    for xx in range(0,m):
        if b*xx%a==0:
            x=b*xx//a
        else:
            x=int(b/a*xx)+1
        maxdif=max(maxdif,int(a*x/b)-a*int(x/b))
    return maxdif

if __name__=='__main__':
    a,b,n=readinput()
    ans=main(a,b,n)
    print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    char X, Y;
    cin >> X >> Y;
    if(X < Y) {
        cout << "<" << endl;
        return 0;
    } else if(X > Y) {
        cout << ">" << endl;
        return 0;
    }
    cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
bool bo[1000000000];
int main() {
	long long a[2],k,ans[1000],cnt=0;
	scanf("%lld%lld%d",&a[0],&a[1],&k);
	sort(a,a+1);
	for(int i=0;i<k;i++) {
		if(a[0]+i<=a[1])
			ans[++cnt]=a[0]+i, ans[++cnt]=a[1]-i;
		else
			break;	
	}
	sort(ans+1,ans+1+cnt);
	for(int i=1;i<=cnt;i++)
		if(!bo[ans[i]])
			printf("%lld\n",ans[i]), bo[ans[i]]=1;

}

Measured memory_bytes: 2176
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 ll n;
 cin>>n;
 string s;
 cin>>s;
 ll st=n;
 ll e=-1;
 fr(n)
 {
  if(s[i]=='W')
  {
    st=i;
    break;
  }
}
  for(int i=n-1;i>=0;i--)
  {
    if(s[i]=='R')
    {
      e=i;
      break;
    }
  }
  if(st==n||e==-1)
    cout<<0;
  else{
    ll a=0;
  rep(i,st,e+1)
  {
    if(s[i]=='R')
      a++;
    
  }
  ll temp=a;
  rep(i,st,st+temp)
  {
    if(s[i]=='R')
      a--;
  }
  cout<<a;
}
 
 
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3776
var
  a, b, h, m, distance, angle: Double;

begin
  read(a);
  read(b);
  read(h);
  read(m);

  angle := abs(((30 * h) - (5.5 * m)));

  distance := sqrt((sqr(a) + sqr(b)) - (2 * (a) * (b) * Cos(angle * pi / 180)));

  writeln(distance);

end.

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

using ll=long long; 

void solve(){
	ll a,b,x;
	cin>>a>>b>>x;
	ll u,w;
	u=a/x*x;
	if(u<a)u+=x;
	w=b/x*x;
	cout<<(w-u)/x+1<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

vector<pair<long long, int>> factor(long long x) {
    vector<pair<long long, int>> res;
    for (long long i = 2; i*i <= x; ++i) {
        if (x % i) continue;
        res.emplace_back(i, 0);
        while (x % i == 0) {
            x /= i;
            res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    combination c(n+100);

    auto f = factor(m);
    mint ans = 1;
    for (auto p : f) {
        ans *= c(n-1 + p.se, p.se);
    }
    cout << ans << endl;
}

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

///--->>> CONTAINERS <<<---///
using i64 = int64_t;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using stk = stack<ll>;
using kiwi = queue<ll>;
using pkiwi = priority_queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;

///--->>> MACROS<<<---///
const ll mx = 3e5+123;
#define MOD 1000000007
#define REP(i,n) for (ll i=1;i<=n;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

///--->>>OPTIMIZE<<<---///
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

///--->>> DEBUGGER<<<---///
#define dbg(args...) do {cerr<<#args<<" : "; diraf(args); } while(0)
void diraf ()  {        cerr << endl;}
template < typename T, typename ... hello>void diraf( T arg, const hello &... rest) {cerr<<arg<< ' ';diraf(rest...);}

int main(int argc, char* argv[]){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ///cout<<fixed<<setprecision(20);
    string str; cin>>str;
    if(str[str.size() - 1]=='s') cout<<str<<"es"<<endl;
    else cout<<str+'s'<<endl;


return 0;
}


Measured memory_bytes: 3652
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int k,x;
  cin >> k >> x;

  for(int i = x-k+1; i <= x+k-1; i++) cout << i << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int X,Y;
  int i;
  
  cin>>X>>Y;

  if(!(X%Y)){
    cout << -1 << endl;
  }else{
    for(i=2;!((X*i)%Y);i++)
      ;
    cout << (X*i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
"""
Cython test
"""
from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(N, M, edges):
    longest = [-1] * (N + 1)

    def get_longest(start):
        if longest[start] != -1:
            return longest[start]

        next_edges = edges.get(start)
        if not next_edges:
            ret = 0
        else:
            ret = max(get_longest(v) for v in edges[start]) + 1
        longest[start] = ret
        return ret

    return max(get_longest(v) for v in edges)


T1 = """
4 5
1 2
1 3
3 2
2 4
3 4
"""

T2 = """
6 3
2 3
4 5
5 6
"""

T3 = """
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
"""


def main():
    N, M = map(int, input().split())
    edges = defaultdict(set)
    for i in range(M):
        v1, v2 = map(int, input().split())
        edges[v1].add(v2)

    print(solve(N, M, edges))


def _test():
    """
    # >>> as_input(T1)
    # >>> main()
    # 3

    # >>> as_input(T2)
    # >>> main()
    # 2

    >>> as_input(T3)
    >>> main()
    3
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 212492
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    bool ok = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int a,b,c;
    std::cin >> a >> b >> c;
    std::vector<int> v { a, b, c };
    std::sort(v.begin(), v.end());
    int x1 = v[2] + v[1] - 2 * v[0];
    int x2 = (v[2] - v[1]) + (v[1] - v[0]) / 2 + (((v[1] - v[0]) % 2) ? 2 : 0);
    int x3 = (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
    if ((v[2] - v[1]) % 2) {
        if ((v[2] - v[0]) % 2) x3++;
        else x3 += 2;
    } else {
        if ((v[2] - v[0]) % 2) x3 += 2;
    }
    std::cout << std::min({ x1, x2, x3 }) << std::endl;
}

Measured memory_bytes: 256
from math import gcd
n=int(input())
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        gcd_ij=gcd(i,j)
        for k in range(1,n+1):
            ans+=gcd(gcd_ij,k)
print(ans)
    
            

Measured memory_bytes: 9184
#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())
#define mod 1000000007
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
void solve()
{
    ll a,b,c,d ;
    cin >> a >> b >> c >> d;
    cout << abs(c-a)*(abs(d-b)) << endl;
}
int main()
{
  fast();
  solve();

return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	cin >> s;
	int i, n = s.size();
	string s2;
	for (i = 0; i < n; i++) {
		if (s[i] != 'x') {
			s2.push_back(s[i]);
		}
	}
	string s3;
	s3 = s2;
	reverse(s2.begin(), s2.end());
	if (s3 != s2) {
		cout << -1 << endl;
		return 0;
	}
	int left = 0, right = n - 1;
	ll ans = 0;
	while (left < right) {
		if (s[left] == s[right]) {
			left++; right--;
		}
		else if (s[left] == 'x') {
			ans++;
			left++;
		}
		else {
			ans++;
			right--;
		}
	}
	cout << ans << endl;
}

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

int		main(void)
{
	int		N, M;

	cin >> N >> M;
	vector<int> Ai(N);
	double	sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> Ai.at(i);
		sum += Ai.at(i);
	}
	int		counter = 0;
	for (auto &i : Ai)
	{
		if (i >= sum / (4 * M)) counter++;
	}
	if (counter >= M)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

namespace AtCoder
{
	public class Program
	{
		// ABC107-B
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split();
			int H = int.Parse(vs[0]);
			int W = int.Parse(vs[1]);
			string[] map = new string[H];
			bool[] col = new bool[W];
			int y = 0;
			for (int i = 0; i < H; i++) {
				string s = Console.ReadLine();
				bool row = false;
				for (int j = 0; j < s.Length; j++) {
					bool f = s[j] == '#';
					col[j] |= f;
					row |= f;
				}
				if (row) {
					map[y] = s;
					y++;
				}
			}
			for (int i = 0; i < y; i++) {
				string s = "";
				for (int x = 0; x < map[i].Length; x++) {
					if (col[x]) {
						s += map[i][x];
					}
				}
				Console.WriteLine(s);
			}
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int a, b;

int main(void)
{
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    lint N,K;
    cin >> N >> K;
    lint c=0;
    for(int i=N+1;i>=K;i--){
        c+=((N-i+1)*i+1);
        c %= MOD;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3600
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::BTreeMap;

fn main() {
    input!(s: chars, t: chars);
    let n = s.len();
    let s: Vec<usize> = s.iter().map(|&c| c as usize - 'a' as usize + 1).collect();
    let t: Vec<usize> = t.iter().map(|&c| c as usize - 'a' as usize + 1).collect();

    let mut to = vec![0; 27];
    for i in 0..n {
        if to[s[i]] == 0 {
            to[s[i]] = t[i];
        } else if to[s[i]] != t[i] {
            println!("No");
            return;
        }
    }

    let (s, t) = (t, s);

    let mut to = vec![0; 27];
    for i in 0..n {
        if to[s[i]] == 0 {
            to[s[i]] = t[i];
        } else if to[s[i]] != t[i] {
            println!("No");
            return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 10492
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <utility>

using ll = long long;
using Pair = std::pair<ll, ll>;

const int MAX_N = 1e5 + 10;

int N;
int A[MAX_N];

int main() {
    std::cin >> N;
    std::map<int, int> cnt;

    for(int i = 0; i < N; ++i) {
        std::cin >> A[i];

        ++cnt[A[i]];
    }
    int m = 0;
    for(auto& p : cnt) {
        if(p.second >= 2) {
            if(p.second % 2 == 0)
                ++m;
        }
    }

    if(m % 2 == 0) {
        std::cout << cnt.size() << std::endl;
    }else {
        std::cout << cnt.size() - 1 << std::endl;
    }
}

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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}

template<typename T>
int UBS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}

	if (mas[l] >= val)
		return l;
	if (mas[r] >= val)
		return r;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main()
{
	IOS
	int mas[4] = {0,0,0,0};
	for(int i  =0;i < 3; ++i){
		int a,b;
		cin >> a >>b;
		mas[a-1]++;
		mas[b-1]++;
	}
	int one = 0;
	int two = 0;
	for(int i =0;i < 4; ++i){
		if(mas[i]%2 == 0)
			two++;
		else
			one++;
	}
	if(one == 0 || one == 2)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1000000000000000LL
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,sum,top,a[200005],b[200005],c[200005],ans,sum0,sum1,ture1;
long long top2,now,d[200005],e[200005],sum2[200005];
char s[200005];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	s[0]='0';
	for(i=1;i<=n;i++)
		if(s[i]=='0')
			sum++;
		else{
			if(s[i-1]=='0'){
				top++;
				c[top]=(i&1);
				b[top]=1;
				a[top]=sum;
				sum=0;
			}
			else
				b[top]++;
		}
	if(top==0){
		pus(0,2);
		return 0;
	}
	sum0=sum;
	for(i=1;i<=top;i++){
		sum0+=a[i];
		sum1+=b[i]/2;
		ture1+=b[i];
	}
	ans=(sum0+1)*sum1;
	ture1--;
	if(ture1&1)
		ans+=ture1/2+1;
	ture1/=2;
	ans+=ture1*(ture1+1);
	//pus(ans,2);
	for(i=1;i<=top;i++)
		if(b[i]&1){
			top2++;
			d[top2]+=a[i];
			e[top2]=c[i];
		}
		else
			d[top2+1]+=a[i];
	for(i=top2;i>=1;i--){
		sum2[i]=sum2[i+1]+e[i];
		ans+=e[i];
	}
	//pus(ans,2);
	for(i=1;i<=top2;i++)
		if((e[i]^now)==0){
			d[i]--;
			now^=1;
			if(now==0)
				ans+=sum2[i]+i-1;
			else
				ans+=top2-sum2[i];
		}
	//pus(ans,2);
	sum2[top2+1]=sum+d[top2+1];
	for(i=top2;i>=1;i--)
		sum2[i]=sum2[i+1]+d[i];
	sum=0;
	for(i=1;i<=top2;i++){
		sum+=d[i];
		ans+=sum2[i+1]+sum/2;
	}
	pus(ans,2);
	//for(i=1;i<=top;i++)
	//	cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 m, d, cnt = 0; cin >> m >> d;
    rep1(i,m) {
        rep1(j,d) {
            i32 d1 = j%10, d2 = (j - j%10)/10;
            if(d1<2 || d2<2) continue;
            if(i == d1*d2) ++cnt;
        }
    }
    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
class UnionFind_PathCompression
  attr_reader :rank, :parent, :value
  attr_writer :rank, :parent

  def initialize(x)
    @value = x
    @rank = 0
    @parent = self
  end

  def ==(obj)
    @value == obj.value
  end

  def find
    return self if self.parent == self
    root = self.parent.find
    self.parent = root
    root
  end

  def union(y)
    xr = find; yr = y.find
    return if xr == yr
    if xr.rank >= yr.rank
      yr.parent = xr
      xr.rank += 1
    else
      y.union(self)
    end
  end
end

N,M = gets.split.map(&:to_i)
langs = (0..M).map{ nil }
UF = (1..N).map{ |n| UnionFind_PathCompression.new(n) }

(1..N).each { |k|
  ls = gets.split.map(&:to_i)[1..-1]
  u1 = UF[k-1]
  ls.each{ |l|
    if u2 = langs[l]
      u1.union(u2)
    end
    langs[l] = u1
  }
}

puts UF.map{ |u| u.find.value }.uniq.size == 1 ? "YES" : "NO"


Measured memory_bytes: 11940
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

const string SP = " ";
int A[20][20];
int ret[(1 << 16)];
int n;

bool check(int x) {
  for (int i = 0; i < 16; i++) {
    if ((x & (1 << i)) == 0) continue;
    int y = x;
    for (int j = 0; j < 16; j++) {
      if ((x & (1 << j)) != 0 && A[i][j] == 0) {
        return false;
      }
      if ((x & (1 << j)) == 0 && A[i][j] == 1) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) A[i][j] = -1;
  for (int i = 0; i < (1 << n); i++) ret[i] = -1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      x--;
      A[i][x] = y;
    }
  }
  int ans = 0;
  for (int i = 1; i < (1 << n); i++) {
    if (check(i)) {
      ans = max(ans, __builtin_popcount(i));
      cerr << i << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    int b = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] > 1) b = 1;
    }
    if (a[0] != 0) b = 1;
    if (b) {
        cout << -1 << endl;
        return 0;
    }

    ll r = 0;
    int c = 0;
    for (int i = n - 1; i > 0; i--) {
        if (c > 0) c--;
        if (a[i] == c) continue;
        r += a[i];
        c = a[i];
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int main(){
	string S;
	ios::sync_with_stdio(false);
	cin>>S;
	rep(k,S.length()-1)
	if(S.substr(k,2)=="AC"){
		cout<<"Yes\n";
		return 0;
	} 
	cout<<"No\n";
	return 0;
}

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

ll n, v[3005];
ll dp[3005][3005][5];

ll solve(ll esq, ll dir, ll flag){
    if(esq == dir) return + (flag == 0 ? 1 : -1) * v[esq];
    if(dp[esq][dir][flag] != -1) return dp[esq][dir][flag];
    ll r1 = solve(esq+1, dir, !flag) + (flag == 0 ? 1 : -1) * v[esq];
    ll r2 = solve(esq, dir-1, !flag) + (flag == 0 ? 1 : -1) * v[dir];
    if(flag == 0) return dp[esq][dir][flag] = max(r1,r2);
    else return dp[esq][dir][flag] = min(r1,r2);
}

int main(){
    memset(dp, -1, sizeof dp);
    cin >> n;
    ll sum = 0;
    for(ll i = 0; i < n; i++)
        cin >> v[i], sum += v[i];
    cout << solve(0, n-1, 0) << endl;
	return 0;
}


Measured memory_bytes: 353152
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n,k,i;
	scanf("%d%d",&n,&k);
	char s[100005];
	int a[100005];
	int b[100005];
	int cnt;
	scanf("%s",s);
	//連続する1の数を正、0の数を負として配列a[]に保存する
	i=0;cnt=1;
	a[0]=0;
	while(i<n){
		while(s[i]=='0'){
			a[cnt]--;
			i++;
			if(s[i]=='1'){
				cnt++;
			}
		}
		while(s[i]=='1'){
			a[cnt]++;
			i++;
			if(s[i]=='0'){
				cnt++;
			}
		}
	}
	cnt++;
	//printf("cnt=%d\n",cnt);//cntの個数を表示
	//累積和を作成
	b[0]=abs(a[0]);
	for(i=1;i<cnt;i++){
		b[i]= b[i-1]+abs(a[i]);
	}
	int ans=b[1];
	int temp;
	int min ( int x ,int y){
		int min = x;
		if(min>y)min=y;
		return y;
	}
	for(i=0;i<cnt;i++){
		//printf("a[%d]=%d\n",i,a[i]);
	}
	for(i=0;i<cnt;i++){
		//printf("b[%d]=%d\n",i,b[i]);
	}
	for(i=1;i<cnt;i++){
		//左端がiでa[i]の値を使って右端rを求めていく。
		int r;
		if(a[i]>0){
			r= i+2*k;
			if(r>=cnt)r=cnt-1;
		}else{
			r = i+(2*k)-1;
			if(r>=cnt)r=cnt-1;
		}
		temp = b[r]-b[i-1];
		//printf("temp=%d\n",temp);
		if(temp>ans)ans=temp;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <queue>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
long long N, M, ans;

int main()
{
    cin >> N >> M;
    if (N == 1 && M == 1)
    {
        ans = 1;
    }
    else if (N == 1 || M == 1)
    {
        if (N == 1)
        {
            ans = M - 2;
        }
        else if (M == 1)
        {
            ans = N - 2;
        }
    }
    else
    {
        ans = N * M - (N - 2) * 2 - (M - 2) * 2 - 4;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      for (Vertex v : vertices) {
        if(v.state == Vertex.WHITE)
          depthFirstSearch(v.index);
      }
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.findTime).append(" ")
             .append(v.doneTime).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void depthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].findTime = ++time;
      
      for(int ajcIndex: vertices[index].ajacent) {
        if(vertices[ajcIndex].state == Vertex.WHITE)
          depthFirstSearch(ajcIndex);
      }
      vertices[index].state = Vertex.BLACK;
      vertices[index].doneTime = ++time;
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
      }
    }
  }
}


Measured memory_bytes: 24232
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

bitset<4000001>d;
int main() {
	d[0] = 1;
	int sum = 0;
	int n;
	scanf("%d", &n);
	fup(i, 0, n - 1, 1)
	{
		int x;
		scanf("%d", &x);
		sum += x;
		d |= d << x;
	}
	fup(i, (sum+1) / 2, 4000000, 1)
	{
		if (d[i])
		{
			printf("%d", i);
			return 0;
		}
	}
}

Measured memory_bytes: 1664
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)

    val x_1 = sc.nextInt();
    val y_1 = sc.nextInt();
    val x_2 = sc.nextInt();
    val y_2 = sc.nextInt();

    val AB = arrayOf(x_2 - x_1, y_2 - y_1)
    val BC = arrayOf(-AB[1], AB[0])
    val CD = arrayOf(-AB[0], -AB[1])

    val x_3 = x_2 + BC[0]
    val y_3 = y_2 + BC[1]
    val x_4 = x_3 + CD[0]
    val y_4 = y_3 + CD[1]

    println("$x_3 $y_3 $x_4 $y_4")
}

Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int A, B; cin >> A >> B;

    int a = 1;
    int ans = 0;

    while (a < B)
    {
        a += A - 1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N = 0;
    string Number;
    cin >> Number;
    for (int i = 0; i < Number.size(); i++) {
        char X=Number[i]-48;
        N += X;
        if (N % 9 == 0) N = 0;
    }
    if (N == 0)
        cout << "Yes"<< endl;
    else
        cout << "No"  << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int x,y,n,m,a[110],b[110],i,ch;
int main(){
    scanf(" %d %d %d %d",&n,&m,&x,&y);
    for(i=1;i<=n;i++){
        scanf(" %d",&a[i]);
    }
    for(i=1;i<=m;i++){
        scanf(" %d",&b[i]);
    }
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    for(i=x+1;i<=y;i++){
        if(i>a[n] && i<=b[1]){
            ch=1;
            break;
        }
    }
    if(ch){
        printf("No ");
    }
    printf("War");
}


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


int main()
{
    string S;
    cin >> S;
    if( S[1] == 'R'){
        cout << "ABC" << endl;
    }else if( S[1] == 'B' ){
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

int main()
{
	int n;
	std::cin >> n;
	
	std::vector<int> vc(n);
	int a;
	for (int i = 1; i < n; i++) {
		std::cin >> a;
		vc[a - 1]++;
	}
	
	for (auto e : vc) {
		std::cout << e << '\n';
	}
	std::cout << std::flush;
	
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

map< int , int > mp[nax];
int main()
{
	int n , m;
	cin >> n >> m;
	cout << (n - 1 ) * ( m - 1 ) << endl;
	return 0;
} 




Measured memory_bytes: 93952
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

        static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        int x = in.i();
                        int a = in.i();
                        int b = in.i();
                        x -= a;
                        out.println(x % b);
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                public int i() {
                        int num = 0, b;
                        boolean minus = false;
                        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
                        if (b == '-') {
                                minus = true;
                                b = readByte();
                        }

                        while (true) {
                                if (b >= '0' && b <= '9') {
                                        num = num * 10 + (b - '0');
                                } else {
                                        return minus ? -num : num;
                                }
                                b = readByte();
                        }
                }

        }
}



Measured memory_bytes: 21460
from collections import Counter
from itertools import combinations
n, k = map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9 + 7
inv_num = 0
for left, right in combinations(A, 2):
    if left > right:
        inv_num += 1
#print(inv_num)

acc_num = 0
counter = Counter(A)
rest = n
for key in sorted(counter.keys(), reverse=True):
    rest -= counter[key]
    acc_num += rest * counter[key]

total = (inv_num * k) % mod
total += ((acc_num % mod) * ((k * (k - 1) // 2) % mod)) % mod
total %= mod
print(total)


Measured memory_bytes: 41180