akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/
ll a[3005][3005];
ll dp[3005][3005][4];
int main()
{
 #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif  
 
  IOS;
  ll r,c,k;
  cin>>r>>c>>k;
   memset(a,0,sizeof(a));
  for(int i=0;i<k;i++)
  {
    ll x,y,z;
    cin>>x>>y>>z;
    a[x][y]=z;
  }
  memset(dp,0,sizeof(dp));
 
  dp[1][1][0]=0;
  dp[1][1][1]=a[1][1];
  for(int i=1;i<=r;i++)
  {
    for(int j=1;j<=c;j++)
    {
     /* dp[i][j][0]=0;
      if(i==1 && j==1)
        continue;
      dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
      for(int x=0;x<=3;x++)
      {
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][x]);
        dp[i][j][1]=max(dp[i][j][],dp[i-1][j][x]+a[i][j]);
      }
      for(int x=1;x<=min(j,3);x++)
      {
        dp[i][j][x]=max(dp[i][j][x],max(dp[i][j-1][x],dp[i][j-1][x-1]+a[i][j]));
      }*/
      if(i==1 && j==1)
        continue;
      dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
      for(int k=0;k<=3;k++)
      {
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
        dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+a[i][j]);
      }
      for(int k=1;k<=min(j,3);k++)
      {
        dp[i][j][k]=max(dp[i][j][k],max(dp[i][j-1][k],dp[i][j-1][k-1]+a[i][j]));
      }
    }
  }
  ll ans=INT_MIN;
  for(int i=0;i<=3;i++)
    ans=max(ans,dp[r][c][i]);
  cout<<ans<<endl;

}

Measured memory_bytes: 356416
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=0,d=0;
  vector<int> c;
  cin>>a;
  for(int i=1;i*i<=a;i++){
    if(a%i==0){
      c.push_back(i);
      if(i*i!=a) c.push_back(a/i);
    }
  }
  b=c.size();
  if(b%2==0) d=1;
  sort(c.begin(),c.end());
  // cout<<c[(b-1)/2]<<" "<<c[b-(b-(b-1)/2)+d]<<"\n";
  //cout<<b<<"\n";
  cout<<c[(b-1)/2]+c[b-(b-(b-1)/2)+d]-2<<"\n";
  //for(int i=0;i<b;i++) cout<<c[i]<<"\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#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++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int L;
    cin >> L;
    ll cube;
    ld ans;
    if (L >= 27)
    {
        cube = L * L * L;
        cout << cube / 27 << endl;
    }
    else
    {
        ans = L * L * L;
        cout << ans / 27 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////




int main(){fastio
    ll n;cin>>n;
    vector<l_l>v;
    rep(i,1,n){
        rep(j,i+1,n){
            if(n%2==0){
                if(i+j==n+1)continue;
                else v.pb(l_l(i,j));
            }else{
                if(i+j==n)continue;
                else v.pb(l_l(i,j));
            }
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x.first<<" "<<x.second<<endl;
    
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;



ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{
//ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vi a(n);
    rep(i,0,n)cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll ans=a[0];
    ll j=2;
    rep(i,1,n)
    {
        if(j>=n)break;
        if(j==n-1)
        {
            ans+=a[i];
            break;
        }
        else{
            ans+=a[i]*2ll;
            j+=2;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long int LL;
typedef pair<int, int> PII;

int main(void){
  LL n, m;
  cin >> n >> m;
  LL l[m], r[m];
  int _min = 1, _max = n;

  // for (int i = 0; i < n; i++) {
  //   ans[i] = 0;
  // }

  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    if (_min < l[i]) _min = l[i];
    if (r[i] < _max) _max = r[i];
  }

  if(_max < _min) {
    cout << 0 << endl;
  } else {
    cout << _max - _min + 1 << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> nums(n);
  for(int i=0; i<n; ++i) {
  	cin >> nums[i];
  }
  
  sort(nums.begin(), nums.end());
  vector<int> list(nums.back()+1, 0);
  int prev = -1;
  for (auto num : nums) {
    int cur = num;
    if (prev == cur) {
    	list[cur]++;
      	continue;
    }
  	while (cur <= nums.back()) {
    	list[cur]++;
      	cur+=num;
    }
    prev = num;
  }
  int ans = 0;
  for (auto num : nums) {
  	if(list[num] < 2) {
    	ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 8012
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  if((A+B) % 2 == 0) {
    cout << (A+B)/2 << endl;
  } else {
    cout << "IMPOSSIBLE" <<endl;
  }
  return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

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

    while (!b.equals(0)) {
      int cnt = 0;

      for(int n = 2; n*(n-1) < 2*b; n++) {
        int bunsi = 2*b -n*(n-1);
        int bunbo = 2*n;
        if(bunsi % bunbo == 0) cnt++;
      }
      System.out.println(cnt);
      b = Integer.parseInt(sc.next());
    }
  }
}



Measured memory_bytes: 26252
from math import sqrt, ceil
import fractions
A, B = map(int, input().split())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


ans = 1

tmp = make_divisors(fractions.gcd(A, B))

for x in tmp:
    if is_prime(x):
        ans += 1

print(ans)


Measured memory_bytes: 5216
int main()
{
  int n;
  scanf("%d", &n);
  char s[4];
  int i;
  int a = 0, w = 0, t = 0, r = 0;
  for (i = 0; i < n; i++)
  {
    scanf("%s", s);
    if (s[0] == 'A')
      a++;
    else if (s[0] == 'W')
      w++;
    else if (s[0] == 'T')
      t++;
    else if (s[0] == 'R')
      r++;
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, w, t, r);
}


Measured memory_bytes: 1724
#include <stdio.h>
int main(void){
    long a,b;
    
    scanf("%ld %ld", &a,&b);
        while(1){
            if(a>=b) a=a-b;
            else if(b>a) b=b-a;
            if(a==0 || b==0)break;
        }
        if(a==0){
            printf("%ld\n",b);
        }
        if(b==0){
            printf("%ld\n",a);
        }
    
    
    return 0;
}

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

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int count = Integer.parseInt(br.readLine());
		while(count > 0){
			String s = br.readLine();
			double x1 = Double.parseDouble(s.split(" ")[0]);
			double y1 = Double.parseDouble(s.split(" ")[1]);
			double x2 = Double.parseDouble(s.split(" ")[2]);
			double y2 = Double.parseDouble(s.split(" ")[3]);
			double x3 = Double.parseDouble(s.split(" ")[4]);
			double y3 = Double.parseDouble(s.split(" ")[5]);
			double x4 = Double.parseDouble(s.split(" ")[6]);
			double y4 = Double.parseDouble(s.split(" ")[7]);

			if(isParallell(x1,y1,x2,y2,x3,y3,x4, y4)) System.out.println("YES");
			else 									  System.out.println("NO");
			count--;
		}
    }
    private static boolean isParallell(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
    {
		double slope12,slope34;
		
		if((x2-x1)==0) slope12=(y2-y1);
		else slope12 = (y2-y1) / (x2-x1);
		if((x4-x3)==0) slope34=(y4-y3);
		else slope34 = (y4-y3) / (x4-x3);
	
		if(slope12 == slope34) return true;
		else 					return false;
    }
}

Measured memory_bytes: 9812
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var D = cin.scanint;
        Array.Sort(D);
        Array.Reverse(D);
        WriteLine(D[0] * 10 + D[1] + D[2]);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
from copy import deepcopy
NUM = [10000, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6]
n, m = map(int, input().split())
aa = list(map(int, input().split()))

dp = [[-1 for j in range(9)] for i in range(n + 1)]
for j in range(9):
    dp[0][j] = 0
for i in range(1, n + 1):
    for a in aa:
        if i - NUM[a] >= 0 and dp[i - NUM[a]][0] != -1:
            tmp = deepcopy(dp[i - NUM[a]])
            tmp[9 - a] += 1
            if sum(tmp) > sum(dp[i]) or (sum(tmp) == sum(dp[i]) and tmp > dp[i]):
                dp[i] = tmp
ans = ""
for j in range(9):
    for k in range(dp[n][j]):
        ans += str(9 - j)
print(ans)

Measured memory_bytes: 57688
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

int x[4] = {}, y[4] = {}, vx = 0, vy = 0;

int main() {
	cin >> x[0] >> y[0] >> x[1] >> y[1];

	vx = x[1] - x[0];
	vy = y[1] - y[0];

	//if (y[0] >= y[1]) {
		//if (x[0] >= x[1]) {
			x[2] = x[1] - vy;
			y[2] = y[1] + vx;
			x[3] = x[2] - vx;
			y[3] = y[2] - vy;
		//}
		//else {
			x[2] = x[1] - vy;
			y[2] = y[1] + vx;
			x[3] = x[2] - vx;
			y[3] = y[2] - vy;
		//}
	//}
	//else {
		//if (x[0] >= x[1]) {
			x[2] = x[1] - vy;
			y[2] = y[1] + vx;
			x[3] = x[2] - vx;
			y[3] = y[2] - vy;
		//}
		//else {
			x[2] = x[1] - vy;
			y[2] = y[1] + vx;
			x[3] = x[2] - vx;
			y[3] = y[2] - vy;
		//}
	//}

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        String[] astr = str.split(" "); //状況に合わせて
        Boolean flag  = true;
        int[] in_data = Stream.of(astr).mapToInt(x->{
            try{
                return Integer.parseInt(x);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();
        int x = in_data[0];
        int a = in_data[1];

        if(x < a){
            System.out.println("0");
        }else{
            System.out.println("10");
        }

    }
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;
using ll = int64_t;

int main()
{
    int A, B, C;
    ll K;

    cin >> A >> B >> C;
    cin >> K;

    int mns = -1;

    int ans = A - B;

    if (K % 2) ans = mns * (A - B);

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


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> m(N,-1);
  queue<int> q;
  q.push(0);
  m.at(0)=-2;
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:G.at(a)){
      if(m.at(x)==-1){
        m.at(x)=a+1;
        q.push(x);
      }
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<m.at(i)<<endl;
  }
}

Measured memory_bytes: 10172
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a,b;
  double f = 0;
  cin >> a >> b;
  int res;
  if(a%2 == 1) f = 0.5;
  if( 12.5*a+f <= 10*b && 12.5*a+12+f > 10*b ){
    res = 10*b;
  } else if( 12.5*a+f >= 10*b && 12.5*a+f <= 10*b+9 ){
    res = 12.5*a+f; // 最小..
  } else res = -1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,flag=0;
  cin>>n;
  long long a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<n-1;i++)
  {
    if(a[i]==a[i+1])
    {
      flag=1;
      break;
    }
  }
  if(flag==1)
  {
    cout<<"NO"<<endl;
  }
  else
  {
    cout<<"YES"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1920
n,k=map(int,input().split())
dic={}
for i in range(n):
	dic[i+1]=0
for _ in range(k):
	f=input()
	a=list(map(int,input().split()))
	for j in a:
		dic[j]+=1
ans=0
# print(dic)
for i in dic:
	if(dic[i]==0):
		ans+=1
print(ans)



Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
    //ll sieve[10000009];
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll arr[5];
    for(ll i=0;i<5;i++)
        cin >> arr[i];
    ll index=-1;
    for(ll i=0;i<5;i++)
    {
        if(arr[i]==0)
        {
            index=i;
            break;
        }
    }
    index++;
    cout << index << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <math.h>
#include <unordered_map>
#include <map>
#include <set>
#define sc scanf
#define pr printf
using namespace std;
typedef long long ll;
const ll MOD = 1000000000+7;;
unordered_map<int,int> factor;
int main()
{
    int n;
    while(~sc("%d",&n))
    {
        factor.clear();
        for(int i=2; i<=n; i++)
        {
            int t = i;
            for(int j=2; j<=t; j++)
            {
                while(t % j == 0)
                {
                    factor[j]++; t /= j;
                }

            }
            if(t != 1) factor[t]++;

        }
        ll ans = 1;
        for(auto index : factor)
            ans = (ans*(index.second+1))%MOD;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=200010,LOGN=20;
long long n;
long long ans=0;
int main()
{
    read(n);
    for(long long i=1;i<=n;++i) ans+=i*(n-i+1);
    for(int i=1;i<n;++i)
    {
        long long u,v;
        read(u),read(v);
        if(u>v) swap(u,v);
        ans-=u*(n-v+1);
    }
    write(ans),putchar('\n');
	return 0;
}


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

long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x; 
}

long long num(long long n, long long c, long long d) {
    long long G = GCD(c, d);
    long long L = c * d / G;
    return n - n / c - n / d + n / L;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long ans = num(b, c, d) - num((a-1), c, d);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
up=list(map(int,input().split()))
down=list(map(int,input().split()))

up_sum=up[0]
down_sum=sum(down)
ans=up_sum+down_sum

for i in range(1,n):
    up_sum += up[i]
    down_sum -= down[i-1]
    ans=max(ans,up_sum+down_sum)


print(ans)

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

int main() {
int A; int B; int C;
  cin>>A>>B>>C;
  int N=0; int X=0;
  if(A==5) N++;
  else if(A==7) X++;
    
  if(B==5) N++;
  else if(B==7) X++;
   
  if(C==5) N++;
  else if(C==7) X++;
  
  if(N==2&&X==1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main() {
  int n,x;
  cin>>n;
  x=0;
  vector<long int> a(n);
  vector<long int> b(n,0);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      b.at(x)=a.at(i);
      x++;
      i++;
    }
    if(x>1)break;
  }
  cout<<b.at(0)*b.at(1)<<endl;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn calc_comb(n: u64, m: u64) -> u64 {
    let mut ret = 1;
    for i in 0..m {
        ret *= n - i;
        ret /= (i + 1);
    }
    ret
}

fn main() {
    let v: Vec<u64> = read_vec();
    let (n, a, b) = (v[0], v[1], v[2]);
    let mut v: Vec<u64> = read_vec();

    let mut m = BTreeMap::new();
    for elem in v.into_iter() {
        *m.entry(elem).or_insert(0) += 1;
    }

    let mut count = 0;
    let mut sum = 0;
    for (i, key) in m.keys().rev().enumerate() {
        if count + m[key] >= a {
            sum += key * (a - count);
            println!("{}", sum as f64 / a as f64);
            if i == 0 {
                let mut comb = 0;
                for j in a..min(b, m[key]) + 1 {
                    comb += calc_comb(m[key], j);
                }
                println!("{}", comb);
                return;
            } else {
                println!("{}", calc_comb(m[key], a - count));
                return;
            }
        }
        sum += *key * m[key];
        count += m[key];
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
// printElems(&a[0], &a[n]);　みたいな感じで使う。
void printElems(const int* begin, const int* end)
{
	for (const int* p = begin; p != end; ++p) {
		std::cout << *p << ' ';
	}
	std::cout << std::endl;
}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int, 3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL << 60;


ll dp[100005][3];
ll a[100005];
ll b[100005];
ll c[100005];


int main() {
	int n;
	cin >> n;
	rep1(i, n) cin >> a[i] >> b[i] >> c[i];

	rep1(i, n) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	ll ans = 0;
	rep(i, 3) ans = max(ans, dp[n][i]);
	prints(ans);


	return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){//gengo kakunin
	int N,M;cin>>N>>M;
	vector<pair<long,long>> vp[N];
	long p,y;
	rep(i,0,M){
		cin>>p>>y; p--;
		vp[p].push_back({y, i});
	}
	long ans[M];
	rep(i,0,N){
		sort(vp[i].begin(), vp[i].end());
		rep(j,0,vp[i].size()){
			ans[vp[i][j].second] = 1e12 + 1e6 * (i + 1) + (j + 1);
		}
	}
	string s;
	rep(i,0,M){
		s = to_string(ans[i]);
		rep(j,1,s.size()) cout<<s[j];
		cout<<endl;
	}
}

Measured memory_bytes: 7808
#include <stdio.h>

int main(){
  int a,b,m;
  scanf("%d",&a);
  scanf("%d",&b);
  m=a+b;
  if(m<a-b) m=a-b;
  if(m<a*b) m=a*b;
  printf("%d",m);
  return(0);
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
ll n,ans;
vector<ll> d;
ll dfs(ll num,ll sum,ll nowsum){
  if(num == n) return sum + nowsum;
  return dfs(num+1,sum,nowsum*10+d[num])+dfs(num+1,sum+nowsum,d[num]);
}
  
int main(){
  cin >> n;
  while(n){
    d.push_back(n%10);
    n/=10;
  }
  reverse(d.begin(),d.end());
  n=d.size();
  cout << dfs(1,0,d[0]) << endl;
  return 0;
}

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

using namespace std;

int solve(int n, string &s)
{
    int l, r, ans = 0;
    l = 0, r = n - 1;

    while (l < r)
    {
        while (l < n and s[l] != 'W') // left is looking for white stone
            ++l;
        while (r >= 0 and s[r] != 'R') // right is looking for red stone
            --r;
        if (l >= r)
            break;
        swap(s[l], s[r]);
        ++ans;
    }
    return ans;
}

int main(void)
{
    int    n;
    string s;
    cin >> n;
    cin >> s;

    cout << solve(n, s) << endl;

    return 0;
}


Measured memory_bytes: 3744
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=2e5+5;

int n,ans=0;
int a[maxn];
map<int,int,greater<int> > cnt;
map<int,bool> vis;
map<int,vector<int> > g;

void dfs(int u,int p){
	vis[u]=1;
	int sum=0;
	bool f=false;
	FOR(i,0,g[u].size()){
		int v=g[u][i];
//		printf("u=%d v=%d\n",u,v);
		if(v==p) continue;
		if(u==v){
			f=true;
			continue;
		}
		dfs(v,u);
		sum+=cnt[v];
	}
//	printf("u=%d p=%d sum=%d\n",u,p,sum);
	if(sum<cnt[u]){
		cnt[u]-=sum;
		ans+=sum;
		if(f){
			ans+=cnt[u]>>1;
			cnt[u]=cnt[u]&1;
		}
	}else{
		ans+=cnt[u];
		cnt[u]=0;
	}
	return;
}

int main(){
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i),++cnt[a[i]];
	sort(a,a+n);
	vector<int> vec(a,a+n);
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	FOR(i,0,vec.size()){
		for(int j=1<<30;j>vec[i];j>>=1){
			if(cnt[j-vec[i]]){
				g[vec[i]].PB(j-vec[i]);
			}
		}
	}
	FOR(i,0,vec.size()) if(!vis[vec[i]]) dfs(vec[i],-1);
	printf("%d\n",ans);
	return 0;
}

/*
10
6 6 6 6 6 2 2 2 2 2
*/

Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    rep(i,n) cin >> a[i];
    
    int s;
    s=1;
    rep(i,n){
        if(a[i]==s){
            ++s;
        }
    }
    
    if(s==1){
        cout << -1 << endl;
    }
    else{
    cout << n-s+1 << endl;
    }
    return 0;
}

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

size_t length(const string &str)
{
    return str.length();
}

int main()
{
    int N;
    string S;
    cin >> S;
    N = length(S);
    for (int i = 0; i < N; i++)
    {
        S.at(i) = 'x';
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

double radi(double n) {
  return n * M_PI / 180;
}

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hd = h / 12.0 * 360 + (30 * m / 60.0);
  double md = m / 60.0 * 360;
  double hr = radi(hd);
  double mr = radi(md);
  double hx = a * cos(hr);
  double hy = a * sin(hr);
  double mx = b * cos(mr);
  double my = b * sin(mr);
  double ans = sqrt(pow(abs(hx-mx), 2) + pow(abs(hy-my), 2));
  printf("%.10f", ans);
  
   
  return 0;
}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    int H, W;
    cin >> H >> W;
    if (H == 1 && W == 1) {
        cout << 1 << endl;
    } else if (H == 1) {
        cout << W - 2 << endl;
    } else if (W == 1) {
        cout << H - 2 << endl;
    } else {
        ll ans = ll(max(0, H-2)) * max(0, W-2);
        cout << ans << endl;
    }

}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	char O[110], E[110];
	int i;
	scanf("%s",O);
	scanf("%s", E);
	i = 0;
    while(1)
	 {
     printf("%c%c", O[i], E[i]);
        i++;
        if(E[i]==0){
            if(O[i]!=0)printf("%c",O[i]);
            break;}
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;

int main(){
	map<int,int> mp;
	int n,k;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		mp[a]++;
	}

	vector<int> cnt;
	for(auto p:mp){
		cnt.push_back(p.second);
	}

	sort(cnt.begin(),cnt.end());
	if(cnt.size() <= k){
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	for(int i = 0;i < cnt.size() - k;i++){
		ans += cnt[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 10748
<?php
//ワーシャルフロイド（全点対最短路問題）
//スタート地点１つに対してゴールが２つ。流れるものは水
//故に、単純に $cost[$s][$g1] + $cost[$s][$g2] とするとWA
//スタート〜ある点までは合流道。ある点〜それぞれのゴールまでは二股に分かれて進むイメージ
//また、有向グラフ（一方通行）なので注意。
//と言ってもむしろ$cost[$b][$a] = $cost[$a][$b]というコピーが不要になるので楽。


$file_handle = fopen('php://stdin', "r");

function warshall_floyd($cost) {
	global $n;

	for ($i = 1; $i <= $n; ++$i) {
	    for ($j = 1; $j <= $n; ++$j) {
	        for ($k = 1; $k <= $n; ++$k) {
	        	//INFだったらスルー。これで劇的に早くなる。
	        	if ($cost[$j][$i]===INF || $cost[$i][$k]===INF) continue;
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $cost[$j][$i] + $cost[$i][$k];
	            if ($via < $cost[$j][$k]) {
	                $cost[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $cost;
}


while(1){
	//ファイル読み込み
	$info = trim(fgets($file_handle));
	$explode = explode(' ', $info);
	$n = $explode[0]; $m = $explode[1]; $s = $explode[2]; $g1 = $explode[3]; $g2 = $explode[4];
	//終了条件
	if ($n==0) break;
	
	//初期化

	//ワーシャルフロイド準備。
	for ($i=1; $i<=$n; ++$i){
		for ($j=1; $j<=$n; ++$j){
			if ($i === $j){
				$cost[$i][$i] = 0;
			} else {
				$cost[$i][$j] = INF;
			}
		}
	}

	//辺の情報を格納
	for ($i=1; $i<=$m; ++$i){
		$info2 = trim(fgets($file_handle));
		$e = explode(' ', $info2);
		$cost[$e[0]][$e[1]] = $e[2];
	}

	//探索。先に全点対最短路を求めておく必要がある
	$cost = warshall_floyd($cost);
	
	//最小値計算
	$min = INF;
	for($i=1; $i<=$n; ++$i){
		//どこで分岐するのが最も総コストが低いか比較
		$via = $cost[$s][$i] + $cost[$i][$g1] + $cost[$i][$g2];
		$min = min($min, $via);
	}
	
	//出力
	echo $min.PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 9912
//C
#include <cassert>
#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>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#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>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	string S, T;
	cin >> S >> T;
	int N = S.size();
	for (int i = 0; i < N; i++) {
		S = S.substr(N - 1, 1) + S.substr(0, N - 1);
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

struct amida{
  int to, from;  
};

int main() {
    int n, m, a;
    while(cin >> n >> m >> a, n||m||a){
        vector<vector<amida> > v(1010);
        
        for(int i=0; i<m; ++i){
            int h, p, q; cin >> h >> p >> q;
            v[h].push_back({p, q});
        }
        
        int pos=a;
        for(int i=1000; i>=1; --i){
            for(int j=0; j<v[i].size(); ++j){
                if(v[i][j].to==pos){
                    pos = v[i][j].from;
                    continue;
                }
                if(v[i][j].from==pos){
                    pos = v[i][j].to;
                    continue;
                }
            }
        }
        cout << pos << endl;
    }
    
    
	return 0;
}


Measured memory_bytes: 3060
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    List<Integer> A = new ArrayList<Integer>();
    List<Integer> B = new ArrayList<Integer>();
    for(int i=0; i<M; i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a == 1) B.add(b);
      if(b == N) A.add(a);
    }
    Collections.sort(A);
    Collections.sort(B);
    int j = 0;
    int k = 0;
    boolean check = false;
    for(int i=1; i<=N; i++){
      while(j < A.size() && A.get(j) < i) j++;
      while(k < B.size() && B.get(k) < i) k++;
      if(j >= A.size() || k >= B.size()) break;
      if(A.get(j).equals(B.get(k)) ){
        check = true;
        break;
      }
    }
    if(check == true) out.println("POSSIBLE");
    else out.println("IMPOSSIBLE");   
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, n, x, y;
  string s, t, u;
  cin >> s;
  rep(i, s.length())
  {
    if (s[i] == ',')
      s[i] = ' ';
  }
  pr(s);
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(){
 
    int Sn = 0;
    int Hn = 0;
    int Dn = 0;
    int* Wh;
    int* C;
    int Sc = 0;
 
    cin >> Sn;
    for (int D = 0; D < Sn; ++D){

        cin >> Hn;
        cin >> Dn;
        Wh = new int[Hn];
        for (int i = 0; i < Hn; ++i){
            cin >> Wh[i];
        }
        if (Hn <= Dn){
            cout << 0 << endl;
            continue;
        }
        C = new int[Hn - 1];
        for (int i = 0; i < Hn - 1; ++i){
            C[i] = Wh[i + 1] - Wh[i];
        }
        Sc = Wh[Hn - 1] - Wh[0];

        sort(&C[0], &C[0]+Hn-1);
        for (int i = 0; i < Dn - 1; ++i){
            Sc -= C[Hn - i - 2];
        }

        cout << Sc << endl;
    }
 
    return 0;
}

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

int N, M;
int C[100000];

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int A, B; cin >> A >> B; --A; --B; ++C[A]; ++C[B];
  }
  bool good = true;
  for(int i = 0; i < N; ++i) {
    if(C[i] % 2 == 1) good = false;
  }
  cout << (good ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  ll k;
  cin  >> s >> k;
  int n = s.size();
  char x=s[0];
  char y=s[n-1];
  ll cnt = 0;
  ll first;
  ll last;
  vector<ll>vec;
  if(n==1){
    cout<<n*k/2<<endl;
    return 0;
  }
  rep(i,n-1){
    if(s[i] == s[i+1]) cnt++;
    else{
      vec.push_back(cnt);
      cnt = 0;
    }
    if(i==n-2){
      vec.push_back(cnt);
    }
    last = cnt;
  }
  ll ans = 0;
  int m=vec.size();
  if(x!=y){
    rep(i,m){
      ans += (vec[i]+1)/2;
    }  
    ans *=k ;
  }   
  else{
    first = vec[0];
    if(m==1){
      cout << (vec[0]+1)*k/2 << endl;
      return 0;
    }
    for(int i=1;i<m-1;i++){
      ans += (vec[i]+1)/2;
    }
    ans*=k;
    first++;
    last++;
    ll num = (first+last)/2;
    ans += num *(k-1);
    ans += first/2;
    ans += last/2;
  }
    
  cout << ans << endl;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b >= c) {
		cout << 0<< endl;
		return 0;
	}
	else {
		cout << c - a + b << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int w,n;
	int num[30]={};
	int i,j,tmp,count;
	
	scanf("%d",&w);
	for(i=0;i<w;i++){
		num[i]=i+1;
	}
	scanf("%d",&n);
	for(count=0;count<n;count++){
		scanf("%d,%d",&i,&j);
		tmp=num[i-1];
		num[i-1]=num[j-1];
		num[j-1]=tmp;
	}
	for(count=0;count<w;count++){
		printf("%d\n",num[count]);
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
for i in range(n):
    a,b = map(int, input().split())
    coor = [[0for i in range(b+1)]for i in range(a+1)]
    p = int(input())
    prob = {}
    for k in range(p):
        z,x,c,v = map(int, input().split())
        if (z == c):
            r = max(x,v)
            if ((z,r) in prob.keys()):  ## list는 dictionary의 key가 안되지만 tuple은 가능
                prob[(z,r)] = 'xy'      ## (tuple의 불변성 때문인걸로 기억남)
            else:
                prob[(z,r)] = 'y'
        if (x == v):
            r = max(z,c)
            if ((r,x) in prob.keys()):
                prob[(r,x)] = 'xy'
            else:
                prob[(r,x)] = 'x'
    for k in range(a+1):
        for l in range(b+1):
            if (p == 0):
                if (k == 0 or l == 0):
                    coor[k][l] = 1
                else:
                    coor[k][l] = coor[k-1][l] + coor[k][l-1]   
            elif (k == 0 and l == 0):
                coor[0][0] = 1
            elif (k == 0):
                if ((k,l) in prob.keys()):
                    coor[0][l] = 0
                else:
                    coor[0][l] = coor[0][l-1]
            elif (l == 0):
                if ((k,l) in prob.keys()):
                    coor[k][0] = 0
                else:
                    coor[k][0] = coor[k-1][0]
            elif ((k,l) in prob.keys() and prob[(k,l)] == 'x'):
                coor[k][l] = coor[k][l-1]
            elif ((k,l) in prob.keys() and prob[(k,l)] == 'y'):
                coor[k][l] = coor[k-1][l]
            elif ((k,l) in prob.keys() and prob[(k,l)] == 'xy'):
                coor[k][l] = 0
            else:
                coor[k][l] = coor[k-1][l] + coor[k][l-1]
    co = coor[-1][-1]
    if (co == 0):
        print('Miserable Hokusai!')
    else:
        print(co)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
#define inf 1e18+8
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int id[N];
signed  main()
{
   vi arr(N);
   int n,m;
   cin>>n;

   for(int i=2;i<=n;i++)
    {
        int c;cin>>c;
        id[c]++;
    }
    for(int i=1;i<=n;i++) cout<<id[i]<<endl;

   
    
}

Measured memory_bytes: 6268